public async Task <IActionResult> Edit(int id, [Bind("ProductId,Name,Description,CategoryProductId,Manufacturer,Supplier,Price")] Product product) { if (id != product.ProductId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.ProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("CategoryId,Name")] Category category) { if (id != category.CategoryId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.CategoryId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Price, Quantity, ShippingPrice")] Products products) { if (id != products.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(products); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(products.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(products)); }
public async Task <IActionResult> Edit(int id, [Bind("YieldId,Yield,CostPerTray,ProductsId,DateIn,DateOut")] Yields yields) { if (id != yields.YieldId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(yields); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!YieldsExists(yields.YieldId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProductsId"] = new SelectList(_context.Products, "Id", "Id", yields.ProductsId); return(View(yields)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Business,DateIn,DateOut")] Visitors SowRatesL) { if (id != SowRatesL.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(SowRatesL); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SowRatesLExists(SowRatesL.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(SowRatesL)); }
public async void SoftDeleteProductAsync(Product product = null, int?id = null) { if (product != null) { product.Active = false; _context.Update(product); SaveAndUpdateContext(); return; } if (id == null || id <= 0) { return; } var productToChange = await _context.Products.FirstOrDefaultAsync(p => p.Id == id); if (productToChange != null) { productToChange.Active = false; _context.Update(productToChange); SaveAndUpdateContext(); } }
public async Task Update(Product product) { _context.Update(product); await _context.SaveChangesAsync(); }