コード例 #1
0
        public ActionResult DeleteFilter(int filterId)
        {
            BllManager user   = (BllManager)userService.Find(User.Identity.Name);
            BllFilter  filter = user.Filters.FirstOrDefault(x => x.Id == filterId);

            if (filter == null)
            {
                throw new HttpException(404, "Page Not Found");
            }

            user.Filters.Remove(filter);
            userService.Update(user);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        public static DalFilter ToDal(this BllFilter filter, int userId)
        {
            if (filter == null)
            {
                return(null);
            }

            return(new DalFilter
            {
                Id = filter.Id,
                UserId = userId,
                Skills = filter.Skills.ToDictionary(k => k.Key.ToDal(), v => v.Value),
                LastViewed = filter.LastViewed
            });
        }
コード例 #3
0
        public ActionResult Filter(int filterId = 0)
        {
            BllFilter       filter = null;
            FilterViewModel filterModel;

            if (filterId != 0)
            {
                BllManager user = (BllManager)userService.Find(User.Identity.Name);
                filter = user.Filters.FirstOrDefault(x => x.Id == filterId);
            }

            filterModel = ExtractSkills(filter);

            return(View("Filter", filterModel));
        }
コード例 #4
0
        private void SaveFilter(FilterViewModel model)
        {
            BllManager user       = (BllManager)userService.Find(User.Identity.Name);
            BllFilter  filter     = model.ToBal();
            BllFilter  userfilter = user.Filters.FirstOrDefault(x => x.Id == filter.Id);

            if (userfilter == null)
            {
                user.Filters.Add(filter);
            }
            else
            {
                userfilter.Skills     = filter.Skills;
                userfilter.LastViewed = filter.LastViewed;
            }
            userService.Update(user);
        }
コード例 #5
0
        private FilterViewModel ExtractSkills(BllFilter filter)
        {
            int id        = filter != null ? filter.Id : 0;
            var allSkills = skillService.GetAll().Select(x => x.ToMvc()).ToList();

            if (filter != null && filter.Skills != null)
            {
                foreach (var skill in filter.Skills)
                {
                    UserSkillViewModel fsvm = allSkills.First(x => x.Skill.Id == skill.Key.Id);
                    fsvm.Level = skill.Value;
                }
            }

            FilterViewModel filterViewModel = new FilterViewModel
            {
                Id     = id,
                Skills = allSkills
            };

            return(filterViewModel);
        }
コード例 #6
0
        public ActionResult Browse(int Id = 0)
        {
            BllFilter filter;

            if (Id != 0)
            {
                BllManager manager = (BllManager)userService.Find(User.Identity.Name);
                filter = manager.Filters.FirstOrDefault(x => x.Id == Id);
            }
            else
            {
                filter = new BllFilter();
            }
            FilterViewModel filterViewModel = ExtractSkills(filter);

            filterViewModel.LastViewed = DateTime.Now;
            if (Id != 0)
            {
                SaveFilter(filterViewModel);
            }
            return(Browse(filterViewModel));
        }