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 Create_Successfully_Made() { //arrange int expected = 4; var mockRepository = new Mock <IInnerTrackRepository>(); var obj = new ProjectSourceTypeObj(); var user = "******"; mockRepository.Setup(m => m.CreateProjectSourceType(obj, user)).Returns(expected); var logic = new ProjectSourceTypeLogic(mockRepository.Object); //act var actual = logic.Create(obj, user); //assert Assert.AreEqual(expected, actual); }