public ActionResult UpdateCustomer(int id) { List <country> countries = db.countries.ToList(); ViewBag.CountryList = new SelectList(countries, "countryid", "countryname"); ViewBag.Error = TempData["Error"]; var ac = db.Addcustomers.Where(i => i.Id == id).FirstOrDefault(); AddcustomerModel model = new AddcustomerModel(); if (ac != null) { model.id = ac.Id; model.Customerid = ac.Customerid; model.Name = ac.Name; model.Dob = ac.Dob; model.countryid = ac.countryid; model.stateid = ac.stateid; model.cityid = ac.cityid; model.Address = ac.Address; model.Email = ac.Email; model.Mobile = ac.Mobile; model.wouldyouliketoparticipateinSurvey = ac.Survey; } else { ViewBag.Error = "No Record found!!"; } return(View(model)); }
public ActionResult Addcustomer() { ViewBag.Success = TempData["Success"]; AddcustomerModel acm = new AddcustomerModel(); List <country> countries = db.countries.ToList(); ViewBag.CountryList = new SelectList(countries, "countryid", "countryname"); return(View(acm)); }
public ActionResult UpdateCustomer(AddcustomerModel model) { Addcustomer ac = db.Addcustomers.Where(i => i.Id == model.id).FirstOrDefault(); ac.Id = model.id; ac.Customerid = model.cityid; ac.Name = model.Name; ac.Dob = model.Dob; ac.countryid = model.countryid; ac.stateid = model.stateid; ac.cityid = model.cityid; ac.Address = model.Address; ac.Email = model.Email; ac.Mobile = model.Mobile; ac.Survey = model.wouldyouliketoparticipateinSurvey; db.SaveChanges(); return(RedirectToAction("Customerlist", "Home")); }
public ActionResult Addcustomer(AddcustomerModel model) { Addcustomer ac = new Addcustomer(); ac.Id = model.id; ac.Customerid = model.cityid; ac.Name = model.Name; ac.Dob = model.Dob; ac.countryid = model.countryid; ac.stateid = model.stateid; ac.cityid = model.cityid; ac.Address = model.Address; ac.Email = model.Email; ac.Mobile = model.Mobile; ac.Survey = model.wouldyouliketoparticipateinSurvey; db.Addcustomers.Add(ac); db.SaveChanges(); TempData["Success"] = "Customer data added successfully."; return(RedirectToAction("Addcustomer", "Home")); }