public async Task <IActionResult> PutStore(int id, Store store) { if (id != store.Id) { return(BadRequest()); } _context.Entry(store).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProduct(int id, Product product) { if (id != product.Id) { return(BadRequest()); } var price = Convert.ToDecimal(product.Price); var newProduct = new Product() { Id = product.Id, Name = product.Name, Price = price }; _context.Entry(newProduct).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutSale(int id, Sale sale) { if (id != sale.ProductId) { return(BadRequest()); } var date = Convert.ToDateTime(sale.DateSold); Sale newSale = new Sale() { Id = sale.Id, CustomerId = sale.CustomerId, ProductId = sale.ProductId, StoreId = sale.ProductId, DateSold = date }; _context.Entry(newSale).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SaleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }