public ActionResult Edit(EditProjectSourceTypeModel model) { if (!ModelState.IsValid) { return(Redirect(Url.ProjectSourceType_Edit(model.Id))); } ProjectSourceTypeObj obj; if (!model.Id.HasValue) { obj = ModelConverter.Convert(model); obj.Id = ProjectSourceTypeLogic.Create(obj, CurrentUserName); if (obj.Id == -1) { this.AddError("CreatingProjectSourceType", "There was an error creating your ProjectSourceType. If this continues contact support."); return(Redirect(Url.ProjectSourceType_Create())); } } else { obj = ModelConverter.Convert(model); var success = ProjectSourceTypeLogic.Update(obj, CurrentUserName); if (!success) { this.AddError("UpdatingProjectSourceType", "There was an error updating your ProjectSourceType. If this continues contact support."); return(Redirect(Url.ProjectSourceType_Edit(model.Id.Value))); } } return(Redirect(Url.ProjectSourceType_Show(obj.Id.Value))); }
public void Update_Id_Found() { //arrange bool expected = true; var mockRepository = new Mock <IInnerTrackRepository>(); var updatedObj = new ProjectSourceTypeObj { Id = 2 }; var user = "******"; mockRepository.Setup(m => m.UpdateProjectSourceType(updatedObj, user)).Returns(expected); var logic = new ProjectSourceTypeLogic(mockRepository.Object); //act var actual = logic.Update(updatedObj, user); //assert Assert.AreEqual(expected, actual); }