public IActionResult Index(string search, string searchC) { var PropertiesListViewModel = new PropertiesListViewModel(); int sea = Convert.ToInt32(search); int seaC = Convert.ToInt32(searchC); if (search != null) { if (searchC == null) { PropertiesListViewModel.Properties = _context.Properties.Where(p => p.CategoryId == sea); } else { PropertiesListViewModel.Properties = _context.Properties.Where(p => p.CategoryId == sea && p.CityId == seaC); } } else { if (searchC == null) { PropertiesListViewModel.Properties = _context.Properties; } else { PropertiesListViewModel.Properties = _context.Properties.Where(p => p.CityId == seaC); } } return(View(PropertiesListViewModel)); }
public IActionResult Search(string SearchTerm = "", int id = 1) { const int ItemsPerPage = 6; if (SearchTerm != "" && SearchTerm != null) { var viewModel = new PropertiesListViewModel { ItemsPerPage = ItemsPerPage, PageNumber = id, PropertiesCount = this.propertiesService.GetCount(), Properties = this.propertiesService.GetAllBySearch <VisualisePropertiesViewModel>(SearchTerm, id, ItemsPerPage), }; return(this.View(viewModel)); } else { var viewModel = new PropertiesListViewModel { ItemsPerPage = ItemsPerPage, PageNumber = id, PropertiesCount = this.propertiesService.GetCount(), Properties = this.propertiesService.GetAll <VisualisePropertiesViewModel>(id, ItemsPerPage), }; return(this.View(viewModel)); } }
public PropertiesListViewModel GetAllByUserId(string userId) { var properties = new PropertiesListViewModel { Properties = this.propertiesRepository .All() .Where(p => p.ApplicationUserId == userId) .OrderByDescending(p => p.CreatedOn) .Select(p => new PropertyInListViewModel { Name = p.Name, Stars = p.Stars, Country = p.Town.Country.Name, Town = p.Town.Name, PropertyCategory = p.PropertyCategory.Name, Id = p.Id, Image = p.PropertyImages.FirstOrDefault(pi => pi.PropertyId == p.Id) != null ? $"../..{GlobalConstants.PropertyImagesPath}{p.PropertyImages.FirstOrDefault(pi => pi.PropertyId == p.Id).Id}.{p.PropertyImages.FirstOrDefault(pi => pi.PropertyId == p.Id).Extension}" : p.Offers.Select(o => o.OfferImages.FirstOrDefault()).FirstOrDefault() != null ? $"../..{GlobalConstants.OfferImagesPath}{p.Offers.Select(o => o.OfferImages.FirstOrDefault()).FirstOrDefault().Id}.{p.Offers.Select(o => o.OfferImages.FirstOrDefault()).FirstOrDefault().Extension}" : $"../..{GlobalConstants.DefaultImagePath}", }) .ToList(), }; return(properties); }
public async Task <IActionResult> AllProperty() { var user = await _userManager.GetUserAsync(User); IEnumerable <Property> properties = _propertyRepository.Properties; var allProperty = new PropertiesListViewModel { Properties = properties }; return(View("MyProperty", allProperty)); }
//GET:Property/ public async Task <IActionResult> MyProperty() { var user = await _userManager.GetUserAsync(User); IEnumerable <Property> properties = _propertyRepository.Properties.Where(p => p.Customer == user) .OrderBy(p => p.PropertyId); var myProperty = new PropertiesListViewModel { Properties = properties }; return(View(myProperty)); }
public IActionResult SortByPriceDesc(int id = 1) { const int ItemsPerPage = 6; var viewModel = new PropertiesListViewModel { ItemsPerPage = ItemsPerPage, PageNumber = id, PropertiesCount = this.propertiesService.GetCount(), Properties = this.propertiesService.GetAll <VisualisePropertiesViewModel>(id, ItemsPerPage).OrderBy(x => x.Price), }; return(this.View(viewModel)); }
public IActionResult All(int id = 1) { try { const int ItemsPerPage = 12; var userId = this.HttpContext.User.Claims.First(c => c.Type.Contains("nameidentifier")).Value; var viewModel = new PropertiesListViewModel { ItemsPerPage = ItemsPerPage, PageNumber = id, Count = this.propertiesService.GetCount(), Properties = this.propertiesService.GetAll <PropertiesInListViewModel>(id, userId, 10), }; return(this.View(viewModel)); } catch (Exception ex) { return(this.View("Error", new ErrorViewModel { RequestId = ex.Message })); } }