HotelModel.cs 824 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ПодготовкаКДемо1
  7. {
  8. public partial class Hotel
  9. {
  10. public string CountryName { get; set; }
  11. public string CountTour { get; set; }
  12. public static List<Hotel> GetHotels()
  13. {
  14. List<Hotel> hotels = BaseConnect.BaseModel.Hotel.ToList();
  15. foreach(Hotel hotel in hotels)
  16. {
  17. Country country = BaseConnect.BaseModel.Country.FirstOrDefault(x => x.Code == hotel.CountryCode);
  18. if (country != null)
  19. hotel.CountryName = country.Name;
  20. hotel.CountTour= hotel.Tour.Count().ToString();
  21. }
  22. return hotels;
  23. }
  24. }
  25. }