public async Task <ActionResult> Put(long id, [FromBody] Supplier supplier) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else if (id != supplier.SupplierId) { return(BadRequest()); } db.Entry(supplier).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(NoContent()); }
public async Task <ActionResult> Put(long id, [FromBody] User user) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else if (id != user.UserId) { return(BadRequest()); } db.Entry(user).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (Exception ex) { return(NotFound()); } return(NoContent()); }
public async Task <ActionResult> Put(long id, [FromBody] PurchaseInformations purchaseInformations) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else if (id != purchaseInformations.PurchaseInformationsId) { return(BadRequest()); } db.Entry(purchaseInformations).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(NoContent()); }
public PersonViewModel Update(Person person) { context.Entry(person).State = EntityState.Modified; context.SaveChanges(); return(mapper.Map <PersonViewModel>(person)); }