public ActionResult Edit(CustomerMst customerMst) { db.CustomerMsts.Add(customerMst); db.SaveChanges(); return(Redirect("CustomerList")); }
public ActionResult SaveUpdateCustomer(CustomerMst customerMst) { customerMst.UserName = User.Identity.Name; db.CustomerMsts.Add(customerMst); db.SaveChanges(); return(Redirect("CustomerList")); }
public ActionResult SaveUpdateCustomer(CustomerMst customerMst) { if (customerMst.pk_Custid == 0) { customerMst.Username = User.Identity.Name; customerMst.FirstVisit = DateTime.Now; customerMst.LastVisit = DateTime.Now; customerMst.TotalVisits = 1; customerMst.TotalSpent = 0; customerMst.PointBalance = 0; _db.CustomerMsts.Add(customerMst); _db.SaveChanges(); } else { var customerInDB = _db.CustomerMsts.FirstOrDefault(a => a.pk_Custid == customerMst.pk_Custid); customerInDB.Name = customerMst.Name; customerInDB.MobNo = customerMst.MobNo; customerInDB.Email = customerMst.Email; customerInDB.Username = User.Identity.Name; _db.SaveChanges(); } return(RedirectToAction("CustomerList")); }
public ActionResult Edit(int id) { var EditData = new CustomerMst(); EditData = _db.CustomerMsts.FirstOrDefault(a => a.pk_Custid == id); EditData.Username = User.Identity.Name; _db.SaveChanges(); return(View("SaveUpdateCustomer", EditData)); }
public JsonResult GetCustomerByPhone(string phoneNumber) { CustomerMst customer = _db.CustomerMsts.Where(a => a.MobNo == phoneNumber).OrderByDescending(a => a.LastVisit).FirstOrDefault(); return(Json(customer, JsonRequestBehavior.AllowGet)); }