public HttpResponseMessage UpdateProject([FromBody] ProjectDTO project) { if (project != null) { DTOToEntity dte = new DTOToEntity(); var updatedProject = dte.ProjectDTOToEntity(project); repo.UpdateProject(updatedProject); return(Request.CreateResponse(HttpStatusCode.OK, "Project Updated successfully.")); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "An error occured.")); } }
public void ProjectDTOToEntityExistingValid() { ProjectController pc = new ProjectController(); DTOToEntity dte = new DTOToEntity(); ProjectDTO expected = new ProjectDTO { Id = 1, Invoiced = false, ProjectName = "Test Project", ProjectDescription = "Test Description" }; var actual = dte.ProjectDTOToEntity(expected); Assert.AreNotEqual(expected.Id, actual.Id); Assert.AreEqual(expected.ProjectName, actual.ProjectName); Assert.AreEqual(expected.ProjectDescription, actual.ProjectDescription); Assert.AreEqual(expected.Invoiced, actual.Invoiced); }
public HttpResponseMessage AddNewProject([FromBody] ProjectDTO project) { if (project != null) { DTOToEntity dte = new DTOToEntity(); Project newProject = dte.ProjectDTOToEntity(project); repo.AddNewProject(newProject); return(Request.CreateResponse(HttpStatusCode.OK, "Project added successfully.")); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "The project contained no information. Please fill in the form and try again.")); } }