public HttpResponseMessage UpdateProjectOwner(ProjectOwnerDTO projectOwner) { if (projectOwner != null) { DTOToEntity dte = new DTOToEntity(); var owner = dte.OwnerDTOToEntity(projectOwner); repo.AddProjectOwner(owner); return(Request.CreateResponse(HttpStatusCode.OK, "Owner Added Successfully.")); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "An Error Occured. Please check your details and try again.")); } }
public void OwnerDTOToEntityExistingValid() { ProjectOwnerController poc = new ProjectOwnerController(); DTOToEntity dte = new DTOToEntity(); ProjectOwnerDTO expected = new ProjectOwnerDTO { Id = 1, Project_Id = 1, Name = "Test", PhoneNumber = "00000 000000", AddressLine1 = "address 1", AddressLine2 = "address 2", Town = "town", County = "county", PostCode = "postcode" }; var actual = dte.OwnerDTOToEntity(expected); Assert.AreEqual(expected.Id, actual.Id); Assert.AreEqual(expected.Project_Id, actual.Project_Id); Assert.AreEqual(expected.Name, actual.Name); Assert.AreEqual(expected.PhoneNumber, actual.PhoneNumber); Assert.AreEqual(expected.AddressLine1, actual.AddressLine1); Assert.AreEqual(expected.AddressLine2, actual.AddressLine2); Assert.AreEqual(expected.Town, actual.Town); Assert.AreEqual(expected.County, actual.County); Assert.AreEqual(expected.PostCode, actual.PostCode); }