public ActionResult DeleteConfirmed(int id) { DeliveryCost deliveryCost = db.DeliveryCosts.Find(id); db.DeliveryCosts.Remove(deliveryCost); db.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index")); } DeliveryCost chooseDeliveryCost = dbContext.DeliveryCosts.Find(id); return(View(chooseDeliveryCost)); }
public IActionResult Create(DeliveryCost newDeliveryCost) { if (ModelState.IsValid) { dbContext.DeliveryCosts.Add(newDeliveryCost); dbContext.SaveChanges(); TempData["notifyMsg"] = "Thêm KHU VỰC GIAO HÀNG thành công!!!"; return(RedirectToAction("Index")); } return(View(newDeliveryCost)); }
public ActionResult Edit([Bind(Include = "deliveryCostID,fromCityID,toCityID,cost")] DeliveryCost deliveryCost) { if (ModelState.IsValid) { db.Entry(deliveryCost).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.fromCityID = new SelectList(db.Cities, "cityID", "cityName", deliveryCost.fromCityID); ViewBag.toCityID = new SelectList(db.Cities, "cityID", "cityName", deliveryCost.toCityID); return(View(deliveryCost)); }
public IActionResult ConfirmDelete(int?id) { if (id == null) { return(RedirectToAction("Index")); } DeliveryCost chooseDeliveryCost = dbContext.DeliveryCosts.Find(id); dbContext.DeliveryCosts.Remove(chooseDeliveryCost); dbContext.SaveChanges(); TempData["notifyMsg"] = "Xóa KHU VỰC GIAO HÀNG thành công!!!"; return(RedirectToAction("Index")); }
// GET: DeliveryCost/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DeliveryCost deliveryCost = db.DeliveryCosts.Find(id); if (deliveryCost == null) { return(HttpNotFound()); } return(View(deliveryCost)); }
// GET: DeliveryCost/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DeliveryCost deliveryCost = db.DeliveryCosts.Find(id); if (deliveryCost == null) { return(HttpNotFound()); } ViewBag.fromCityID = new SelectList(db.Cities, "cityID", "cityName", deliveryCost.fromCityID); ViewBag.toCityID = new SelectList(db.Cities, "cityID", "cityName", deliveryCost.toCityID); return(View(deliveryCost)); }
public ActionResult SaveCost(DeliveryCost deliveryCost) { var exists = db.DeliveryCosts.Where(c => c.fromCityID == deliveryCost.fromCityID && c.toCityID == deliveryCost.toCityID).FirstOrDefault(); if (exists != null) { exists.fromCityID = deliveryCost.fromCityID; exists.toCityID = deliveryCost.toCityID; exists.cost = deliveryCost.cost; db.SaveChanges(); return(Content("OK")); } else { db.DeliveryCosts.Add(deliveryCost); db.SaveChanges(); return(Content("OK")); } }
public IActionResult Edit(int?id, DeliveryCost newDeliveryCost) { if (id == null) { return(RedirectToAction("Index")); } DeliveryCost oldDeliveryCost = dbContext.DeliveryCosts.Find(id); if (ModelState.IsValid) { if (oldDeliveryCost.deliverycost_ID == id) { oldDeliveryCost.deliverycost_AreaName = newDeliveryCost.deliverycost_AreaName; oldDeliveryCost.deliverycost_Cost = newDeliveryCost.deliverycost_Cost; dbContext.SaveChanges(); TempData["notifyMsg"] = "Cập nhật THÔNG TIN DỊCH VỤ GIAO HÀNG thành công!!!"; return(RedirectToAction("Index")); } } return(View(newDeliveryCost)); }