public async Task <IActionResult> Edit(int id, [Bind("Id,ItemName,ItemPrice")] Gift gift)
        {
            if (id != gift.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gift);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GiftExists(gift.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(gift));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Charge")] ShippingMethod shippingMethod)
        {
            if (id != shippingMethod.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shippingMethod);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShippingMethodExists(shippingMethod.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(shippingMethod));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,GiftSenderId,GiftId,ShippingMethodId,Reciever,RecieverAddress")] GiftPurchase giftPurchase)
        {
            if (id != giftPurchase.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(giftPurchase);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GiftPurchaseExists(giftPurchase.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GiftId"]           = new SelectList(_context.Gift, "Id", "Id", giftPurchase.GiftId);
            ViewData["GiftSenderId"]     = new SelectList(_context.Set <GiftSender>(), "Id", "Id", giftPurchase.GiftSenderId);
            ViewData["ShippingMethodId"] = new SelectList(_context.Set <ShippingMethod>(), "Id", "Id", giftPurchase.ShippingMethodId);
            return(View(giftPurchase));
        }