PartialHotel.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using AvaloniaApplicationTest.ViewModels;
  2. using Microsoft.EntityFrameworkCore;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace AvaloniaApplicationTest.Models
  9. {
  10. public partial class Hotel
  11. {
  12. public String CountryName
  13. {
  14. get
  15. {
  16. foreach (var i in MainWindowViewModel.myConnection.Countries)
  17. {
  18. if (i.Code == CountryCode)
  19. return i.Name;
  20. }
  21. return "Отсутствует";
  22. }
  23. }
  24. public String Stars
  25. {
  26. get
  27. {
  28. switch (CountOfStars)
  29. {
  30. case 1:
  31. return "★☆☆☆☆";
  32. case 2:
  33. return "★★☆☆☆";
  34. case 3:
  35. return "★★★☆☆";
  36. case 4:
  37. return "★★★★☆";
  38. case 5:
  39. return "★★★★★";
  40. default:
  41. break;
  42. }
  43. return "☆☆☆☆☆";
  44. }
  45. }
  46. public int CountTours
  47. {
  48. get
  49. {
  50. int tours = MainWindowViewModel.myConnection.Tours.Include(x => x.Hotels).Where(x => x.Hotels.Where(x => x.Name == this.Name).Count() != 0).Count();
  51. return tours;
  52. }
  53. }
  54. }
  55. }