Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "SupplyID,Provider.ProviderID,Product.ProductID,Quantity,Price,SupplyDate")] SupplyEdit supplyEdit)
 {
     if (ModelState.IsValid)
     {
         serviceSupplies.UpdateSupply(supplyEdit.ToSupply());
         return(RedirectToAction("Index"));
     }
     return(View(supplyEdit));
 }
Exemplo n.º 2
0
        // GET: SupplyViews/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SupplyEdit supplyEdit = new SupplyEdit(serviceSupplies.GetSupply(Convert.ToInt32(id)),
                                                   serviceProducts.GetProducts(), serviceProviders.GetProviders());

            if (supplyEdit == null)
            {
                return(HttpNotFound());
            }
            return(View(supplyEdit));
        }
Exemplo n.º 3
0
        public bool UpdateSupply(SupplyEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx
                             .Items
                             .Single(e => e.SupplyId == model.SupplyId && e.OwnerId == _ownerId);

                entity.SupplyName = model.SupplyName;
                entity.Brand      = model.Brand;
                entity.Color      = model.Color;
                entity.Quantity   = model.Quantity;
                entity.TotalCost  = model.TotalCost;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit(int id)
        {
            var service = CreateSupplyService();
            var detail  = service.GetItemById(id);
            var model   =
                new SupplyEdit
            {
                SupplyId    = detail.SupplyId,
                SupplyName  = detail.SupplyName,
                Brand       = detail.Brand,
                Color       = detail.Color,
                Quantity    = detail.Quantity,
                TotalCost   = detail.TotalCost,
                AlreadyHave = detail.AlreadyHave
            };

            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult Edit(int id, SupplyEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.SupplyId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var service = CreateSupplyService();

            if (service.UpdateSupply(model))
            {
                TempData["SaveResult"] = ("Your supply was updated.");
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your supply could not be updated.");
            return(View(model));
        }
Exemplo n.º 6
0
        // GET: SupplyViews/Create
        public ActionResult Create()
        {
            SupplyEdit supplyEdit = new SupplyEdit(serviceProducts.GetProducts(), serviceProviders.GetProviders());

            return(View(supplyEdit));
        }