コード例 #1
0
        public void ProjectEntityToDTOValid()
        {
            ProjectController pc = new ProjectController();

            EntityToDTO etd = new EntityToDTO();

            Project expected = new Project {
                Invoiced = false, ProjectName = "Test Project", ProjectDescription = "Test Description"
            };

            var actual = etd.ProjectEntityToDTO(expected);

            Assert.AreEqual(expected.ProjectName, actual.ProjectName);
            Assert.AreEqual(expected.ProjectDescription, actual.ProjectDescription);
            Assert.AreEqual(expected.Invoiced, actual.Invoiced);
        }
コード例 #2
0
        public HttpResponseMessage GetProjects()
        {
            var ProjectsList           = repo.GetProjects;
            List <ProjectDTO> projects = new List <ProjectDTO>();

            if (ProjectsList.Count() > 0)
            {
                EntityToDTO dte = new EntityToDTO();
                foreach (var p in ProjectsList)
                {
                    var dto = dte.ProjectEntityToDTO(p);
                    projects.Add(dto);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, projects));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "There are currently no projects."));
            }
        }