public ActionResult Create(Contact_Type c) { var data = db.Contact_Type.Where(a => a.contact_type_name == c.contact_type_name && a.contact_type_isDeleted != true).SingleOrDefault(); if (data != null) { ViewBag.errMsg = Servicely.Languages.Language.Contact_type_already_exist; return(View(c)); } db.Contact_Type.Add(c); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Contact_Type c) { var data = db.Contact_Type.Where(a => a.contact_type_name == c.contact_type_name && a.contact_type_id != c.contact_type_id && a.contact_type_isDeleted != true).SingleOrDefault(); if (data != null) { ViewBag.errMsg = Languages.Language.Contact_type_already_exist;; return(View(c)); } db.Entry(c).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }