public ActionResult Create(Customer customer) { if (ModelState.IsValid) { var _user = db.User.Where(r => r.UserName == HttpContext.User.Identity.Name).FirstOrDefault(); customer.UpdateUserId = _user.Id; customer.UpdatedDate = DateTime.Now; customer.CreateUserId = _user.Id; customer.CreatedDate = DateTime.Now; customer.UserId = _user.Id; customer.ReRegisterLastDateTime = DateTime.Now; db.Customer.Add(customer); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CustomerStatusId = new SelectList(db.CustomerStatus, "Id", "Name", customer.CustomerStatusId); ViewBag.UserId = new SelectList(db.User, "Id", "ConfirmationToken", customer.UserId); return View(customer); }
public ActionResult Edit(Customer customer) { if (ModelState.IsValid) { var _customer = db.Customer.Where(r => r.Id == customer.Id).FirstOrDefault(); var _user = db.User.Where(r => r.UserName == HttpContext.User.Identity.Name).FirstOrDefault(); _customer.FirstName = customer.FirstName; _customer.LastName = customer.LastName; _customer.Email = customer.Email; _customer.Mobile = customer.Mobile; _customer.Phone = customer.Phone; _customer.Referance = customer.Referance; _customer.Source = customer.Source; _customer.UserId = customer.UserId; _customer.CustomerStatusId = customer.CustomerStatusId; _customer.UpdatedDate = DateTime.Now; _customer.UpdateUserId = _user.Id; _customer.CustomeCode = customer.CustomeCode; _customer.ReRegisterLastDateTime = customer.ReRegisterLastDateTime; _customer.ReRegisterChecked = customer.ReRegisterChecked; db.Entry(_customer).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CustomerStatusId = new SelectList(db.CustomerStatus, "Id", "Name", customer.CustomerStatusId); ViewBag.UserId = new SelectList(db.User, "Id", "Email", customer.UserId); return View(customer); }