public ActionResult Create_Post(LeadGenerator objen) { //Employee employee = new Employee(); //TryUpdateModel(employee);// this method handels exception if (ModelState.IsValid) { LeadGeneratorDAL objdal = new LeadGeneratorDAL(); //Bussiness layer logic to save data go here try { objdal.InsertUpdate(objen, 0); } catch (SqlException se) { if (se.Number == 2627) { ModelState.AddModelError("LeadGeneratorName", objen.LeadGeneratorName + " already exists!"); return(View("Create", objen)); } } catch (Exception ex) { } return(RedirectToAction("Index")); } else { return(View()); } }
public ActionResult Edit_Post(LeadGenerator objen) { if (ModelState.IsValid) { LeadGeneratorDAL objdal = new LeadGeneratorDAL(); //Bussiness layer logic to save data go here try { objdal.InsertUpdate(objen, 1); } catch (SqlException se) { if (se.Number == 2627) { ModelState.AddModelError("LeadGeneratorName", objen.LeadGeneratorName + " already exists!"); return(View("Edit", objen)); } } catch (Exception ex) { } return(RedirectToAction("Index")); } else { return(View(objen)); } }