-
-
Save dcomartin/83e1f605f7e05e55314716dea15ab0f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost("/productCrud/{sku}")] | |
public async Task<IActionResult> UpdateProduct([FromRoute] string sku, [FromForm]CatalogProduct product) | |
{ | |
var record = await _catalogDbContext.Products.SingleOrDefaultAsync(x => x.Sku == sku); | |
if (product == null) | |
{ | |
return NotFound(); | |
} | |
record.Description = product.Description; | |
record.Name = product.Name; | |
record.Price = product.Price; | |
record.Cost = product.Cost; | |
record.QuantityOnHand = product.QuantityOnHand; | |
record.ForSale = product.Price > 0 && product.QuantityOnHand > 0 && product.ForSale; | |
record.FreeShipping = product.FreeShipping; | |
await _catalogDbContext.SaveChangesAsync(); | |
return RedirectToAction("GetProduct", new { sku = sku }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment