소스 검색

Added Bank Repo

Added UnitNumber To Week
master
Kobus 5 년 전
부모
커밋
1a199f82e5

+ 1
- 1
UnivateProperties_API/Context/DataContext.cs 파일 보기

@@ -6,7 +6,7 @@ using UnivateProperties_API.Model.Region;
6 6
 using UnivateProperties_API.Model.Timeshare;
7 7
 using System.Linq;
8 8
 using UnivateProperties_API.Model;
9
-using UnivateProperties_API.Model.Bank;
9
+using UnivateProperties_API.Model.Banks;
10 10
 using UnivateProperties_API.Model.Misc;
11 11
 using UnivateProperties_API.Model.ProcessFlow;
12 12
 

UnivateProperties_API/Model/Bank/Bank.cs → UnivateProperties_API/Model/Banks/Bank.cs 파일 보기

@@ -1,4 +1,4 @@
1
-namespace UnivateProperties_API.Model.Bank
1
+namespace UnivateProperties_API.Model.Banks
2 2
 {
3 3
     public class Bank : BaseEntity
4 4
     {

UnivateProperties_API/Model/Bank/BankAccount.cs → UnivateProperties_API/Model/Banks/BankAccount.cs 파일 보기

@@ -1,6 +1,6 @@
1 1
 using UnivateProperties_API.Model.Users;
2 2
 
3
-namespace UnivateProperties_API.Model.Bank
3
+namespace UnivateProperties_API.Model.Banks
4 4
 {
5 5
     public class BankAccount : BaseEntity
6 6
     {

+ 1
- 0
UnivateProperties_API/Model/Timeshare/TimeshareWeek.cs 파일 보기

@@ -28,6 +28,7 @@ namespace UnivateProperties_API.Model.Timeshare
28 28
         public string Module { get; set; }
29 29
         public int Bedrooms { get; set; }
30 30
         public int MaxSleep { get; set; }
31
+        public string UnitNumber { get; set; }
31 32
         public string WeekNumber { get; set; }
32 33
         public double LevyAmount { get; set; }
33 34
 

+ 150
- 0
UnivateProperties_API/Repository/Banks/BankAccountRepository.cs 파일 보기

@@ -0,0 +1,150 @@
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 class BankAccountRepository : IRepository<Bank>, IRepository<BankAccount>
12
+    {
13
+        private readonly DataContext _dbContext;
14
+
15
+        public BankAccountRepository(DataContext dbContext)
16
+        {
17
+            _dbContext = dbContext;
18
+        }
19
+
20
+        public List<Bank> Get(Func<Bank, bool> where)
21
+        {
22
+            return _dbContext.Banks.Where(where).ToList();
23
+        }
24
+
25
+        public List<BankAccount> Get(Func<BankAccount, bool> where)
26
+        {
27
+            return _dbContext.BankAccounts.Where(where).ToList();
28
+        }
29
+
30
+        public List<Bank> GetAll()
31
+        {
32
+            return _dbContext.Banks.ToList();
33
+        }
34
+
35
+        public Bank GetDetailed(Func<Bank, bool> first)
36
+        {
37
+            var item = _dbContext.Banks.FirstOrDefault(first);
38
+            return item;
39
+        }
40
+
41
+        public BankAccount GetDetailed(Func<BankAccount, bool> first)
42
+        {
43
+            var item = _dbContext.BankAccounts.FirstOrDefault(first);
44
+            return item;
45
+        }
46
+
47
+        public List<Bank> GetDetailedAll()
48
+        {
49
+            return GetAll();
50
+        }
51
+
52
+        public void Insert(Bank item)
53
+        {
54
+            _dbContext.Add(item);
55
+            Save();
56
+        }
57
+
58
+        public void Insert(IEnumerable<Bank> items)
59
+        {
60
+            foreach (var item in items)
61
+            {
62
+                _dbContext.Add(item);
63
+            }
64
+            Save();
65
+        }
66
+
67
+        public void Insert(BankAccount item)
68
+        {
69
+            _dbContext.Add(item);
70
+            Save();
71
+        }
72
+
73
+        public void Insert(IEnumerable<BankAccount> items)
74
+        {
75
+            foreach (var item in items)
76
+            {
77
+                _dbContext.Add(item);
78
+            }
79
+            Save();
80
+        }
81
+
82
+        public void Remove(Bank item)
83
+        {
84
+            var i = _dbContext.Banks.Find(item);
85
+            _dbContext.Banks.Remove(i);
86
+            Save();
87
+        }
88
+
89
+        public void Remove(IEnumerable<Bank> items)
90
+        {
91
+            foreach (var item in items)
92
+            {
93
+                var i = _dbContext.Banks.Find(item);
94
+                _dbContext.Banks.Remove(i);
95
+            }
96
+            Save();
97
+        }
98
+
99
+        public void Remove(BankAccount item)
100
+        {
101
+            var i = _dbContext.BankAccounts.Find(item);
102
+            _dbContext.BankAccounts.Remove(i);
103
+            Save();
104
+        }
105
+
106
+        public void Remove(IEnumerable<BankAccount> items)
107
+        {
108
+            foreach (var item in items)
109
+            {
110
+                var i = _dbContext.BankAccounts.Find(item);
111
+                _dbContext.BankAccounts.Remove(i);
112
+            }
113
+            Save();
114
+        }
115
+
116
+        public void RemoveAtId(int item)
117
+        {
118
+            var i = _dbContext.Seasons.Find(item);
119
+            _dbContext.Seasons.Remove(i);
120
+            Save();
121
+        }
122
+
123
+        public void Save()
124
+        {
125
+            _dbContext.SaveChanges();
126
+        }
127
+
128
+        public void Update(Bank item)
129
+        {
130
+            _dbContext.Entry(item).State = EntityState.Modified;
131
+            Save();
132
+        }
133
+
134
+        public void Update(BankAccount item)
135
+        {
136
+            _dbContext.Entry(item).State = EntityState.Modified;
137
+            Save();
138
+        }
139
+
140
+        List<BankAccount> IRepository<BankAccount>.GetAll()
141
+        {
142
+            return _dbContext.BankAccounts.ToList();
143
+        }
144
+
145
+        List<BankAccount> IRepository<BankAccount>.GetDetailedAll()
146
+        {
147
+            return _dbContext.BankAccounts.ToList();
148
+        }
149
+    }
150
+}

+ 1
- 0
UnivateProperties_API/Startup.cs 파일 보기

@@ -110,6 +110,7 @@ namespace UnivateProperties_API
110 110
             services.AddTransient<IRepository<Season>, SeasonRepository>();
111 111
             services.AddTransient<IRepository<UnitConfiguration>, UnitConfigurationRepository>();
112 112
             services.AddTransient<IRepository<TimeshareWeek>, WeekRepository>();
113
+            services.AddTransient<IRepository<TimeshareWeek>, WeekRepository>();
113 114
             #endregion Timeshare
114 115
             #region User
115 116
             services.AddScoped<IRegisterRepository, RegisterRepository>();

+ 1
- 1
UnivateProperties_API/appsettings.json 파일 보기

@@ -9,6 +9,6 @@
9 9
   },
10 10
   "AllowedHosts": "*",
11 11
   "ConnectionStrings": {
12
-    "DefaultConnection": "Server=192.168.6.188;Port=5432;Database=Univate;User Id=postgres;Password=prov1s1on;"
12
+    "DefaultConnection": "Server=localhost;Port=5432;Database=Univate;User Id=postgres;Password=Prov1s1on;"
13 13
   }
14 14
 }

Loading…
취소
저장