public ActionResult Edit(EditProjectSourceModel model) { if (!ModelState.IsValid) { return(Redirect(Url.ProjectSource_Edit(model.Id))); } ProjectSourceObj obj; if (!model.Id.HasValue) { obj = ModelConverter.Convert(model); obj.Id = ProjectSourceLogic.Create(obj, CurrentUserName); if (obj.Id == -1) { this.AddError("CreatingProjectSource", "There was an error creating your ProjectSource. If this continues contact support."); return(Redirect(Url.ProjectSource_Create())); } } else { obj = ModelConverter.Convert(model); var success = ProjectSourceLogic.Update(obj, CurrentUserName); if (!success) { this.AddError("UpdatingProjectSource", "There was an error updating your ProjectSource. If this continues contact support."); return(Redirect(Url.ProjectSource_Edit(model.Id.Value))); } } return(Redirect(Url.ProjectSource_Show(obj.Id.Value))); }
public void Update_Id_Found() { //arrange bool expected = true; var mockRepository = new Mock <IInnerTrackRepository>(); var updatedObj = new ProjectSourceObj { Id = 2 }; var user = "******"; mockRepository.Setup(m => m.UpdateProjectSource(updatedObj, user)).Returns(expected); var logic = new ProjectSourceLogic(mockRepository.Object); //act var actual = logic.Update(updatedObj, user); //assert Assert.AreEqual(expected, actual); }