public ActionResult AddOrUpdate(int id = 0) { var model = _productRepository.Get(id); var categoriesViewModel = _categoryRepository.GetAll().Select(i => new Models.CategoryAdminViewModel { Checked = false, Id = i.Id, Title = i.Title }).ToList(); if (model != null && model.Categories != null) { foreach (var item in model.Categories) { categoriesViewModel.FirstOrDefault(i => i.Id == item.Id).Checked = true; } } else { model = new Product(); } ViewBag.FiltersSelectList = _filterRepository.GetAll().ToList().Select(item => new SelectListItem { Text = item.Title, Value = item.Id.ToString() }); ViewBag.EnumValuesSelectList = _enumRepositopy.GetAll().ToList().Select(item => new SelectListItem { Text = item.Key, Value = item.Id.ToString() }); ViewBag.AllCategories = categoriesViewModel; ViewBag.AllRecommendations = _recommendationRepository.GetAll().Select(item => new SelectListItem { Text = item.Title, Value = item.Id.ToString() }); var routeItem = _routeItemRepository.Get((string)ControllerContext.RequestContext.RouteData.Values["controller"], "Index", id); ViewBag.CurrentFriendlyUrl = routeItem != null ? routeItem.FriendlyUrl : null; return(View(model)); }
public void TestGetAllShouldReturnAllFilters() { _filters.Add(_filter); var results = _repository.GetAll(); Assert.That(results.Single(), Is.EqualTo(_filter)); }
public ActionResult GetTemplateFilter(int id, int count) { var model = _categoryRepository.GetFilters(id).Count(); if (id == 0 || count > model) { model = count; } ViewBag.FiltersSelectList = _filterRepository.GetAll().Select(item => new SelectListItem { Text = item.Title, Value = item.Id.ToString() }); return(PartialView("_PartialCategoryEmptyFilter", model)); }