public ActionResult Create(CountryView model) { if (ModelState.IsValid) { CountryDomain domain = new CountryDomain { Name = model.Name, }; RepositoryCountries.Insert(domain); try { RepositoryCountries.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } return View(); }
public ActionResult DeleteConfirmed(CountryView model) { if (model == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } CountryDomain doman = RepositoryCountries.GetById(model.Id); if (doman == null) { return HttpNotFound(String.Format("Country with Id {0} not found.", model.Id)); } try { RepositoryCountries.Delete(doman); RepositoryCountries.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } return View(model); }