public void Create(BllUser entity) { entity.Password = Crypto.HashPassword(entity.Password); userRepo.Create(entity.ToDal()); uow.Save(); }
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(); }
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; }
public bool Remove(BllUser entity) { if (entity != null) return Remove(entity.Id); else return false; }
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; }