public bool commitInsert(location loc) { using (obj) { //inserting into database obj.locations.InsertOnSubmit(loc); obj.SubmitChanges(); return true; } }
partial void Deletelocation(location instance);
partial void Updatelocation(location instance);
partial void Insertlocation(location instance);
public ActionResult Insert(location loc) { //Inserting into the table if (ModelState.IsValid) { try { obj.commitInsert(loc); return RedirectToAction("Index"); } catch { return View(); } } return View(); }
public ActionResult Update(int id, location loc) { //updating a location based on id if (ModelState.IsValid) { try { obj.commitUpdate(id, loc.name, loc.address, loc.postalCode, loc.country, loc.phone); return RedirectToAction("Details/" + id); } catch { return View(); } } return View(); }