public ActionResult CreateProcess(FormCollection frm) { int kt = 0; try { // TODO: Add insert logic here Models.ContactDetails ad = new Models.ContactDetails() { Address = frm["Address"], Phone = frm["Phone"], Email = frm["Email"] }; kt = ContactsBusiness.AddContactDetails(ad); } catch { kt = 0; } if (kt > 0) { return RedirectToAction("ListContact", "ContactDetails", new { add = "success" }); } else { return RedirectToAction("ListContact", "ContactDetails", new { add = "error" }); } }
public static int EditContactDetails(ContactDetails ad) { int upt = 0; try { upt = DataAccessLayer.ContactDetailsDA.EditContact(ad); } catch (Exception) { return 0; } return upt; }
public static int AddContactDetails(ContactDetails ad) { int ins = 0; try { ins = DataAccessLayer.ContactDetailsDA.AddContact(ad); } catch (Exception) { return 0; } return ins; }
public ActionResult EditProcess(int id, FormCollection frm) { int kt = 0; try { // TODO: Add insert logic here Models.ContactDetails ad = new Models.ContactDetails() { Id = int.Parse(frm["Id"]), Address = frm["Address"], Phone = frm["Phone"], Email = frm["Email"] }; kt = ContactsBusiness.EditContactDetails(ad); } catch { kt = 0; } if (kt > 0) { return RedirectToAction("ListContact", "ContactDetails", new { update = "success" }); } else { return RedirectToAction("ListContact", "ContactDetails", new { update = "error" }); } }
private static List<ContactDetails> AddContactToList(DataTable dt) { List<ContactDetails> ls = new List<ContactDetails>(); try { for (int i = 0; i < dt.Rows.Count; i++) { ContactDetails ad = new ContactDetails() { Id = int.Parse(dt.Rows[i]["Id"].ToString()), Phone = dt.Rows[i]["Phone"].ToString(), Email= dt.Rows[i]["Email"].ToString(), Address= dt.Rows[i]["Address"].ToString() }; ls.Add(ad); } } catch (Exception) { return new List<ContactDetails>(); } return ls; }