API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

WeekDto.cs 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. // F-Fixed T-Timeshare (Fixed Timeshare Week)
  75. //PML - Peak / Medium / Low Felxi
  76. switch (split[25].Trim())
  77. {
  78. case "T":
  79. case "F":
  80. WeekType = "Fixed";
  81. break;
  82. case "P":
  83. case "M":
  84. case "L":
  85. WeekType = "Peak Flexi";
  86. break;
  87. default:
  88. WeekType = "";
  89. break;
  90. }
  91. }
  92. public WeekDto(TimeshareWeek week)
  93. {
  94. Id = week.Id;
  95. AgentAsRep = week.AgentAsRep;
  96. OtherResort = week.OtherResort;
  97. Agency = week.Agency?.AgencyName;
  98. Agent = $"{week.Agent?.Name} {week.Agent?.Surname}";
  99. Owner = $"{week.Owner?.Name} {week.Owner?.Surname}";
  100. Resort = new ResortDto(week.ResortCode, week.ResortName);
  101. Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
  102. Season = week.Season;
  103. if(week.Status != null)
  104. {
  105. Status = new StatusDto(week.Status.Id, week.Status.Code, week.Status.Description);
  106. }
  107. Bedrooms = week.Bedrooms;
  108. MaxSleep = week.MaxSleep;
  109. UnitNumber = week.UnitNumber;
  110. WeekNumber = week.WeekNumber;
  111. LevyAmount = week.LevyAmount;
  112. CurrentYearBanked = week.CurrentYearBanked;
  113. ArrivalDate = week.ArrivalDate;
  114. DepartureDate = week.DepartureDate;
  115. SellPrice = week.SellPrice;
  116. IsTender = false;
  117. ReferedByAgent = week.ReferedByAgent;
  118. WeekType = week.WeekType.ToString();
  119. WeekStatus = week.WeekStatus;
  120. Publish = week.Publish;
  121. PulbishedDate = week.PulbishedDate;
  122. }
  123. public int Id { get; set; }
  124. public ResortDto Resort { get; set; }
  125. public RegionDto Region { get; set; }
  126. public StatusDto Status { get; set; }
  127. public string UnitNumber { get; set; }
  128. public string WeekNumber { get; set; }
  129. public string Season { get; set; }
  130. public string Agency { get; set; }
  131. public string Agent { get; set; }
  132. public string Owner { get; set; }
  133. public bool AgentAsRep { get; set; }
  134. public bool OtherResort { get; set; }
  135. public int Bedrooms { get; set; }
  136. public int MaxSleep { get; set; }
  137. public double LevyAmount { get; set; }
  138. public bool CurrentYearBanked { get; set; }
  139. public string BankedWith { get; set; }
  140. public DateTime ArrivalDate { get; set; }
  141. public DateTime DepartureDate { get; set; }
  142. public double SellPrice { get; set; }
  143. public bool IsTender { get; set; }
  144. public bool ReferedByAgent { get; set; }
  145. public string WeekType { get; set; }
  146. public string Display => $"{Resort.Display} ({ArrivalDate.ToShortDateString()} - {DepartureDate.ToShortDateString()})";
  147. public string WeekUni => $"{Resort.ResortCode}-{UnitNumber}-{WeekNumber}";
  148. public string WeekStatus { get; set; }
  149. public bool Publish { get; set; }
  150. public DateTime PulbishedDate { get; set; }
  151. }
  152. }