public ActionResult Create() { var model = new CountryModel(); //default values model.Published = true; return View(model); }
public ActionResult Create(CountryModel model, bool continueEditing) { if (ModelState.IsValid) { var country = model.ToEntity(); countryService.Insert(country); SuccessNotification(localizationService.GetResource("Configuration.Countries.Added")); return continueEditing ? RedirectToAction(SystemRouteNames.Edit, new { rowId = country.RowId }) : RedirectToAction(SystemRouteNames.Index); } //If we got this far, something failed, redisplay form return View(model); }
public ActionResult Edit(CountryModel model, bool continueEditing) { var country = countryService.GetById(model.RowId); if (country == null) //No country found with the specified id return RedirectToAction(SystemRouteNames.Index); if (ModelState.IsValid) { country = model.ToEntity(country); countryService.Update(country); SuccessNotification(localizationService.GetResource("Configuration.Countries.Updated")); return continueEditing ? RedirectToAction(SystemRouteNames.Edit, new { rowId = country.RowId }) : RedirectToAction(SystemRouteNames.Index); } //If we got this far, something failed, redisplay form return View(model); }