浏览代码

Change to weekDTO & added bankscontroller

master
George Williams 4 年前
父节点
当前提交
1308c094c8

+ 32
- 0
UnivateProperties_API/Containers/Timeshare/WeekDto.cs 查看文件

@@ -21,6 +21,36 @@ namespace UnivateProperties_API.Containers.Timeshare
21 21
             Resort = new ResortDto(split[0].Trim(), split[0].Trim());
22 22
             UnitNumber = split[1].Trim();
23 23
             WeekNumber = split[2].Trim();
24
+            switch (split[8].Trim())
25
+            {
26
+                case "R":
27
+                    Season = "Red";
28
+                    break;
29
+                case "W":
30
+                    Season = "White";
31
+                    break;
32
+                case "B":
33
+                    Season = "Blue";
34
+                    break;
35
+                case "1":
36
+                    Season = "Peak 1";
37
+                    break;
38
+                case "2":
39
+                    Season = "Peak 2";
40
+                    break;
41
+                case "3":
42
+                    Season = "Peak 3";
43
+                    break;
44
+                case "4":
45
+                    Season = "Peak 4";
46
+                    break;
47
+                case "5":
48
+                    Season = "Peak 5";
49
+                    break;
50
+                default:
51
+                    Season = split[8].Trim();
52
+                    break;
53
+            }            
24 54
             var size = split[3].Trim();
25 55
             if(size.Length == 3 && !size.ToLower().StartsWith('s'))
26 56
             {
@@ -56,6 +86,7 @@ namespace UnivateProperties_API.Containers.Timeshare
56 86
             Owner = $"{week.Owner?.Name} {week.Owner?.Surname}";
57 87
             Resort = new ResortDto(week.ResortCode, week.ResortName);
58 88
             Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
89
+            Season = week.Season;
59 90
             if(week.Status != null)
60 91
             {
61 92
                 Status = new StatusDto(week.Status.Id, week.Status.Code, week.Status.Description);
@@ -79,6 +110,7 @@ namespace UnivateProperties_API.Containers.Timeshare
79 110
         public StatusDto Status { get; set; }
80 111
         public string UnitNumber { get; set; }
81 112
         public string WeekNumber { get; set; }
113
+        public string Season { get; set; }
82 114
         public string Agency { get; set; }
83 115
         public string Agent { get; set; }
84 116
         public string Owner { get; set; }

+ 27
- 0
UnivateProperties_API/Controllers/Banks/BanksController.cs 查看文件

@@ -0,0 +1,27 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Mvc;
6
+using UnivateProperties_API.Repository.Banks;
7
+
8
+namespace UnivateProperties_API.Controllers.Banks
9
+{
10
+    [Route("api/[controller]")]
11
+    [ApiController]
12
+    public class BanksController : ControllerBase
13
+    {
14
+        private readonly IBankRepository _repo;
15
+
16
+        public BanksController(IBankRepository repo)
17
+        {
18
+            _repo = repo;
19
+        }
20
+        
21
+        [HttpGet]
22
+        public IActionResult Get()
23
+        {
24
+            return new OkObjectResult(_repo.GetBanks());
25
+        }       
26
+    }
27
+}

+ 8
- 1
UnivateProperties_API/Controllers/Users/AgentController.cs 查看文件

@@ -1,4 +1,5 @@
1
-using System.Transactions;
1
+using System.Linq;
2
+using System.Transactions;
2 3
 using Microsoft.AspNetCore.Mvc;
3 4
 using UnivateProperties_API.Containers.Users;
4 5
 using UnivateProperties_API.Helpers;
@@ -24,6 +25,12 @@ namespace User_API.Controllers
24 25
             return new OkObjectResult(_Repo.GetAll());
25 26
         }
26 27
 
28
+        [HttpGet("GetByAgency/{id}")]
29
+        public IActionResult GetByAgency(int id)
30
+        {
31
+            return new OkObjectResult(_Repo.Get(x => x.AgencyId == id).ToList());
32
+        }
33
+
27 34
         [HttpGet("{id}")]
28 35
         public IActionResult Get(int id)
29 36
         {

+ 30
- 0
UnivateProperties_API/Repository/Banks/IBankRepository.cs 查看文件

@@ -0,0 +1,30 @@
1
+using Microsoft.EntityFrameworkCore;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.Linq;
5
+using System.Threading.Tasks;
6
+using UnivateProperties_API.Context;
7
+using UnivateProperties_API.Model.Banks;
8
+
9
+namespace UnivateProperties_API.Repository.Banks
10
+{
11
+    public interface IBankRepository
12
+    {
13
+        List<Bank> GetBanks();
14
+    }
15
+
16
+    public class BankRepository : IBankRepository
17
+    {
18
+        private readonly DataContext dBContext;
19
+
20
+        public BankRepository(DataContext _dBContext)
21
+        {
22
+            dBContext = _dBContext;
23
+        }
24
+
25
+        public List<Bank> GetBanks()
26
+        {
27
+            return dBContext.Banks.ToList();
28
+        }
29
+    }
30
+}

+ 4
- 1
UnivateProperties_API/Startup.cs 查看文件

@@ -104,6 +104,9 @@ namespace UnivateProperties_API
104 104
                 options.AutomaticAuthentication = true;
105 105
             });
106 106
 
107
+            #region 
108
+            services.AddTransient<IBankRepository, BankRepository>();
109
+            #endregion
107 110
             #region ProcessFlow
108 111
             services.AddTransient<IBidRepository, BidRepository>();
109 112
             #endregion
@@ -155,7 +158,7 @@ namespace UnivateProperties_API
155 158
             #endregion
156 159
             #region Misc
157 160
             services.AddTransient<ICarouselRepository, CarouselRepository>();
158
-            services.AddTransient<IRepository<PlaceHolderFormat>, PlaceHolderFormatRepository>();
161
+            services.AddTransient<IRepository<PlaceHolderFormat>, PlaceHolderFormatRepository>();            
159 162
             #endregion
160 163
             #region Campaign 
161 164
             services.AddTransient<ICampaignRepository, CampaignRepository>();

正在加载...
取消
保存