public async Task <IActionResult> PutProductsOnVaultOrder(int id, ProductsOnVaultOrder productsOnVaultOrder)
        {
            if (id != productsOnVaultOrder.ProductsOnVaultOrderId)
            {
                return(BadRequest());
            }

            _context.Entry(productsOnVaultOrder).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductsOnVaultOrderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddToVaultOrder(int Id, [Bind("ProductId,Description,Ovation,Decoration,Legacy,Size,Price,ProductCode," +
                                                                        "AllowedToSelectId,UpChargeForLegacy,UpChargeAmount,ProductCategory," +
                                                                        "Color,Color1,Color2,Comments,PhotoImage,VaultOrderId")] Product product)
        {
            if (Id != 0)
            {
                // Find VaultOrder in VaultOrder table
                var VO = await _context.VaultOrder.FindAsync(Id);

                if (VO != null)
                {
                    var POVO = new ProductsOnVaultOrder();
                    POVO.VaultOrderId      = VO.VaultOrderId;
                    POVO.ProductCode       = product.ProductCode;
                    POVO.ProductCategory   = product.ProductCategory;
                    POVO.VenetianCarapace  = product.VenetianCarapace;
                    POVO.Description       = product.Description;
                    POVO.Size              = product.Size;
                    POVO.Price             = product.Price;
                    POVO.AllowedToSelectId = product.AllowedToSelectId;
                    POVO.UpChargeForLegacy = product.UpChargeForLegacy;
                    POVO.UpChargeAmount    = product.UpChargeAmount;
                    POVO.Legacy            = product.Legacy;
                    POVO.Decoration        = product.Decoration;
                    POVO.Ovation           = product.Ovation;
                    POVO.Color             = product.Color;
                    POVO.Color1            = product.Color1;
                    POVO.Color2            = product.Color2;
                    POVO.PhotoImage        = product.PhotoImage;

                    try
                    {
                        _context.ProductsOnVaultOrder.Add(POVO);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!ProductExists(product.ProductId))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
                return(RedirectToAction(nameof(Details), "VaultOrders", new { id = Id }));
            }
            return(View());
        }
        public async Task <ActionResult <ProductsOnVaultOrder> > PostProductsOnVaultOrder(ProductsOnVaultOrder productsOnVaultOrder)
        {
            _context.ProductsOnVaultOrder.Add(productsOnVaultOrder);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetProductsOnVaultOrder", new { id = productsOnVaultOrder.ProductsOnVaultOrderId }, productsOnVaultOrder));
        }