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")); }
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 }); }
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)); }
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); }
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); }
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)); }