API
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WeekDto.cs 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnivateProperties_API.Helpers;
  5. using UnivateProperties_API.Model.Timeshare;
  6. namespace UnivateProperties_API.Containers.Timeshare
  7. {
  8. public class WeekDto : IDisplay
  9. {
  10. public WeekDto()
  11. {
  12. }
  13. public WeekDto(int id,string line)
  14. {
  15. Id = id;
  16. List<string> split = line.Split(",").ToList();
  17. AgentAsRep = false;
  18. Resort = new ResortDto(split[0].Trim(), TenderWeeksHelper.GetResortName(split[0].Trim()));
  19. UnitNumber = split[1].Trim();
  20. WeekNumber = split[2].Trim();
  21. switch (split[8].Trim())
  22. {
  23. case "R":
  24. Season = "Red";
  25. break;
  26. case "W":
  27. Season = "White";
  28. break;
  29. case "B":
  30. Season = "Blue";
  31. break;
  32. case "1":
  33. Season = "Peak 1";
  34. break;
  35. case "2":
  36. Season = "Peak 2";
  37. break;
  38. case "3":
  39. Season = "Peak 3";
  40. break;
  41. case "4":
  42. Season = "Peak 4";
  43. break;
  44. case "5":
  45. Season = "Peak 5";
  46. break;
  47. default:
  48. Season = split[8].Trim();
  49. break;
  50. }
  51. var size = split[3].Trim();
  52. if(size.Length == 3 && !size.ToLower().StartsWith('s'))
  53. {
  54. int.TryParse(size.Substring(0, 1), out int temp);
  55. Bedrooms = temp;
  56. int.TryParse(size.Substring(2, 1), out temp);
  57. MaxSleep = temp;
  58. }
  59. bool currentYear = split[9].Trim() == "Y";
  60. LevyAmount = Convert.ToDouble(split[5].Trim());
  61. DateTime tempDate = MyCommon.GetDateFromString(currentYear ? split[6].Trim() : split[13].Trim());
  62. if(tempDate != DateTime.MinValue)
  63. {
  64. ArrivalDate = tempDate;
  65. }
  66. tempDate = MyCommon.GetDateFromString(currentYear ? split[7].Trim() : split[14].Trim());
  67. if(tempDate != DateTime.MinValue)
  68. {
  69. DepartureDate = tempDate;
  70. }
  71. Region = new RegionDto() { RegionCode = split[24].Trim() };
  72. IsTender = true;
  73. ReferedByAgent = false;
  74. }
  75. public WeekDto(TimeshareWeek week)
  76. {
  77. Id = week.Id;
  78. AgentAsRep = week.AgentAsRep;
  79. OtherResort = week.OtherResort;
  80. Agency = week.Agency?.AgencyName;
  81. Agent = $"{week.Agent?.Name} {week.Agent?.Surname}";
  82. Owner = $"{week.Owner?.Name} {week.Owner?.Surname}";
  83. Resort = new ResortDto(week.ResortCode, week.ResortName);
  84. Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
  85. Season = week.Season;
  86. if(week.Status != null)
  87. {
  88. Status = new StatusDto(week.Status.Id, week.Status.Code, week.Status.Description);
  89. }
  90. Bedrooms = week.Bedrooms;
  91. MaxSleep = week.MaxSleep;
  92. UnitNumber = week.UnitNumber;
  93. WeekNumber = week.WeekNumber;
  94. LevyAmount = week.LevyAmount;
  95. CurrentYearBanked = week.CurrentYearBanked;
  96. ArrivalDate = week.ArrivalDate;
  97. DepartureDate = week.DepartureDate;
  98. SellPrice = week.SellPrice;
  99. IsTender = false;
  100. ReferedByAgent = week.ReferedByAgent;
  101. }
  102. public int Id { get; set; }
  103. public ResortDto Resort { get; set; }
  104. public RegionDto Region { get; set; }
  105. public StatusDto Status { get; set; }
  106. public string UnitNumber { get; set; }
  107. public string WeekNumber { get; set; }
  108. public string Season { get; set; }
  109. public string Agency { get; set; }
  110. public string Agent { get; set; }
  111. public string Owner { get; set; }
  112. public bool AgentAsRep { get; set; }
  113. public bool OtherResort { get; set; }
  114. public int Bedrooms { get; set; }
  115. public int MaxSleep { get; set; }
  116. public double LevyAmount { get; set; }
  117. public bool CurrentYearBanked { get; set; }
  118. public string BankedWith { get; set; }
  119. public DateTime ArrivalDate { get; set; }
  120. public DateTime DepartureDate { get; set; }
  121. public double SellPrice { get; set; }
  122. public bool IsTender { get; set; }
  123. public bool ReferedByAgent { get; set; }
  124. public string Display => $"{Resort.Display} ({ArrivalDate.ToShortDateString()} - {DepartureDate.ToShortDateString()})";
  125. public string WeekUni => $"{Resort.ResortCode}-{UnitNumber}-{WeekNumber}";
  126. }
  127. }