Procházet zdrojové kódy

Change to weekDTO & added bankscontroller

master
George Williams před 4 roky
rodič
revize
1308c094c8

+ 32
- 0
UnivateProperties_API/Containers/Timeshare/WeekDto.cs Zobrazit soubor

21
             Resort = new ResortDto(split[0].Trim(), split[0].Trim());
21
             Resort = new ResortDto(split[0].Trim(), split[0].Trim());
22
             UnitNumber = split[1].Trim();
22
             UnitNumber = split[1].Trim();
23
             WeekNumber = split[2].Trim();
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
             var size = split[3].Trim();
54
             var size = split[3].Trim();
25
             if(size.Length == 3 && !size.ToLower().StartsWith('s'))
55
             if(size.Length == 3 && !size.ToLower().StartsWith('s'))
26
             {
56
             {
56
             Owner = $"{week.Owner?.Name} {week.Owner?.Surname}";
86
             Owner = $"{week.Owner?.Name} {week.Owner?.Surname}";
57
             Resort = new ResortDto(week.ResortCode, week.ResortName);
87
             Resort = new ResortDto(week.ResortCode, week.ResortName);
58
             Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
88
             Region = new RegionDto(week.Region != null ? week.Region.Id : 0, week.Region?.Code, week.Region?.Description);
89
+            Season = week.Season;
59
             if(week.Status != null)
90
             if(week.Status != null)
60
             {
91
             {
61
                 Status = new StatusDto(week.Status.Id, week.Status.Code, week.Status.Description);
92
                 Status = new StatusDto(week.Status.Id, week.Status.Code, week.Status.Description);
79
         public StatusDto Status { get; set; }
110
         public StatusDto Status { get; set; }
80
         public string UnitNumber { get; set; }
111
         public string UnitNumber { get; set; }
81
         public string WeekNumber { get; set; }
112
         public string WeekNumber { get; set; }
113
+        public string Season { get; set; }
82
         public string Agency { get; set; }
114
         public string Agency { get; set; }
83
         public string Agent { get; set; }
115
         public string Agent { get; set; }
84
         public string Owner { get; set; }
116
         public string Owner { get; set; }

+ 27
- 0
UnivateProperties_API/Controllers/Banks/BanksController.cs Zobrazit soubor

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 Zobrazit soubor

1
-using System.Transactions;
1
+using System.Linq;
2
+using System.Transactions;
2
 using Microsoft.AspNetCore.Mvc;
3
 using Microsoft.AspNetCore.Mvc;
3
 using UnivateProperties_API.Containers.Users;
4
 using UnivateProperties_API.Containers.Users;
4
 using UnivateProperties_API.Helpers;
5
 using UnivateProperties_API.Helpers;
24
             return new OkObjectResult(_Repo.GetAll());
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
         [HttpGet("{id}")]
34
         [HttpGet("{id}")]
28
         public IActionResult Get(int id)
35
         public IActionResult Get(int id)
29
         {
36
         {

+ 30
- 0
UnivateProperties_API/Repository/Banks/IBankRepository.cs Zobrazit soubor

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 Zobrazit soubor

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

Načítá se…
Zrušit
Uložit