public ActionResult EditTerritoryInternalPost(int id) { if (!_authorizer.Authorize(TerritoriesPermissions.ManageInternalTerritories)) { return(new HttpUnauthorizedResult()); } var tir = _territoryRepositoryService.GetTerritoryInternal(id); if (tir == null) { return(HttpNotFound()); } if (!TryUpdateModel(tir, _territoryIncludeProperties)) { _transactionManager.Cancel(); return(View(tir)); } try { _territoryRepositoryService.Update(tir); } catch (Exception ex) { AddModelError("", ex.Message); return(View(tir)); } return(View(tir)); }
public void UpdateHappensCorrectly() { PopulateTable(1); var tir = _territoryRepositoryService.GetTerritories().First(); tir.Name += "x"; var updated = _territoryRepositoryService.Update(tir); Assert.That(updated.Name, Is.EqualTo("Name0x")); Assert.That(updated.Id == tir.Id); var fromDb = _territoryRepositoryService.GetTerritoryInternal(1); Assert.That(fromDb.Id == updated.Id); Assert.That(fromDb.Name, Is.EqualTo("Name0x")); var updated2 = _territoryRepositoryService.Update(tir); //same name should not throw exception here. Assert.That(updated2.Name, Is.EqualTo("Name0x")); Assert.That(updated2.Id == tir.Id); }