private ApartmentModel GetApartmentModelById(int id)
        {
            ApartmentModel apartment = null;

            try
            {
                apartment = new ApartmentModel()
                {
                    Id            = _apartmentService.GetApartmentById(id).Id,
                    Name          = _apartmentService.GetApartmentById(id).Name,
                    Price         = _apartmentService.GetApartmentById(id).Price,
                    AvailableFrom = _apartmentService.GetApartmentById(id).AvailableFrom,
                    NumberOfBeds  = _apartmentService.GetApartmentById(id).NumberOfBeds,
                    AverageRating = float.Parse(_apartmentService.GetApartmentById(id).AverageRating.ToString("0.00")),
                    Phone         = _apartmentService.GetApartmentById(id).Phone,
                    Address       = _apartmentService.GetApartmentById(id).Address,
                    Description   = _apartmentService.GetApartmentById(id).Description
                };
                if (apartment.Description == null || apartment.Description.Length == 0)
                {
                    apartment.Description = "No description available...";
                }
            }
            catch (Exception ex)
            {
                _log.LogError(ex, ex.Message);
            }
            return(apartment);
        }
Example #2
0
 public IActionResult GetApartmentById(Guid id)
 {
     return(Ok(_apartmentService.GetApartmentById(id)));
 }