public ActionResult Create(FormCollection collection, projectCountry country) { try { var newCountry = db.projectCountries.Where(a => a.nameCountry.Equals(country.nameCountry)).FirstOrDefault(); if (newCountry == null) { db.projectCountries.Add(country); db.SaveChanges(); Session.Add("message", "Country added successfully"); Session["error"] = null; Session["notification"] = null; return(RedirectToAction("Index")); } else { Session.Add("error", "This country already exists!"); Session["message"] = null; Session["notification"] = null; return(RedirectToAction("Create")); } } catch { return(View()); } }
// GET: projectCountries/Details/5 public ActionResult Details(int?id) { Session["error"] = null; Session["notification"] = null; Session["message"] = null; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } projectCountry country = db.projectCountries.Find(id); if (country == null) { return(HttpNotFound()); } return(View(country)); }