public int SaveClient(crm_clients element) { try { if (element.id == 0) { db.crm_clients.Add(element); db.SaveChanges(); } else { try { db.Entry(element).State = EntityState.Modified; db.SaveChanges(); } catch (OptimisticConcurrencyException ex) { RDL.Debug.LogError(ex); } } } catch (Exception ex) { RDL.Debug.LogError(ex); } return(element.id); }
public crm_clients GetClient(int id) { var res = new crm_clients(); res = db.GetClient(id); return(res); }
public crm_clients GetClient(int id) { var res = new crm_clients(); res = db.crm_clients.FirstOrDefault(x => x.id == id); return(res); }
public void SaveClient(crm_clients item) { try { db.SaveClient(item); } catch (Exception ex) { RDL.Debug.LogError(ex); } }
public ActionResult CreateClient(string fio, string note, int sourceID, int statusID) { var mng = new CRMManager(); int? sourceID_ = null; if (sourceID != 0) sourceID_ = sourceID; int? statusID_ = null; if (statusID != 0) statusID_=statusID; var user = HttpContext.User.Identity.Name; var item = new crm_clients { id = 0, fio = fio, city=null, note = note, sourceID =sourceID_, statusID = statusID_, addedBy = user, created = DateTime.Now, nextContact = DateTime.Now, subchannel = null, username = null, needActive = null }; mng.SaveClient(item); return Json(new { result = item.id > 0, clientID = item.id }); }