API
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

WeekDto.cs 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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(), split[0].Trim());
  19. UnitNumber = split[1].Trim();
  20. WeekNumber = split[2].Trim();
  21. var size = split[3].Trim();
  22. if(size.Length == 3 && !size.ToLower().StartsWith('s'))
  23. {
  24. int.TryParse(size.Substring(0, 1), out int temp);
  25. Bedrooms = temp;
  26. int.TryParse(size.Substring(2, 1), out temp);
  27. MaxSleep = temp;
  28. }
  29. bool currentYear = split[9].Trim() == "Y";
  30. LevyAmount = Convert.ToDouble(split[5].Trim());
  31. DateTime tempDate = MyCommon.GetDateFromString(currentYear ? split[6].Trim() : split[13].Trim());
  32. if(tempDate != DateTime.MinValue)
  33. {
  34. ArrivalDate = tempDate;
  35. }
  36. tempDate = MyCommon.GetDateFromString(currentYear ? split[7].Trim() : split[14].Trim());
  37. if(tempDate != DateTime.MinValue)
  38. {
  39. DepartureDate = tempDate;
  40. }
  41. Region = new RegionDto() { RegionCode = split[24].Trim() };
  42. IsTender = true;
  43. ReferedByAgent = false;
  44. }
  45. public WeekDto(TimeshareWeek week)
  46. {
  47. Id = week.Id;
  48. AgentAsRep = week.AgentAsRep;
  49. OtherResort = week.OtherResort;
  50. Agency = week.Agency?.AgencyName;
  51. Agent = $"{week.Agent?.Name} {week.Agent?.Surname}";
  52. Owner = $"{week.Owner?.Name} {week.Owner?.Surname}";
  53. Resort = new ResortDto(week.ResortCode, week.ResortName);
  54. Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
  55. if(week.Status != null)
  56. {
  57. Status = new StatusDto(week.Status.Id, week.Status.Code, week.Status.Description);
  58. }
  59. Bedrooms = week.Bedrooms;
  60. MaxSleep = week.MaxSleep;
  61. UnitNumber = week.UnitNumber;
  62. WeekNumber = week.WeekNumber;
  63. LevyAmount = week.LevyAmount;
  64. CurrentYearBanked = week.CurrentYearBanked;
  65. ArrivalDate = week.ArrivalDate;
  66. DepartureDate = week.DepartureDate;
  67. SellPrice = week.SellPrice;
  68. IsTender = false;
  69. ReferedByAgent = week.ReferedByAgent;
  70. }
  71. public int Id { get; set; }
  72. public ResortDto Resort { get; set; }
  73. public RegionDto Region { get; set; }
  74. public StatusDto Status { get; set; }
  75. public string UnitNumber { get; set; }
  76. public string WeekNumber { get; set; }
  77. public string Agency { get; set; }
  78. public string Agent { get; set; }
  79. public string Owner { get; set; }
  80. public bool AgentAsRep { get; set; }
  81. public bool OtherResort { get; set; }
  82. public int Bedrooms { get; set; }
  83. public int MaxSleep { get; set; }
  84. public double LevyAmount { get; set; }
  85. public bool CurrentYearBanked { get; set; }
  86. public string BankedWith { get; set; }
  87. public DateTime ArrivalDate { get; set; }
  88. public DateTime DepartureDate { get; set; }
  89. public double SellPrice { get; set; }
  90. public bool IsTender { get; set; }
  91. public bool ReferedByAgent { get; set; }
  92. public string Display => $"{Resort.Display} ({ArrivalDate.ToShortDateString()} - {DepartureDate.ToShortDateString()})";
  93. }
  94. }