예제 #1
0
 public void Create(BllUser entity)
 {
     entity.Password = Crypto.HashPassword(entity.Password);
     userRepo.Create(entity.ToDal());
     uow.Save();
 }
예제 #2
0
        public void Update(BllUser entity)
        {
            BllUser user = Find(entity.Id);

            if (entity is BllProgrammer)
                UpdateUserSkills((BllProgrammer)entity);
            else if (entity is BllManager)
                UpdateFilters((BllManager)entity);

            if (entity.Password != user.Password)
                entity.Password = Crypto.HashPassword(entity.Password);

            userRepo.Update(entity.ToDal());
            uow.Save();
        }
예제 #3
0
        private static DalUser InitializeDalUserProperties(BllUser user)
        {
            DalUser dalUser;
            if (user is BllAdmin)
                dalUser = new DalAdmin();
            else if (user is BllProgrammer)
            {
                BllProgrammer programmer = (BllProgrammer)user;
                DalProgrammer dalProgrammer = new DalProgrammer();
                dalProgrammer.Name = programmer.Name;
                dalProgrammer.About = programmer.About;
                dalProgrammer.BirthDate = programmer.BirthDate;
                dalProgrammer.Photo = programmer.Photo;
                dalProgrammer.ImapeType = programmer.ImageType;
                dalProgrammer.Skills = programmer.Skills.Select(x => new DalUserSkill
                {
                    User = dalProgrammer,
                    Level = x.Value,
                    Skill = x.Key.ToDal()
                });
                dalUser = dalProgrammer;
            }
            else if (user is BllManager)
                dalUser = new DalManager()
                {
                    Filters = ((BllManager)user).Filters.Select(f => f.ToDal(user.Id))
                };
            else dalUser = new DalUser();

            return dalUser;
        }
예제 #4
0
 public bool Remove(BllUser entity)
 {
     if (entity != null)
         return Remove(entity.Id);
     else return false;
 }
예제 #5
0
        private static BllUser InitializeBalUserProperties(DalUser user)
        {
            BllUser balUser;
            if (user is DalAdmin)
                balUser = new BllAdmin();
            else if (user is DalProgrammer)
            {
                DalProgrammer dalProgrammer = (DalProgrammer)user;
                Dictionary<BllSkill, int> skillsDict = null;
                if (dalProgrammer.Skills != null)
                    skillsDict = dalProgrammer.Skills.ToDictionary(k => k.Skill.ToBal(), v => v.Level);
                balUser = new BllProgrammer()
                {
                    Name = dalProgrammer.Name,
                    About = dalProgrammer.About,
                    BirthDate = dalProgrammer.BirthDate,
                    Photo = dalProgrammer.Photo,
                    ImageType = dalProgrammer.ImapeType,
                    Skills = skillsDict
                };
            }
            else if (user is DalManager && ((DalManager)user).Filters != null)
                balUser = new BllManager
                {
                    Filters = ((DalManager)user).Filters.Select(f => f.ToBal()).ToList()
                };
            else balUser = new BllUser();

            return balUser;
        }