Example #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Amount,CreatedDate,Id")] Invoice invoice)
        {
            if (id != invoice.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(invoice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InvoiceExists(invoice.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(invoice));
        }
Example #2
0
        public async Task <IActionResult> Edit(Guid id, [Bind("CategoryId,Price,ImageLink,CreatedDate,Id")] Kit kit)
        {
            if (id != kit.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(kit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KitExists(kit.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", kit.CategoryId);
            return(View(kit));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Name,CreatedDate,Id")] Category category)
        {
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Database.ExecuteSqlInterpolated($"dbo.CategoryUpdate {category.Id},{category.Name}");
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Surname,Name,Phone,Passport,SecondName,Email,CreatedDate,Id")] Customer customer)
        {
            if (id != customer.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("KitId,OrderId,Quantity,CreatedDate,Id")] OrderItem orderItem)
        {
            if (id != orderItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orderItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderItemExists(orderItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["KitId"]   = new SelectList(_context.Kits, "Id", "Id", orderItem.KitId);
            ViewData["OrderId"] = new SelectList(_context.Orders, "Id", "Id", orderItem.OrderId);
            return(View(orderItem));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("KitId,Name,Value,CreatedDate,Id")] Description description)
        {
            if (id != description.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(description);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DescriptionExists(description.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["KitId"] = new SelectList(_context.Kits, "Id", "Id", description.KitId);
            return(View(description));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("InvoiceId,AccountId,Quantity,Status,CreatedDate,Id")] Order order)
        {
            if (id != order.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["AccountId"] = new SelectList(_context.Accounts, "Id", "Id", order.AccountId);
            // ViewData["InvoiceId"] = new SelectList(_context.Invoices, "Id", "Id", order.InvoiceId);
            return(View(order));
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("CustomerId,Amount,CardNumber,Currency,CreatedDate,Id")] Account account)
        {
            if (id != account.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(account);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountExists(account.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Customers, "Id", "Id", account.CustomerId);
            return(View(account));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Price,CategoryId")] Computer product,
                                               int amountInStock)
        {
            //if (id != product.Id)
            //{
            //    return NotFound();
            //}

            //StockItem stockItem = await _apiClient.ApiStockGetAsync(product.Id);

            if (ModelState.IsValid)
            {
                try
                {
                    //stockItem.AmountInStock = amountInStock;
                    //await _apiClient.ApiStockPutAsync(stockItem.Id, stockItem);

                    _context.Update(product);
                    _context.Entry(product).Property("Image").IsModified = false;
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { category = "Laptops" }));
            }


            ViewData["CategoryId"] = new SelectList(await _context.Category.ToListAsync(), "Id", "Name");
            //ViewData["AmountInStock"] = stockItem.AmountInStock;

            return(View(product));
        }