public IActionResult Index() { CosmeticListViewModel listVM = new CosmeticListViewModel(); listVM.Title = "View Cosmetic Categories"; return(View(listVM)); }
public IActionResult Values(CosmeticFieldType column) { if (column.Equals(CosmeticFieldType.All)) { SearchCosmeticsViewModel searchVM = new SearchCosmeticsViewModel(); searchVM.Cosmetics = context.Cosmetics.ToList(); searchVM.Title = "All Cosmetics"; return(View("Cosmetics", searchVM)); } else { CosmeticListViewModel listVM = new CosmeticListViewModel(); IEnumerable <CosmeticField> fields; // List<CosmeticField> fields; switch (column) { case CosmeticFieldType.Finish: fields = context.Finishs.ToList().Cast <CosmeticField>(); break; case CosmeticFieldType.Formulation: fields = context.Formulations.ToList().Cast <CosmeticField>(); break; case CosmeticFieldType.Rating: fields = context.Ratings.ToList().Cast <CosmeticField>(); break; case CosmeticFieldType.SkinType: fields = context.SkinTypes.ToList().Cast <CosmeticField>(); break; case CosmeticFieldType.Color: default: fields = context.Colors.ToList().Cast <CosmeticField>(); break; } listVM.Fields = fields; listVM.Title = "All " + column + " Values"; listVM.Column = column; return(View(listVM)); } }
public ViewResult List(string category) { string _category = category; IEnumerable <Cosmetic> cosmetics = null; string currCategory = ""; if (string.IsNullOrEmpty(category)) { cosmetics = _allcosmetic.Cosmetics.OrderBy(i => i.CosmeticId); } else { if (string.Equals("makeup", category, StringComparison.OrdinalIgnoreCase)) { cosmetics = _allcosmetic.Cosmetics.Where(i => i.Category.CategoryName.Equals("Макияж")).OrderBy(i => i.CosmeticId); currCategory = "Макияж"; } else if (string.Equals("hair", category, StringComparison.OrdinalIgnoreCase)) { cosmetics = _allcosmetic.Cosmetics.Where(i => i.Category.CategoryName.Equals("Уход за волосами")).OrderBy(i => i.CosmeticId); currCategory = "Уход за волосами"; } else if (string.Equals("body", category, StringComparison.OrdinalIgnoreCase)) { cosmetics = _allcosmetic.Cosmetics.Where(i => i.Category.CategoryName.Equals("Уход для тела")).OrderBy(i => i.CosmeticId); currCategory = "Уход для тела"; } else if (string.Equals("face", category, StringComparison.OrdinalIgnoreCase)) { cosmetics = _allcosmetic.Cosmetics.Where(i => i.Category.CategoryName.Equals("Уход для лица")).OrderBy(i => i.CosmeticId); currCategory = "Уход для лица"; } } var cosmeticObj = new CosmeticListViewModel { AllCosmetics = cosmetics, CurrCategory = currCategory }; ViewBag.Title = "Страница с косметикой"; return(View(cosmeticObj)); }