private AddCategoryViewModel MakeCategoryList() { var model = new AddCategoryViewModel(); model.CategoriesList = _dataAccess.GetAllEntities() .Select(cat => new SelectListItem { Text = cat.CategoryName, Value = cat.CategoryId.ToString()}); model.Category = new CategoryModel(); model.Category.CategoryList = model.CategoriesList; model.Categories = _dataAccess.GetAllEntities(); return model; }
public ActionResult Index(AddCategoryViewModel model) { _dataAccess.AddNewEntity(model.Category); return RedirectToAction("Index", "ShowCategory"); }