Przeglądaj źródła

Janneke testing feedback

master
George Williams 5 lat temu
rodzic
commit
b40e156529

+ 13
- 3
UnivateProperties_API/Containers/ProcessFlow/BidItemDisplay.cs Wyświetl plik

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
     public class BidItemDisplay
6
     public class BidItemDisplay
4
     {
7
     {
8
         public string ShortDescription { get; set; }
11
         public string ShortDescription { get; set; }
9
         public string Description { get; set; }
12
         public string Description { get; set; }
10
         public string Resort { get; set; }
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
         public string StatusCode { get; set; }
16
         public string StatusCode { get; set; }
14
         public string Status { get; set; }
17
         public string Status { get; set; }
15
         public decimal Price { get; set; }
18
         public decimal Price { get; set; }
16
         public decimal Offer { get; set; }
19
         public decimal Offer { get; set; }
17
         public string MadeBy { get; set; }
20
         public string MadeBy { get; set; }
21
+        public DateTime Date { get; set; }
18
         public string Comment { get; set; }
22
         public string Comment { get; set; }
19
         public string DeclineReason { get; set; }
23
         public string DeclineReason { get; set; }
24
+        public decimal SellPrice { get; set; }
20
         #endregion 
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 Wyświetl plik

6
     {
6
     {
7
         public string UserName { get; set; }
7
         public string UserName { get; set; }
8
         public string Type { get; set; }
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
         public string Property { get; set; }
11
         public string Property { get; set; }
11
         public string Value { get; set; }
12
         public string Value { get; set; }
12
     }
13
     }

+ 9
- 2
UnivateProperties_API/Controllers/ProcessFlow/BidController.cs Wyświetl plik

39
             return new OkObjectResult(items);
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
         [HttpPost]
49
         [HttpPost]
43
-        public IActionResult Post([FromBody] BidItem item)
50
+        public IActionResult Post([FromBody] BidItemNew item)
44
         {
51
         {
45
             using (var scope = new TransactionScope())
52
             using (var scope = new TransactionScope())
46
             {
53
             {
47
-                _Repo.Insert(item);
54
+                _Repo.InsertNew(item);
48
                 scope.Complete();
55
                 scope.Complete();
49
                 return CreatedAtAction(nameof(Get), new { id = item.Id }, item);
56
                 return CreatedAtAction(nameof(Get), new { id = item.Id }, item);
50
             }
57
             }

+ 12
- 1
UnivateProperties_API/Model/Properties/PropertyType.cs Wyświetl plik

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

+ 10
- 0
UnivateProperties_API/Model/Properties/UserDefinedGroup.cs Wyświetl plik

1
 using System.Collections.Generic;
1
 using System.Collections.Generic;
2
+using System.ComponentModel.DataAnnotations.Schema;
2
 
3
 
3
 namespace UnivateProperties_API.Model.Properties
4
 namespace UnivateProperties_API.Model.Properties
4
 {
5
 {
10
         public int Rank { get; set; }
11
         public int Rank { get; set; }
11
 
12
 
12
         public ICollection<UserDefinedField> Fields { get; set; }
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
         #endregion 
23
         #endregion 
14
     }
24
     }
15
 }
25
 }

+ 2
- 1
UnivateProperties_API/Repository/Logging/SearchLogRepository.cs Wyświetl plik

49
             {
49
             {
50
                 var searchObject = JsonConvert.DeserializeObject<SearchObject>(log.Search);
50
                 var searchObject = JsonConvert.DeserializeObject<SearchObject>(log.Search);
51
                 list.Add(new SearchDisplay() {
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
                     Type = log.Type,
54
                     Type = log.Type,
54
                     UserName = searchObject.UserName,
55
                     UserName = searchObject.UserName,
55
                     Property = searchObject.Property,
56
                     Property = searchObject.Property,

+ 139
- 36
UnivateProperties_API/Repository/ProccessFlow/BidRepository.cs Wyświetl plik

6
 using UnivateProperties_API.Context;
6
 using UnivateProperties_API.Context;
7
 using UnivateProperties_API.Helpers;
7
 using UnivateProperties_API.Helpers;
8
 using UnivateProperties_API.Model;
8
 using UnivateProperties_API.Model;
9
-using UnivateProperties_API.Model.Communication;
10
 using UnivateProperties_API.Model.ProcessFlow;
9
 using UnivateProperties_API.Model.ProcessFlow;
11
 using UnivateProperties_API.Repository.Communication;
10
 using UnivateProperties_API.Repository.Communication;
12
 using UnivateProperties_API.Repository.Timeshare;
11
 using UnivateProperties_API.Repository.Timeshare;
75
             List<BidItemDisplay> list = new List<BidItemDisplay>();
74
             List<BidItemDisplay> list = new List<BidItemDisplay>();
76
             foreach (BidItem item in bids)
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
                 list.Add(bid);
78
                 list.Add(bid);
113
-
114
             }
79
             }
115
             return list;
80
             return list;
116
         }
81
         }
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
         public void Insert(IEnumerable<BidItem> items)
211
         public void Insert(IEnumerable<BidItem> items)
162
         {
212
         {
163
             foreach (var item in items)
213
             foreach (var item in items)
259
             // Not sure if properties need it
309
             // Not sure if properties need it
260
             return 0;
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 Wyświetl plik

13
         List<BidItemDisplay> GetMyBid(Func<BidItem, bool> where);
13
         List<BidItemDisplay> GetMyBid(Func<BidItem, bool> where);
14
         BidItemDisplay AcceptBid(int id);
14
         BidItemDisplay AcceptBid(int id);
15
         BidItemDisplay DecineBid(BitItemDecline item);
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 Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz