public IHttpActionResult Patch(CustomerViewModel model) { if (!model.id.HasValue || model.id.Value < 0) { return(BadRequest()); } var svc = new CustomerAppSvcGeneric(); var toUpdate = svc.Get(model.id.Value); if (toUpdate == null) { return(NotFound()); } try { toUpdate.Name = model.customerName; toUpdate.ContactName = model.contactName; var result = svc.Update(toUpdate); return(Ok(result)); } catch (Exception ex) { return(InternalServerError(ex)); } }
private bool DoUpdateCustomer(CustomerViewModel model) { var svc = new CustomerAppSvcGeneric(); var updated = svc.Update(model.GetEntity()); return(updated != null); }
public void UpdateTest() { var objCustomer = new Customer() { Id = 2, ContactName = "Florisvaldo" }; var svc = new CustomerAppSvcGeneric(); var customerUpdated = svc.Update(objCustomer); Assert.IsNotNull(customerUpdated); Assert.IsTrue(customerUpdated.Id > 0); }