User.cs

51 lines | 1.223 kB Blame History Raw Download
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

using Model.Entities.Base;
using Model.Entities.Files;
using Model.ViewModel;

namespace Model.Entities.Users
{
    public class User : BaseEntity
    {
        [Required]
        public string Login { set; get; }
        [Required]
        public string Password { set; get; }
        public bool IsActive { set; get; }

        public bool IsAdmin
        {
            get
            {
                return Groups.FirstOrDefault(e => e.Name == EnumDefaultGroups.Администраторы.ToString()) != null;
            }
        }

        [Obsolete]
        public User() { }

        public User(string Login, string Password, bool IsActive, IEnumerable<Group> Groups)
        {
            this.Login = Login;
            this.Password = Password;
            this.IsActive = IsActive;

           this. Groups = new List<Group>(Groups);
        }


        public virtual List<Group> Groups { set; get; } = new List<Group>();

        public virtual List<FS_Item> FS_Items { set; get; } = new List<FS_Item>();

    }
}