Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            DeliveryCost deliveryCost = db.DeliveryCosts.Find(id);

            db.DeliveryCosts.Remove(deliveryCost);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public IActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index"));
            }
            DeliveryCost chooseDeliveryCost = dbContext.DeliveryCosts.Find(id);

            return(View(chooseDeliveryCost));
        }
Ejemplo n.º 3
0
 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));
 }
Ejemplo n.º 4
0
 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));
 }
Ejemplo n.º 5
0
        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"));
        }
Ejemplo n.º 6
0
        // 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));
        }
Ejemplo n.º 7
0
        // 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));
        }
Ejemplo n.º 8
0
        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"));
            }
        }
Ejemplo n.º 9
0
        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));
        }