예제 #1
0
        private static IQueryable <RentalListingModel> GetAllRentalProperties(string sortOrder, bool isTenant)
        {
            var allRentalProperties = RentalService.GetRentalProperties(null, sortOrder).Select(x => new RentalListingModel
            {
                Id           = x.Id,
                PropertyId   = x.PropertyId,
                PropertyName = x.Property.Name,
                Title        = x.Title,
                Address      = new AddressViewModel
                {
                    AddressId = x.Property.Address.AddressId,
                    CountryId = x.Property.Address.CountryId,
                    Number    = x.Property?.Address?.Number?.Replace(" ", ""),
                    Street    = x.Property.Address?.Street?.Trim(),
                    Region    = x.Property.Address?.Region?.Trim(),
                    District  = x.Property.Address?.City?.Trim(),
                    Suburb    = x.Property.Address.Suburb?.Trim() ?? "",
                    PostCode  = x.Property.Address?.PostCode?.Replace(" ", ""),
                    Latitude  = x.Property.Address?.Lat,
                    Longitude = x.Property.Address?.Lng
                },
                PropertyAddress   = x.Property.Address.Number + " " + x.Property.Address.Street + ", " + x.Property.Address.Suburb + ", " + x.Property.Address.City + " - " + x.Property.Address.PostCode,
                PropertyType      = x.Property.PropertyType.Name,
                RentalPaymentType = x.Property.TargetRentType.Name,
                Bedrooms          = x.Property.Bedroom ?? 0,
                Bathrooms         = x.Property.Bathroom ?? 0,
                ParkingSpaces     = x.Property.ParkingSpace ?? 0,
                LandSqm           = x.Property.LandSqm ?? 0,
                FloorArea         = x.Property.FloorArea ?? 0,
                // PropertyDescription = x.Property.Description,
                RentalDescription = x.Description.Trim(),
                MovingCost        = x.MovingCost ?? 0,
                TargetRent        = x.TargetRent,
                RentType          = x.Property.TargetRentType.Name,
                AvailableDate     = x.AvailableDate,
                Furnishing        = x.Furnishing,
                IdealTenant       = x.IdealTenant,
                OccupantCount     = x.OccupantCount ?? 0,
                PetsAllowed       = x.PetsAllowed,
                CreatedBy         = x.CreatedBy,
                CreatedOn         = x.CreatedOn?.ToString("dd/MM/yyyy"),
                CreatedDate       = x.CreatedOn,
                UpdatedBy         = x.CreatedBy,
                IsTenant          = isTenant,
                UpdatedOn         = x.UpdatedOn?.ToString("dd/MM/yyyy"),
                RentalFiles       = x.RentalListingMedia.Select(y => new MediaModel {
                    NewFileName = y.NewFileName, OldFileName = y.OldFileName, Status = "load"
                }).ToList()
            }).ToList().AsQueryable();

            return(allRentalProperties);
        }