Beispiel #1
0
        public async Task <object> GetProperty(int id)
        {
            var property = await _propertyRepository.GetPerId(id);

            if (property == null)
            {
                _notifier.Handle(new Notification("Registro não encontrado.", ETypeError.NotFound));
                return(null);
            }

            property.Address = await _addressRepository.GetPerPropetyId(id);

            property.Detail = await _detailsRepository.GetPerPropetyId(id);

            property.Images = await _imageRepository.GetAllPerPropetyId(id);

            var propertyImages = await _imageRepository.GetAllPerPropetyId(property.Id);

            var returnedProperty = new
            {
                Codigo                    = property.Code,
                ValorCondominio           = property.CondominiumPrice,
                ValorAluguel              = property.RentPrice,
                Descricao                 = property.Description,
                NomeProprietario          = property.OwnerName,
                ValorIPTU                 = property.TaxPrice,
                Destaque                  = property.IsSpotlight,
                Tipo                      = (int)property.Type,
                Titulo                    = property.Title,
                ValorVenda                = property.SalePrice,
                TipoEspecificoPropriedade = property.SpecificType,
                Detalhe                   = new DetailsViewModel
                {
                    QuantidadeBanheiros = property.Detail.BathRoomQuantity,
                    QuantidadeQuartos   = property.Detail.BedRoomQuantity,
                    TamanhoDoLocal      = property.Detail.PropertySize,
                    VagasCarros         = property.Detail.CarVacancyQuantity
                },
                Endereco = new AddressViewModel
                {
                    Bairro    = property.Address.District,
                    Cep       = property.Address.Cep,
                    Cidade    = property.Address.City,
                    Estado    = property.Address.State,
                    NumeroRua = property.Address.LocationNumber,
                    Rua       = property.Address.Street
                },
                Imagens = from image in propertyImages
                          select new
                {
                    IdArquivo   = image.FileId,
                    NomeImagem  = image.Name,
                    TipoArquivo = image.FileType,
                }
            };

            return(returnedProperty);
        }