// GET: Custo public ActionResult Load() { Custi obj = new Custi { CustomerCode = "40", CustomerName = "Sukesh" }; return(View("Custome", obj)); }
//delete public List <Custi> Delete(Custi obj) { DAL dal = new DAL(); Custi custdelete = (from temp in dal.Customers where temp.CustomerCode == obj.CustomerCode select temp).ToList <Custi>()[0]; dal.Customers.Remove(custdelete); dal.SaveChanges(); List <Custi> customerscoll = dal.Customers.ToList <Custi>(); return(customerscoll); }
//update public List <Custi> Put(Custi obj) { //selesct the record Linq DAL dal = new DAL(); Custi custupdate = (from temp in dal.Customers where temp.CustomerCode == obj.CustomerCode select temp).ToList <Custi>()[0]; custupdate.CustomerAmount = obj.CustomerAmount; custupdate.CustomerName = obj.CustomerName; List <Custi> customerscoll = dal.Customers.ToList <Custi>(); return(customerscoll); //update the record }
public List <Custi> Post(Custi obj) { if (ModelState.IsValid) { //insert the customer object to database //EF DAL DAL objDal = new DAL(); objDal.Customers.Add(obj); //in memory updation objDal.SaveChanges(); //physical commit } DAL dal = new DAL(); List <Custi> customerscoll = dal.Customers.ToList <Custi>(); return(customerscoll); }
public ActionResult Submit()//validation runs and errors ar send to obj called as model state { Custi obj = new Custi(); obj.CustomerName = Request.Form["customer.CustomerName"]; obj.CustomerCode = Request.Form["customer.CustomerCode"]; if (ModelState.IsValid) { //insert the customer object to database //EF DAL CustomerDal Dal = new CustomerDal(); Dal.Customers.Add(obj); //in memory updation Dal.SaveChanges(); //physical commit } CustomerDal dal = new CustomerDal(); List <Custi> customerscoll = dal.Customers.ToList <Custi>(); return(Json(customerscoll, JsonRequestBehavior.AllowGet)); }