public bool Add(Contact model) { try { entities.Contacts.Add(model); entities.SaveChanges(); return true; } catch (Exception x) { throw x; } }
public JsonResult Save(Contact contact) { try { if (contact.ContactId > 0) new ContactData().Update(contact); else new ContactData().Add(contact); } catch (Exception x) { } return Json(contact, JsonRequestBehavior.AllowGet); }
public bool Update(Contact model) { try { Contact contact = entities.Contacts.Where(x => x.ContactId == model.ContactId).SingleOrDefault(); if (contact != null) { entities.Entry(contact).CurrentValues.SetValues(model); entities.SaveChanges(); return true; } else { return false; } } catch (Exception x) { throw x; } }