public ActionResult Types() { TypesDictViewModel viewModel = new TypesDictViewModel() { Categories = _repository.GetCategories().ToList() , Types = new List <eArchiver.Models.Type>() }; return(View(viewModel)); }
public ActionResult AddType(FormCollection formValues) { string TypeName = formValues["TypeName"]; string sCategoryID = formValues["DictCategoryID"]; int?DictCategoryID = null; int id; if (int.TryParse(sCategoryID, out id)) { DictCategoryID = id; } List <eArchiver.Models.Type> types; if (DictCategoryID.HasValue) { int categoryID = DictCategoryID.Value; if (!string.IsNullOrEmpty(TypeName) && !_repository.TypeExists(TypeName, categoryID)) { _repository.CreateType(TypeName, categoryID); _repository.SubmitChanges(); } else { TempData["Message"] = "Taki typ juz istnieje!"; } types = _repository.GetTypes(DictCategoryID.Value).ToList(); } else { types = new List <eArchiver.Models.Type>(); } TypesDictViewModel viewModel = new TypesDictViewModel() { Categories = _repository.GetCategories().ToList(), Types = types, SelectedCategory = DictCategoryID }; return(PartialView("TypesUserControl", viewModel)); }