public ActionResult Edit(int id, Main mains) { try { using (mvcar mv = new mvcar()) { mv.Entry(mains).State = EntityState.Modified; mv.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(Main mains) { try { using (mvcar mv = new mvcar())//this creats the data in the database { mv.Mains.Add(mains); mv.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (mvcar mv = new mvcar()) { Main car = mv.Mains.Where(x => x.Id == id).FirstOrDefault(); mv.Mains.Remove(car); mv.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }