Beispiel #1
0
        public PropertiesViewModel Build(PropertiesQuery query)
        {
            //var properties = _context.Properties
            //    .Where(p => p.IsListedForSale);

            var properties = _context.CompletePropertiesDetails().Where(p => p.IsListedForSale);


            if (!string.IsNullOrWhiteSpace(query.Search))
            {
                properties = properties.Where(x => x.StreetName.Contains(query.Search) ||
                                              x.Description.Contains(query.Search));
            }

            return(new PropertiesViewModel
            {
                Properties = properties
                             .ToList()
                             .Select(d => MapViewModel(d, _userId))
                             .ToList(),
                Search = query.Search
            });
        }