public ActionResult Edit_POST(int id, LocationTypeViewModel locationTypeViewModel) { if (ModelState.IsValid) { try { LocationType locationType = this._locationTypeService.FindOne(id); if (locationType != null) { this._locationTypeService.Update(locationType, locationTypeViewModel.LocationType); var message = String.Format("Platstypen {0} är nu redigerad", locationType.location_type_swe); ViewData["message"] = MvcHtmlString.Create(String.Format("<a href='{0}'>{1}</a>", Url.Action("Edit", "LocationType", new RouteValueDictionary(new { id = locationType.location_type_id })), message)); return View("Index", LocationTypeViewModel.ToViewModel(new LocationType())); } return View("NotFound"); } catch (Exception e) { ModelState.AddModelError(String.Empty, e.Message); } } return View("Edit", locationTypeViewModel); }
public ActionResult Create_POST(LocationTypeViewModel locationTypeViewModel) { if (ModelState.IsValid) { try { var location_type_id = this._locationTypeService.Add(locationTypeViewModel.LocationType); var message = String.Format("Platstypen {0} är nu skapad", locationTypeViewModel.LocationType.location_type_swe); ViewData["message"] = MvcHtmlString.Create(String.Format("<a href='{0}'>{1}</a>", Url.Action("Edit", "LocationType", new RouteValueDictionary(new { id = location_type_id })), message)); return View("Index", LocationTypeViewModel.ToViewModel(new LocationType())); } catch (Exception e) { ModelState.AddModelError(String.Empty, e.Message); } } return View("Create", locationTypeViewModel); }