// GET: Cost/Delete/5 public ActionResult Delete(int?id) { BookingsModel.Cost cost_ = db.Costs.Find(id); if (cost_ == null) // if its not hthere { return(HttpNotFound()); //throw error } return(View(cost_));//oftherwise through the view. }
// GET: Cost/Edit/5 public ActionResult Edit(int id) { if (id == 0) //if ID is equal to null. { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookingsModel.Cost cost_ = db.Costs.Find(id); if (cost_ == null) // if its not hthere { return(HttpNotFound()); //throw error } return(View(cost_)); }
public ActionResult Edit(BookingsModel.Cost cost_) { try { if (ModelState.IsValid) { db.Entry(cost_).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View(cost_)); } }
public ActionResult Create(BookingsModel.Cost cost_) { try { if (ModelState.IsValid) //if model state is active/. { db.Costs.Add(cost_); } db.SaveChanges(); return(RedirectToAction("Index")); //retur nto index } catch { return(View(cost_)); } }