API
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

WeekDto.cs 7.1KB

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