public ActionResult CategoryEdit(Models.Race.RaceCategory.RaceCategoryViewModel model) { if (ModelState.IsValid) { Data.Models.RaceCategory raceCategory; if (!model.Id.HasValue) { raceCategory = new Data.Models.RaceCategory(); raceCategory.RaceId = model.RaceId; } else { raceCategory = RaceCategoryRepository.GetById(model.Id.Value); } raceCategory.Name = model.Name; raceCategory.Description = model.Description; raceCategory.Start = model.Start.Value; if (model.Id.HasValue) { RaceCategoryRepository.Update(raceCategory, true); } else { RaceCategoryRepository.Create(raceCategory, true); } return(Content("OK")); } return(PartialView("/Views/Race/Category/Edit.cshtml", model)); }
public ActionResult CategoryEdit(int?id, int raceId) { Models.Race.RaceCategory.RaceCategoryViewModel model; if (id.HasValue) { model = new Models.Race.RaceCategory.RaceCategoryViewModel(RaceCategoryRepository.GetById(id.Value)); } else { model = new Models.Race.RaceCategory.RaceCategoryViewModel() { RaceId = raceId } }; return(PartialView("/Views/Race/Category/Edit.cshtml", model)); }