public void DeleteCallLog(int id = 0) { try { NJTicketEntities db = new NJTicketEntities(); NJ_CallLog obj_CallLog = new NJ_CallLog(); if (id > 0) { var clog = db.NJ_CallLog.FirstOrDefault(cl => cl.Id == id); if (clog != null) { db.NJ_CallLog.Remove(clog); db.SaveChanges(); } } } catch (Exception cc) { throw cc; } }
public void AddCallLog(int id = 0, string FirstName = "", string LastName = "", string Phone = "", string Notes = "", string User = "") { HttpContext.Current.Session["LoginId"] = HttpContext.Current.Request.Cookies["LoginId"].Value; try { NJTicketEntities db = new NJTicketEntities(); NJ_CallLog obj_CallLog = new NJ_CallLog(); if (id > 0) { var clog = db.NJ_CallLog.FirstOrDefault(cl => cl.Id == id); if (clog != null) { clog.FirstName = FirstName; clog.LastName = LastName; clog.Phone = Phone; clog.Notes = Notes; clog.Users = User; } } else { obj_CallLog.FirstName = FirstName; obj_CallLog.LastName = LastName; obj_CallLog.Phone = Phone; obj_CallLog.Notes = Notes; obj_CallLog.DateAdded = DateTime.Now; obj_CallLog.AddedBy = Convert.ToInt32(HttpContext.Current.Session["LoginId"]); obj_CallLog.Users = User; db.NJ_CallLog.Add(obj_CallLog); } db.SaveChanges(); } catch (Exception cc) { throw cc; } }