public ActionResult Edit(EditProjectModel model) { if (!ModelState.IsValid) { return(Redirect(Url.Project_Edit(model.Id))); } ProjectObj project; if (!model.Id.HasValue) { project = ModelConverter.Convert(model); project.Id = ProjectLogic.Create(project, CurrentUserName); if (project.Id == -1) { this.AddError("CreatingProject", "There was an error creating your project. If this continues contact support."); return(Redirect(Url.Project_Create())); } } else { project = ModelConverter.Convert(model); var success = ProjectLogic.Update(project, CurrentUserName); if (!success) { this.AddError("UpdatingProject", "There was an error updating your project. If this continues contact support."); return(Redirect(Url.Project_Edit(model.Id.Value))); } } return(Redirect(Url.Project_Show(project.Id.Value))); }
public void Create_Successfully_Made() { //arrange int expected = 4; var mockRepository = new Mock <IInnerTrackRepository>(); var obj = new ProjectObj(); var user = "******"; mockRepository.Setup(m => m.CreateProject(obj, user)).Returns(expected); var logic = new ProjectLogic(mockRepository.Object); //act var actual = logic.Create(obj, user); //assert Assert.AreEqual(expected, actual); }