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.

RegionDto.cs 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using UnivateProperties_API.Helpers;
  4. namespace UnivateProperties_API.Containers.Timeshare
  5. {
  6. public class RegionDto : IDisplay
  7. {
  8. int resortId;
  9. public RegionDto()
  10. {
  11. Resorts = new List<ResortDto>();
  12. }
  13. public RegionDto(string regionCode, string regionName)
  14. {
  15. RegionCode = regionCode;
  16. RegionName = regionName;
  17. Resorts = new List<ResortDto>();
  18. }
  19. public RegionDto(int id, string regionCode, string regionName)
  20. {
  21. Id = id;
  22. RegionCode = regionCode;
  23. RegionName = regionName;
  24. Resorts = new List<ResortDto>();
  25. }
  26. public int Id { get; set; }
  27. public string RegionName { get; set; }
  28. public string RegionCode { get; set; }
  29. public List<ResortDto> Resorts { get; set; }
  30. public int Available
  31. {
  32. get
  33. {
  34. return Resorts != null ? Resorts.Sum(x => x.Available) : 0;
  35. }
  36. }
  37. public string Display => RegionName;
  38. public void TryAddResort(string resortCode, string resortName)
  39. {
  40. if (!Resorts.Any(x => x.ResortCode == resortCode))
  41. {
  42. resortId = int.Parse(TenderWeeksHelper.GetResortId(resortName));
  43. Resorts.Add(new ResortDto(resortId, resortCode, resortName));
  44. }
  45. }
  46. public void OrderResorts()
  47. {
  48. if(Resorts != null && Resorts.Count > 0)
  49. {
  50. Resorts = Resorts.OrderBy(x => x.ResortName).ToList();
  51. }
  52. }
  53. }
  54. }