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 ActionResult AddOrUpdate(int id = 0) { var filter = _filterRepository.Get(id); if (filter == null) { filter = new Entity.Filter(); } ViewBag.EnumValuesSelectList = _enumRepositopy.GetAll().Select(item => new SelectListItem { Text = item.Key, Value = item.Id.ToString() }); return(View(filter)); }
// GET: EnumValue public ActionResult Index() { var modelAllValue = _enumRepositopy.GetAll().ToList(); return(View(modelAllValue)); }