ソースを参照

Janneke testing feedback

master
George Williams 5年前
コミット
b40e156529

+ 13
- 3
UnivateProperties_API/Containers/ProcessFlow/BidItemDisplay.cs ファイルの表示

@@ -1,4 +1,7 @@
1
-namespace UnivateProperties_API.Containers.ProcessFlow
1
+using System;
2
+using UnivateProperties_API.Model.ProcessFlow;
3
+
4
+namespace UnivateProperties_API.Containers.ProcessFlow
2 5
 {
3 6
     public class BidItemDisplay
4 7
     {
@@ -8,15 +11,22 @@
8 11
         public string ShortDescription { get; set; }
9 12
         public string Description { get; set; }
10 13
         public string Resort { get; set; }
11
-        public string Unit { get; set; }
12
-        public string Module { get; set; }
14
+        public string UnitNumber { get; set; }
15
+        public string WeekNumber { get; set; }
13 16
         public string StatusCode { get; set; }
14 17
         public string Status { get; set; }
15 18
         public decimal Price { get; set; }
16 19
         public decimal Offer { get; set; }
17 20
         public string MadeBy { get; set; }
21
+        public DateTime Date { get; set; }
18 22
         public string Comment { get; set; }
19 23
         public string DeclineReason { get; set; }
24
+        public decimal SellPrice { get; set; }
20 25
         #endregion 
21 26
     }
27
+
28
+    public class BidItemNew : BidItem
29
+    {
30
+        public int UserId { get; set; }
31
+    }
22 32
 }

+ 2
- 1
UnivateProperties_API/Containers/Timeshare/TimeshareSearchDisplay.cs ファイルの表示

@@ -6,7 +6,8 @@ namespace UnivateProperties_API.Containers.Timeshare
6 6
     {
7 7
         public string UserName { get; set; }
8 8
         public string Type { get; set; }
9
-        public DateTime Date { get; set; }
9
+        public string Date { get; set; }
10
+        public string Time { get; set; }
10 11
         public string Property { get; set; }
11 12
         public string Value { get; set; }
12 13
     }

+ 9
- 2
UnivateProperties_API/Controllers/ProcessFlow/BidController.cs ファイルの表示

@@ -39,12 +39,19 @@ namespace UnivateProperties_API.Controllers.ProcessFlow
39 39
             return new OkObjectResult(items);
40 40
         }
41 41
 
42
+        [HttpGet("GetBidDetails/{id}")]
43
+        public IActionResult GetBidDetail(int id)
44
+        {
45
+            var item = _Repo.GetDispaly(id);
46
+            return new OkObjectResult(item);
47
+        }
48
+
42 49
         [HttpPost]
43
-        public IActionResult Post([FromBody] BidItem item)
50
+        public IActionResult Post([FromBody] BidItemNew item)
44 51
         {
45 52
             using (var scope = new TransactionScope())
46 53
             {
47
-                _Repo.Insert(item);
54
+                _Repo.InsertNew(item);
48 55
                 scope.Complete();
49 56
                 return CreatedAtAction(nameof(Get), new { id = item.Id }, item);
50 57
             }

+ 12
- 1
UnivateProperties_API/Model/Properties/PropertyType.cs ファイルの表示

@@ -1,10 +1,21 @@
1
-namespace UnivateProperties_API.Model.Properties
1
+using System.ComponentModel.DataAnnotations.Schema;
2
+
3
+namespace UnivateProperties_API.Model.Properties
2 4
 {
3 5
     public class PropertyType : BaseEntity
4 6
     {
5 7
         #region Properties 
6 8
         public string Description { get; set; }
7 9
         public PropertyUsageType UsageType { get; set; }
10
+
11
+        [NotMapped]
12
+        public string PropertyUsageType
13
+        {
14
+            get
15
+            {
16
+                return UsageType.ToString();
17
+            }
18
+        }
8 19
         #endregion 
9 20
     }
10 21
 }

+ 10
- 0
UnivateProperties_API/Model/Properties/UserDefinedGroup.cs ファイルの表示

@@ -1,4 +1,5 @@
1 1
 using System.Collections.Generic;
2
+using System.ComponentModel.DataAnnotations.Schema;
2 3
 
3 4
 namespace UnivateProperties_API.Model.Properties
4 5
 {
@@ -10,6 +11,15 @@ namespace UnivateProperties_API.Model.Properties
10 11
         public int Rank { get; set; }
11 12
 
12 13
         public ICollection<UserDefinedField> Fields { get; set; }
14
+
15
+        [NotMapped]
16
+        public string PropertyUsageType
17
+        {
18
+            get
19
+            {
20
+                return UsageType.ToString();
21
+            }
22
+        }
13 23
         #endregion 
14 24
     }
15 25
 }

+ 2
- 1
UnivateProperties_API/Repository/Logging/SearchLogRepository.cs ファイルの表示

@@ -49,7 +49,8 @@ namespace UnivateProperties_API.Repository.Logging
49 49
             {
50 50
                 var searchObject = JsonConvert.DeserializeObject<SearchObject>(log.Search);
51 51
                 list.Add(new SearchDisplay() {
52
-                    Date = log.Created,
52
+                    Date = string.Format("{0:yyyy-MM-dd}", log.Created),
53
+                    Time = string.Format("{0:HH:mm:ss}", log.Created),
53 54
                     Type = log.Type,
54 55
                     UserName = searchObject.UserName,
55 56
                     Property = searchObject.Property,

+ 139
- 36
UnivateProperties_API/Repository/ProccessFlow/BidRepository.cs ファイルの表示

@@ -6,7 +6,6 @@ using UnivateProperties_API.Containers.ProcessFlow;
6 6
 using UnivateProperties_API.Context;
7 7
 using UnivateProperties_API.Helpers;
8 8
 using UnivateProperties_API.Model;
9
-using UnivateProperties_API.Model.Communication;
10 9
 using UnivateProperties_API.Model.ProcessFlow;
11 10
 using UnivateProperties_API.Repository.Communication;
12 11
 using UnivateProperties_API.Repository.Timeshare;
@@ -75,42 +74,8 @@ namespace UnivateProperties_API.Repository.ProccessFlow
75 74
             List<BidItemDisplay> list = new List<BidItemDisplay>();
76 75
             foreach (BidItem item in bids)
77 76
             {
78
-                BidItemDisplay bid = new BidItemDisplay()
79
-                {
80
-                    Id = item.Id,
81
-                    Offer = (decimal)item.Amount,
82
-                    Comment = item.Comment,
83
-                    DeclineReason = item.DeclinedReason
84
-                };
85
-
86
-                if (item.PropertyId != null)
87
-                {
88
-                    bid.Type = "Property";
89
-                    bid.ShortDescription = item.Property.ShortDescription;
90
-                    bid.Description = item.Property.Description;
91
-                    bid.Price = item.Property.Price;
92
-                }
93
-                if (item.TimeshareWeekId != null)
94
-                {
95
-                    bid.Type = "Timeshare";
96
-                    bid.ShortDescription = string.Format("{0} {1} {2}", item.TimeshareWeek.ResortCode, item.TimeshareWeek.WeekNumber, item.TimeshareWeek.UnitNumber);
97
-                    bid.Price = (decimal)item.TimeshareWeek.SellPrice;
98
-                    bid.Resort = item.TimeshareWeek.ResortName;
99
-                    bid.Unit = item.TimeshareWeek.UnitNumber;
100
-                    bid.Module = item.TimeshareWeek.Module;
101
-                }
102
-                if (item.Status != null)
103
-                {
104
-                    bid.StatusCode = item.Status.Code;
105
-                    bid.Status = string.Format("{0} - {1}", item.Status.Code, item.Status.Description);
106
-                }
107
-                if (item.BidMaker != null)
108
-                    bid.MadeBy = item.BidMaker.Name + " " + item.BidMaker.Surname;
109
-
110
-                bid.MadeBy = "Bob";
111
-
77
+                BidItemDisplay bid = BidItemDisplay(item);
112 78
                 list.Add(bid);
113
-
114 79
             }
115 80
             return list;
116 81
         }
@@ -158,6 +123,91 @@ namespace UnivateProperties_API.Repository.ProccessFlow
158 123
             }
159 124
         }
160 125
 
126
+        public void InsertNew(BidItemNew item)
127
+        {            
128
+            var week = _dbContext.Weeks.Include("Owner").Where(x => x.Id == item.TimeshareWeekId).FirstOrDefault();
129
+            var property = _dbContext.Properties.Include("Owner").Where(x => x.Id == item.PropertyId).FirstOrDefault();
130
+            BidItem bid = new BidItem();
131
+
132
+            foreach (string prop in bid.GetAllProperties())
133
+            {
134
+                if (prop != "Item" && prop != "Display")
135
+                    bid[prop] = item[prop];
136
+            }
137
+            
138
+            var status = _dbContext.Status.Where(x => x.Code == "E1").FirstOrDefault();
139
+            if (status != null)            
140
+                bid.StatusId = status.Id;
141
+
142
+            var individual = _dbContext.Individuals.Where(i => i.UserId == item.UserId).FirstOrDefault();
143
+            if (individual != null)
144
+                bid.BidMakerId = individual.Id;
145
+
146
+            if (!(bid.TimeshareWeek == null && week == null))
147
+            {
148
+                if (week == null && bid.TimeshareWeek != null)
149
+                {
150
+                    MyCommon.PostToConsoft(bid.TimeshareWeek);
151
+                    WeekRepository weekRepository = new WeekRepository(_dbContext);
152
+                    weekRepository.Insert(bid.TimeshareWeek);
153
+                }
154
+                
155
+                List<BaseEntity> list = new List<BaseEntity>() { bid, week, week.Owner };
156
+
157
+                if (bid.TimeshareWeekId != null)
158
+                {
159
+                    if (week != null)
160
+                    {
161
+                        TemplateRepository templateRepository = new TemplateRepository(_dbContext);
162
+                        var template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekOfferMade-Owner");
163
+                        if (template != null)
164
+                        {
165
+                            templateRepository.SendEmailTemplate(template, week.Owner, list);
166
+                        }
167
+                        template = _dbContext.Templates.FirstOrDefault(x => x.Name == "WeekOfferMade-User");
168
+                        if (template != null)
169
+                        {
170
+                            var bidMaker = _dbContext.Individuals.FirstOrDefault(x => x.Id == bid.BidMakerId);
171
+                            if (bidMaker != null)
172
+                            {
173
+                                templateRepository.SendEmailTemplate(template, bidMaker, list);
174
+                            }
175
+                        }
176
+                    }
177
+                }
178
+                                    
179
+                _dbContext.Add(bid);
180
+                Save();
181
+            }
182
+            else
183
+            {                
184
+                List<BaseEntity> list = new List<BaseEntity>() { bid, property, property.Owner };                    
185
+                if (bid.PropertyId != null)
186
+                {
187
+                    if (property != null)
188
+                    {
189
+                        TemplateRepository templateRepository = new TemplateRepository(_dbContext);
190
+                        var template = _dbContext.Templates.FirstOrDefault(x => x.Name == "PropertyOfferMade-Owner");
191
+                        if (template != null)
192
+                        {
193
+                            templateRepository.SendEmailTemplate(template, property.Owner, list);
194
+                        }
195
+                        template = _dbContext.Templates.FirstOrDefault(x => x.Name == "PropertyOfferMade-User");
196
+                        if (template != null)
197
+                        {
198
+                            if (individual != null)
199
+                            {
200
+                                templateRepository.SendEmailTemplate(template, individual, list);
201
+                            }
202
+                        }
203
+                    }
204
+                }
205
+                
206
+                _dbContext.Add(bid);
207
+                Save();
208
+            }
209
+        }
210
+
161 211
         public void Insert(IEnumerable<BidItem> items)
