public HttpResponseMessage GetDetails([FromUri] SearchModelId model)
 {
     try
     {
         var result = _service.GetDetails(model);
         return(Request.CreateResponse(HttpStatusCode.OK, result));
     }
     catch (Exception e)
     {
         _logger.Error(e, "GetDetails");
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, e));
     }
 }
Beispiel #2
0
        public ResponseModel <HotelDetailsResponseDTO> GetDetails(SearchModelId id)
        {
            if (id == null)
            {
                return new ResponseModel <HotelDetailsResponseDTO>()
                       {
                           Code = ResultActionModelCode.NoData, Message = "No data"
                       }
            }
            ;

            using (var unity = _factory.GetUnitOfWork(UnitOfWorkContext.ReadOnly))
            {
                var room = _factory.GetUnitOfWork(UnitOfWorkContext.ReadOnly)
                           .GetRepository <Room>()
                           .AsQueryable()
                           .FirstOrDefault(x => x.Id == id.RoomId);

                var hotel = room.Hotel;


                HotelDetailsResponseDTO response = new HotelDetailsResponseDTO()
                {
                    Description       = hotel.Description,
                    HotelCity         = hotel.City,
                    HotelContactPhone = hotel.ContactPhone,
                    HotelCountry      = hotel.Country.Name,
                    HotelId           = hotel.Id,
                    HotelName         = hotel.Name,
                    HotelNumber       = hotel.HouseNumber,
                    Room = new RoomDetailsResponseDTO()
                    {
                        AdditionalInfo = room.AdditionalInfo,
                        Price          = room.Price,
                        RoomId         = room.Id,
                    }
                };
                return(ResponseModel <HotelDetailsResponseDTO> .OK(response));
            }
        }