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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnivateProperties_API.Helpers;
  5. using UnivateProperties_API.Migrations;
  6. using UnivateProperties_API.Model.Timeshare;
  7. using UnivateProperties_API.Model.Users;
  8. namespace UnivateProperties_API.Containers.Timeshare
  9. {
  10. public class WeekDto : IDisplay
  11. {
  12. public WeekDto()
  13. {
  14. }
  15. public WeekDto(int id, string line)
  16. {
  17. Id = id;
  18. List<string> split = line.Split(",").ToList();
  19. AgentAsRep = false;
  20. Resort = new ResortDto(split[0].Trim(), TenderWeeksHelper.GetResortName(split[0].Trim()));
  21. UnitNumber = split[1].Trim();
  22. WeekNumber = split[2].Trim();
  23. switch (split[8].Trim())
  24. {
  25. case "R":
  26. Season = "Red";
  27. break;
  28. case "W":
  29. Season = "White";
  30. break;
  31. case "B":
  32. Season = "Blue";
  33. break;
  34. case "1":
  35. Season = "Peak 1";
  36. break;
  37. case "2":
  38. Season = "Peak 2";
  39. break;
  40. case "3":
  41. Season = "Peak 3";
  42. break;
  43. case "4":
  44. Season = "Peak 4";
  45. break;
  46. case "5":
  47. Season = "Peak 5";
  48. break;
  49. default:
  50. Season = split[8].Trim();
  51. break;
  52. }
  53. var size = split[3].Trim();
  54. if (size.Length == 3 && !size.ToLower().StartsWith('s'))
  55. {
  56. int.TryParse(size.Substring(0, 1), out int temp);
  57. Bedrooms = temp.ToString();
  58. int.TryParse(size.Substring(2, 1), out temp);
  59. MaxSleep = temp;
  60. }
  61. bool currentYear = split[9].Trim() == "Y";
  62. string amt = split[5].Trim();
  63. amt = amt.Replace('.', ',');
  64. if (double.TryParse(amt, out double dAmt))
  65. LevyAmount = dAmt;
  66. DateTime tempDate = MyCommon.GetDateFromString(currentYear ? split[6].Trim() : split[13].Trim());
  67. if (tempDate != DateTime.MinValue)
  68. {
  69. ArrivalDate = tempDate;
  70. }
  71. tempDate = MyCommon.GetDateFromString(currentYear ? split[7].Trim() : split[14].Trim());
  72. if (tempDate != DateTime.MinValue)
  73. {
  74. DepartureDate = tempDate;
  75. }
  76. Region = new RegionDto() { RegionCode = split[24].Trim() };
  77. IsTender = true;
  78. ReferedByAgent = false;
  79. // F-Fixed T-Timeshare (Fixed Timeshare Week)
  80. //PML - Peak / Medium / Low Felxi
  81. switch (split[25].Trim())
  82. {
  83. case "T":
  84. case "F":
  85. WeekType = "Fixed";
  86. break;
  87. case "P":
  88. case "M":
  89. case "L":
  90. WeekType = "Peak Flexi";
  91. break;
  92. default:
  93. WeekType = "";
  94. break;
  95. }
  96. }
  97. public WeekDto(TimeshareWeek week)
  98. {
  99. Id = week.Id;
  100. AgentAsRep = week.AgentAsRep;
  101. OtherResort = week.OtherResort;
  102. Agency = week.Agency?.AgencyName;
  103. AgencyId = week.AgencyId;
  104. Agent = $"{week.Agent?.Name} {week.Agent?.Surname}";
  105. AgentId = week.AgentId;
  106. Owner = week.DisplayOwner;
  107. OwnerId = week.Owner.Id;
  108. UserId = week.Owner.UserId;
  109. Resort = new ResortDto(week.ResortCode, week.ResortName);
  110. Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
  111. Season = week.Season;
  112. if (week.Status != null)
  113. {
  114. Status = new StatusDto(week.Status.Id, week.Status.Code, week.Status.Description);
  115. }
  116. Bedrooms = week.Bedrooms;
  117. MaxSleep = week.MaxSleep;
  118. UnitNumber = week.UnitNumber;
  119. WeekNumber = week.WeekNumber;
  120. Module = week.Module;
  121. LevyAmount = week.LevyAmount;
  122. CurrentYearBanked = week.CurrentYearBanked;
  123. ArrivalDate = week.ArrivalDate;
  124. DepartureDate = week.DepartureDate;
  125. SellPrice = week.SellPrice;
  126. IsTender = false;
  127. ReferedByAgent = week.ReferedByAgent;
  128. WeekType = week.WeekType.ToString();
  129. WeekStatus = week.WeekStatus;
  130. Publish = week.Publish;
  131. PulbishedDate = week.PulbishedDate;
  132. CustomOwner = week.CustomOwner;
  133. }
  134. public int Id { get; set; }
  135. public ResortDto Resort { get; set; }
  136. public RegionDto Region { get; set; }
  137. public StatusDto Status { get; set; }
  138. public string UnitNumber { get; set; }
  139. public string WeekNumber { get; set; }
  140. public string Season { get; set; }
  141. public string Agency { get; set; }
  142. public int? AgencyId { get; set; }
  143. public string Agent { get; set; }
  144. public int? AgentId { get; set; }
  145. public string Owner { get; set; }
  146. public int OwnerId { get; set; }
  147. public int? UserId { get; set; }
  148. public bool AgentAsRep { get; set; }
  149. public bool OtherResort { get; set; }
  150. public string Bedrooms { get; set; }
  151. public int MaxSleep { get; set; }
  152. public double LevyAmount { get; set; }
  153. public string Module { get; set; }
  154. public bool CurrentYearBanked { get; set; }
  155. public string BankedWith { get; set; }
  156. public DateTime ArrivalDate { get; set; }
  157. public DateTime DepartureDate { get; set; }
  158. public double SellPrice { get; set; }
  159. public bool IsTender { get; set; }
  160. public bool ReferedByAgent { get; set; }
  161. public string WeekType { get; set; }
  162. public string Display => $"{Resort.Display} ({ArrivalDate.ToShortDateString()} - {DepartureDate.ToShortDateString()})";
  163. public string WeekUni => $"{Resort.ResortCode}-{UnitNumber}-{WeekNumber}";
  164. public string WeekStatus { get; set; }
  165. public bool Publish { get; set; }
  166. public DateTime PulbishedDate { get; set; }
  167. public bool CustomOwner {get; set;}
  168. }
  169. }