Пример #1
0
        public void DTOMapperEntitiesToDTOTest()
        {
            Location location1 = new Location()
            {
                Name       = "asdf",
                Address    = "zxvc",
                LocationID = 1
            };

            Location location2 = new Location()
            {
                Name       = "asdf",
                Address    = "zxvc",
                LocationID = 2
            };

            IEnumerable <Location> locations = new List <Location>()
            {
                location1, location2
            };

            var dtos = mapper.GetDTOsForEntities <Location, LocationDTO>(locations);

            AssertLocationDTO(location1, dtos.First());
            AssertLocationDTO(location2, dtos.Last());
        }
Пример #2
0
        public virtual HttpResponseMessage GetAll()
        {
            var serviceResponse = _service.GetAll();

            HttpResponseMessage controllerResponse = null;

            if (serviceResponse.Success)
            {
                controllerResponse = Request.CreateResponse(HttpStatusCode.OK, _mapper.GetDTOsForEntities <TEntity, TEntityDTO>(serviceResponse.Data));
            }
            else
            {
                controllerResponse = Request.CreateResponse(HttpStatusCode.InternalServerError, serviceResponse.Message);
            }

            return(controllerResponse);
        }