public ActionResult Update([FromBody] RegionViewModel region) { var currentRes = _bo.Read(region.Id); if (!currentRes.Success) { return(StatusCode((int)HttpStatusCode.InternalServerError)); } var current = currentRes.Result; if (current == null) { return(NotFound()); } if (current.Name == region.Name) { return(StatusCode((int)HttpStatusCode.NotModified)); } if (current.Name != region.Name) { current.Name = region.Name; } var updateResult = _bo.Update(current); if (!updateResult.Success) { return(StatusCode((int)HttpStatusCode.InternalServerError)); } return(Ok()); }
public ActionResult Update([FromBody] RegionViewModel comp) { var currentResult = _bo.Read(comp.Id); if (!currentResult.Success) { return(InternalServerError()); } var current = currentResult.Result; if (current == null) { return(NotFound()); } if (current.Name == comp.Name) { return(NotModified()); } if (current.Name != comp.Name) { current.Name = comp.Name; } var updateResult = _bo.Update(current); if (!updateResult.Success) { return(InternalServerError()); } return(Ok()); }
public void TestUpdateSameNameRegion() { ContextSeeder.Seed(); var bo = new RegionBusinessObject(); var reg = new Region("another"); bo.Create(reg); reg.Name = "Covilhã"; var resUpdate = bo.Update(reg); Assert.IsTrue(resUpdate.Success); }
public void TestUpdateRegions() { ContextSeeder.Seed(); var bo = new RegionBusinessObject(); var resList = bo.List(); var item = resList.Result.FirstOrDefault(); item.Name = "another"; var resUpdate = bo.Update(item); var resNotList = bo.ListNotDeleted().Result; Assert.IsTrue(resUpdate.Success && resNotList.First().Name == "another"); }