public async Task <IActionResult> PutProductBase(int id, ProductBase productBase) { if (id != productBase.PID) { return(BadRequest()); } _context.Entry(productBase).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductBaseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProduct([FromRoute] int id, [FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.ProductId) { return(BadRequest()); } db.Entry(product).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("CategoryId,Description")] Category category) { if (ModelState.IsValid) { db.Add(category); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Create([Bind("ProductId,Description,PurchaseDate,Price,Available,CategoryId")] Product product) { if (ModelState.IsValid) { db.Add(product); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(db.Category, "CategoryId", "Description", product.CategoryId); return(View(product)); }