162 212
         {
163 213
             foreach (var item in items)
@@ -259,5 +309,58 @@ namespace UnivateProperties_API.Repository.ProccessFlow
259 309
             // Not sure if properties need it
260 310
             return 0;
261 311
         }
312
+
313
+        public BidItemDisplay GetDispaly(int id)
314
+        {
315
+            var bid = _dbContext.BidItems
316
+                .Include("Property")
317
+                .Include("TimeshareWeek")
318
+                .Include("BidMaker")
319
+                .Include("Status")
320
+                .Where(x => x.Id == id).FirstOrDefault();
321
+            return BidItemDisplay(bid);
322
+        }
323
+
324
+        private BidItemDisplay BidItemDisplay(BidItem item)
325
+        {
326
+            if (item == null)
327
+                return null;
328
+
329
+            BidItemDisplay bid = new BidItemDisplay()
330
+            {
331
+                Id = item.Id,
332
+                Offer = (decimal)item.Amount,
333
+                Comment = item.Comment,
334
+                DeclineReason = item.DeclinedReason
335
+            };
336
+
337
+            if (item.PropertyId != null)
338
+            {
339
+                bid.Type = "Property";
340
+                bid.ShortDescription = item.Property.ShortDescription;
341
+                bid.Description = item.Property.Description;
342
+                bid.Price = item.Property.Price;
343
+            }
344
+            if (item.TimeshareWeekId != null)
345
+            {
346
+                bid.Type = "Timeshare";
347
+                bid.ShortDescription = string.Format("{0} {1} {2}", item.TimeshareWeek.ResortCode, item.TimeshareWeek.WeekNumber, item.TimeshareWeek.UnitNumber);
348
+                bid.SellPrice = (decimal)item.TimeshareWeek.SellPrice;
349
+                bid.Resort = item.TimeshareWeek.ResortName;
350
+                bid.UnitNumber = item.TimeshareWeek.UnitNumber;
351
+                bid.WeekNumber = item.TimeshareWeek.Module;
352
+            }
353
+            if (item.Status != null)
354
+            {
355
+                bid.StatusCode = item.Status.Code;
356
+                bid.Status = string.Format("{0} - {1}", item.Status.Code, item.Status.Description);
357
+            }
358
+            if (item.BidMaker != null)
359
+                bid.MadeBy = (item.BidMaker.Name + " " + item.BidMaker.Surname).Trim();
360
+
361
+            bid.Date = item.Created;
362
+
363
+            return bid;
364
+        }
262 365
     }
263 366
 }

+ 2
- 0
UnivateProperties_API/Repository/ProccessFlow/IBidRepository.cs ファイルの表示

@@ -13,5 +13,7 @@ namespace UnivateProperties_API.Repository.ProccessFlow
13 13
         List<BidItemDisplay> GetMyBid(Func<BidItem, bool> where);
14 14
         BidItemDisplay AcceptBid(int id);
15 15
         BidItemDisplay DecineBid(BitItemDecline item);
16
+        void InsertNew(BidItemNew item);
17
+        BidItemDisplay GetDispaly(int id);
16 18
     }
17 19
 }

+ 4
- 0
UnivateProperties_API/Repository/Properties/PropertyRepository.cs ファイルの表示

@@ -372,6 +372,10 @@ namespace UnivateProperties_API.Repository.Properties
372 372
                 //Property ID search will override other searches. 
373 373
                 if (search.PropertyId > 0)
374 374
                 {
375
+                    obj.Property = "PropertyID";
376
+                    obj.Value = search.PropertyId.ToString();
377
+                    SaveLog(obj);
378
+
375 379
                     props = dBContext.Properties.Where(p => p.Id == search.PropertyId).ToList();
376 380
                     return GetDisplayDetails(props);
377 381
                 }

読み込み中…
キャンセル
保存