Exemplo n.º 1
0
        private void UpdateFilters(BllManager balManager)
        {
            var dbFilters = filterRepo.Get(x => x.UserId == balManager.Id);
            foreach (var filter in balManager.Filters)
            {
                if (dbFilters.Any(x => x.Id == filter.Id))
                    filterRepo.Update(filter.ToDal(balManager.Id));
                else filterRepo.Create(filter.ToDal(balManager.Id));
            }

            foreach (var filter in dbFilters)
            {
                if (!balManager.Filters.Any(x => x.Id == filter.Id))
                    filterRepo.Remove(filter.Id);
            }
        }
Exemplo n.º 2
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;
        }