API
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

WeekDto.cs 6.0KB

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