public void InsertEntity(Entity model) { //model.CreatedDate = DateTime.UtcNow; //model.ModifiedDate = DateTime.UtcNow; _dbContext.Entry(model).State = EntityState.Added; Save(); }
public async Task <IActionResult> PutWishlistItem(long id, WishlistItem wishlistItem) { if (id != wishlistItem.Id) { return(BadRequest()); } _context.Entry(wishlistItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WishlistItemExists(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.IdProduct) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }