Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
 private void FillAdditionalProperties(DalUser user)
 {
     if (user as DalProgrammer != null)
     {
         ((DalProgrammer)user).Skills = userSkillRepo.Get(x => x.User.Id == user.Id);
     }
     else if (user as DalManager != null)
     {
         ((DalManager)user).Filters = filterRepo.Get(x => x.UserId == user.Id);
     }
 }
Ejemplo n.º 3
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;
        }