public IActionResult SpecificProperty(int rentalId) { PropertiesForRent propertyForRent = _db.PropertiesForRent.Where(p => p.RentalId == rentalId).FirstOrDefault(); Property property = _db.Property.Where(p => p.PropertiesForRent.First().RentalId == rentalId).FirstOrDefault(); RentalPropertyViewModel propertyViewModel = RentalPropertyMapper.MapPropertyToRentalPropertyVM(property); return(View(propertyViewModel)); }
public IActionResult Index() { List <PropertiesForRent> PropertiesForRent = _db.PropertiesForRent.ToList(); List <Property> Properties = _db.Property.Where(x => x.PropertiesForRent != null && x.PropertiesForRent.Count > 0).ToList(); RentalPropetiesViewModel propertiesViewModel = new RentalPropetiesViewModel { RentalProperties = new List <RentalPropertyViewModel>() }; foreach (Property property in Properties) { RentalPropertyViewModel propertyViewModel = RentalPropertyMapper.MapPropertyToRentalPropertyVM(property); propertiesViewModel.RentalProperties.Add(propertyViewModel); } return(View(propertiesViewModel)); }