Browse Source

commit merge

master
Kobus 5 years ago
parent
commit
c4d4ec2d50

+ 2
- 1
UnivateProperties_API/Containers/Property/PropertyDisplay.cs View File

6
     {
6
     {
7
         #region Properties
7
         #region Properties
8
         public int Id { get; set; }
8
         public int Id { get; set; }
9
+        public string PropertyUsageType { get; set; }
9
         public string ShortDescription { get; set; }
10
         public string ShortDescription { get; set; }
10
         public bool IsSale { get; set; }
11
         public bool IsSale { get; set; }
11
         public string DisplayPrice { get; set; }
12
         public string DisplayPrice { get; set; }
29
         public string City { get; set; }
30
         public string City { get; set; }
30
         public string Suburb { get; set; }
31
         public string Suburb { get; set; }
31
         public string DisplayImage { get; set; }
32
         public string DisplayImage { get; set; }
32
-        public decimal Price { get; set; }
33
+        public decimal Price { get; set; }        
33
         public DateTime DateCreated { get; set; }
34
         public DateTime DateCreated { get; set; }
34
         #endregion 
35
         #endregion 
35
     }
36
     }

+ 2
- 0
UnivateProperties_API/Containers/Property/PropertySearch.cs View File

11
         public string Province { get; set; }
11
         public string Province { get; set; }
12
         public string City { get; set; }
12
         public string City { get; set; }
13
         public string Suburb { get; set; }
13
         public string Suburb { get; set; }
14
+        public decimal MinPrice { get; set; }
15
+        public decimal MaxPrice { get; set; }
14
         #endregion 
16
         #endregion 
15
     }
17
     }
16
 }
18
 }

+ 2
- 1
UnivateProperties_API/Containers/Timeshare/TimeshareSearch.cs View File

1
 namespace UnivateProperties_API.Containers.Timeshare
1
 namespace UnivateProperties_API.Containers.Timeshare
2
 {
2
 {
3
-    public class TimeshareSearch
3
+    public class SearchObject
4
     {
4
     {
5
         public string UserName { get; set; }
5
         public string UserName { get; set; }
6
+        public string Type { get; set; }
6
         public string Property { get; set; }
7
         public string Property { get; set; }
7
         public string Value { get; set; }
8
         public string Value { get; set; }
8
     }
9
     }

+ 2
- 1
UnivateProperties_API/Containers/Timeshare/TimeshareSearchDisplay.cs View File

2
 
2
 
3
 namespace UnivateProperties_API.Containers.Timeshare
3
 namespace UnivateProperties_API.Containers.Timeshare
4
 {
4
 {
5
-    public class TimeshareSearchDisplay
5
+    public class SearchDisplay
6
     {
6
     {
7
         public string UserName { get; set; }
7
         public string UserName { get; set; }
8
+        public string Type { get; set; }
8
         public DateTime Date { get; set; }
9
         public DateTime Date { get; set; }
9
         public string Property { get; set; }
10
         public string Property { get; set; }
10
         public string Value { get; set; }
11
         public string Value { get; set; }

+ 6
- 10
UnivateProperties_API/Controllers/Logging/SearchLogController.cs View File

17
         }
17
         }
18
       
18
       
19
 
19
 
20
-        [HttpGet("{type}")]
21
-        public IActionResult Get(string type)
22
-        {
23
-            if (type.ToUpper() == "PROPERTY")
24
-                return new OkObjectResult(_Repo.GetPropertySearches());
25
-            else if (type.ToUpper() == "TIMESHARE")
26
-                return new OkObjectResult(_Repo.GetTimeshareSearches());
27
-            else return NoContent();
20
+        [HttpGet]
21
+        public IActionResult Get()
22
+        {      
23
+            return new OkObjectResult(_Repo.GetSearches());
28
         }
24
         }
29
         
25
         
30
 
26
 
31
         [HttpPost]
27
         [HttpPost]
32
-        public IActionResult Post([FromBody] TimeshareSearch item)
28
+        public IActionResult Post([FromBody] SearchObject item)
33
         {
29
         {
34
             using (var scope = new TransactionScope())
30
             using (var scope = new TransactionScope())
35
             {
31
             {
36
-                _Repo.SaveTimeshareSearch(item);
32
+                _Repo.SaveSearch(item);
37
                 scope.Complete();
33
                 scope.Complete();
38
                 return new OkObjectResult(item);
34
                 return new OkObjectResult(item);
39
             }
35
             }

+ 6
- 4
UnivateProperties_API/Controllers/Properties/PropertyController.cs View File

78
         }
78
         }
79
         #endregion
79
         #endregion
80
 
80
 
81
-        [HttpPost("search")]
81
+        [HttpGet("search")]
82
         public IActionResult Search([FromBody] PropertySearch search)
82
         public IActionResult Search([FromBody] PropertySearch search)
83
         {
83
         {
84
             return new OkObjectResult(_Repo.GetDisplay(search));
84
             return new OkObjectResult(_Repo.GetDisplay(search));
85
         }
85
         }
86
 
86
 
87
         //Will need to come out. Post search not working......:(
87
         //Will need to come out. Post search not working......:(
88
-        [HttpGet("search/{userName}/{keyword}/{salesType}/{propertyUsageType}/{propertyType}/{province}/{city}/{suburb}")]
89
-        public IActionResult Search(string userName, string keyword, string salesType, string propertyUsageType, string propertyType, string province, string city, string suburb)
88
+        [HttpGet("search/{userName}/{keyword}/{salesType}/{propertyUsageType}/{propertyType}/{province}/{city}/{suburb}/{minPrice}/{maxPrice}")]
89
+        public IActionResult Search(string userName, string keyword, string salesType, string propertyUsageType, string propertyType, string province, string city, string suburb, decimal minPrice, decimal maxPrice)
90
         {
90
         {
91
             var search = new PropertySearch()
91
             var search = new PropertySearch()
92
             {
92
             {
97
                 PropertyType = propertyType,
97
                 PropertyType = propertyType,
98
                 Province = province,
98
                 Province = province,
99
                 City = city,
99
                 City = city,
100
-                Suburb = suburb
100
+                Suburb = suburb,
101
+                MinPrice = minPrice,
102
+                MaxPrice = maxPrice
101
             };
103
             };
102
 
104
 
103
             return new OkObjectResult(_Repo.GetDisplay(search));
105
             return new OkObjectResult(_Repo.GetDisplay(search));

+ 4
- 1
UnivateProperties_API/Controllers/Users/RegisterController.cs View File

40
             if (user == null)
40
             if (user == null)
41
                 return BadRequest(new { message = "Username or password is incorrect" });
41
                 return BadRequest(new { message = "Username or password is incorrect" });
42
 
42
 
43
+            var name = _Repo.UserDetails(user.Id);
44
+
43
             var tokenHandler = new JwtSecurityTokenHandler();
45
             var tokenHandler = new JwtSecurityTokenHandler();
44
             var key = Encoding.ASCII.GetBytes(_appSettings.Secret);
46
             var key = Encoding.ASCII.GetBytes(_appSettings.Secret);
45
             var tokenDescriptor = new SecurityTokenDescriptor
47
             var tokenDescriptor = new SecurityTokenDescriptor
59
             {
61
             {
60
                 user.Id,
62
                 user.Id,
61
                 user.Username,
63
                 user.Username,
62
-                Token = tokenString
64
+                Token = tokenString,
65
+                name
63
             });
66
             });
64
         }
67
         }
65
 
68
 

+ 1028
- 0
UnivateProperties_API/Migrations/20190912055827_SearchLogStuff.Designer.cs
File diff suppressed because it is too large
View File


+ 40
- 0
UnivateProperties_API/Migrations/20190912055827_SearchLogStuff.cs View File

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class SearchLogStuff : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.DropColumn(
10
+                name: "UserID",
11
+                table: "SearchLogs");
12
+
13
+            migrationBuilder.DropColumn(
14
+                name: "GCRecord",
15
+                table: "Properties");
16
+
17
+            migrationBuilder.AddColumn<string>(
18
+                name: "Type",
19
+                table: "SearchLogs",
20
+                nullable: true);
21
+        }
22
+
23
+        protected override void Down(MigrationBuilder migrationBuilder)
24
+        {
25
+            migrationBuilder.DropColumn(
26
+                name: "Type",
27
+                table: "SearchLogs");
28
+
29
+            migrationBuilder.AddColumn<int>(
30
+                name: "UserID",
31
+                table: "SearchLogs",
32
+                nullable: true);
33
+
34
+            migrationBuilder.AddColumn<int>(
35
+                name: "GCRecord",
36
+                table: "Properties",
37
+                nullable: true);
38
+        }
39
+    }
40
+}

+ 2
- 3
UnivateProperties_API/Repository/Logging/ISearchLogRepository.cs View File

7
 {
7
 {
8
     public interface ISearchLogRepository: IRepository<SearchLog>
8
     public interface ISearchLogRepository: IRepository<SearchLog>
9
     {
9
     {
10
-        List<TimeshareSearchDisplay> GetTimeshareSearches();
11
-        List<PropertySearchDispaly> GetPropertySearches();
12
-        void SaveTimeshareSearch(TimeshareSearch item);
10
+        List<SearchDisplay> GetSearches();        
11
+        void SaveSearch(SearchObject item);
13
     }
12
     }
14
 }
13
 }

+ 15
- 38
UnivateProperties_API/Repository/Logging/SearchLogRepository.cs View File

39
         public List<SearchLog> GetDetailedAll()
39
         public List<SearchLog> GetDetailedAll()
40
         {
40
         {
41
             return _dbContext.SearchLogs.ToList();
41
             return _dbContext.SearchLogs.ToList();
42
-        }
42
+        }        
43
 
43
 
44
-        public List<PropertySearchDispaly> GetPropertySearches()
44
+        public List<SearchDisplay> GetSearches()
45
         {
45
         {
46
-            var list = new List<PropertySearchDispaly>();
47
-            var logs = Get(x => x.Type == "Property");
46
+            var list = new List<SearchDisplay>();
47
+            var logs = GetAll();
48
             foreach (SearchLog log in logs)
48
             foreach (SearchLog log in logs)
49
             {
49
             {
50
-                var propSearch = JsonConvert.DeserializeObject<PropertySearch>(log.Search);
51
-                list.Add(new PropertySearchDispaly()
52
-                {
50
+                var searchObject = JsonConvert.DeserializeObject<SearchObject>(log.Search);
51
+                list.Add(new SearchDisplay() {
53
                     Date = log.Created,
52
                     Date = log.Created,
54
-                    UserName = propSearch.UserName,
55
-                    Keyword = propSearch.Keyword,
56
-                    SalesType = propSearch.SalesType,
57
-                    PropertyUsageType = propSearch.PropertyUsageType,
58
-                    PropertyType = propSearch.PropertyType,
59
-                    Province = propSearch.Province,
60
-                    City = propSearch.City,
61
-                    Suburb = propSearch.Suburb
62
-                });
63
-                Debug.WriteLine(propSearch);
64
-            }
65
-            return list;            
66
-        }
67
-
68
-        public List<TimeshareSearchDisplay> GetTimeshareSearches()
69
-        {
70
-            var list = new List<TimeshareSearchDisplay>();
71
-            var logs = Get(x => x.Type == "Timeshare");
72
-            foreach (SearchLog log in logs)
73
-            {
74
-                var timeshareSearch = JsonConvert.DeserializeObject<TimeshareSearch>(log.Search);
75
-                list.Add(new TimeshareSearchDisplay() {
76
-                    Date = log.Created,
77
-                    UserName = timeshareSearch.UserName,
78
-                    Property = timeshareSearch.Property,
79
-                    Value = timeshareSearch.Value
53
+                    Type = log.Type,
54
+                    UserName = searchObject.UserName,
55
+                    Property = searchObject.Property,
56
+                    Value = searchObject.Value
80
                 });
57
                 });
81
             }
58
             }
82
             return list;
59
             return list;
127
             _dbContext.SaveChanges();
104
             _dbContext.SaveChanges();
128
         }
105
         }
129
 
106
 
130
-        public void SaveTimeshareSearch(TimeshareSearch item)
131
-        {
107
+        public void SaveSearch(SearchObject item)
108
+        {            
132
             var searchLog = new SearchLog
109
             var searchLog = new SearchLog
133
-            {
134
-                Type = "Timeshare",
110
+            { 
111
+                Type = item.Type,
135
                 Search = JsonConvert.SerializeObject(item)
112
                 Search = JsonConvert.SerializeObject(item)
136
             };
113
             };
137
-            _dbContext.SearchLogs.Remove(searchLog);
114
+            _dbContext.SearchLogs.Add(searchLog);
138
             Save();
115
             Save();
139
         }
116
         }
140
 
117
 

+ 72
- 9
UnivateProperties_API/Repository/Properties/PropertyRepository.cs View File

4
 using System.Collections.Generic;
4
 using System.Collections.Generic;
5
 using System.Linq;
5
 using System.Linq;
6
 using UnivateProperties_API.Containers.Property;
6
 using UnivateProperties_API.Containers.Property;
7
+using UnivateProperties_API.Containers.Timeshare;
7
 using UnivateProperties_API.Context;
8
 using UnivateProperties_API.Context;
9
+using UnivateProperties_API.Model.Logging;
8
 using UnivateProperties_API.Model.Properties;
10
 using UnivateProperties_API.Model.Properties;
9
 
11
 
10
 namespace UnivateProperties_API.Repository.Properties
12
 namespace UnivateProperties_API.Repository.Properties
155
 
157
 
156
             if (images != null)
158
             if (images != null)
157
             {
159
             {
160
+                var lastID = (from p in dBContext.PropertyImages
161
+                              orderby p.Id descending
162
+                              select p.Id).FirstOrDefault();
163
+
158
                 foreach (PropertyImage image in images)
164
                 foreach (PropertyImage image in images)
159
                 {
165
                 {
166
+                    lastID++;
167
+                    image.Id = lastID;
160
                     image.PropertyId = item.Id;
168
                     image.PropertyId = item.Id;
161
                     dBContext.PropertyImages.Add(image);
169
                     dBContext.PropertyImages.Add(image);
162
                     Save();
170
                     Save();
241
 
249
 
242
             return GetDisplayDetails(props);
250
             return GetDisplayDetails(props);
243
         }
251
         }
244
-
252
+        
245
         public List<PropertyDisplay> GetDisplay(PropertySearch search)
253
         public List<PropertyDisplay> GetDisplay(PropertySearch search)
246
         {
254
         {
247
-            //Save to Log
248
-            dBContext.SearchLogs.Add(new Model.Logging.SearchLog()
255
+            SearchObject obj = new SearchObject()
249
             {
256
             {
250
-                Type = "Property",
251
-                Search = JsonConvert.SerializeObject(search)
252
-            });
253
-            Save();
257
+                UserName = search.UserName,
258
+                Type = "Property"
259
+            };
254
 
260
 
255
             if (!string.IsNullOrEmpty(search.Keyword) && search.Keyword.ToUpper() != "ALL")
261
             if (!string.IsNullOrEmpty(search.Keyword) && search.Keyword.ToUpper() != "ALL")
256
             {
262
             {
267
                                         || EF.Functions.Like(s.Description.ToLower(), $"%{keyword}%")
273
                                         || EF.Functions.Like(s.Description.ToLower(), $"%{keyword}%")
268
                                         || EF.Functions.Like(pt.Description.ToLower(), $"%{keyword}%")
274
                                         || EF.Functions.Like(pt.Description.ToLower(), $"%{keyword}%")
269
                                         select p).ToList();
275
                                         select p).ToList();
276
+                obj.Property = "Keyword";
277
+                obj.Value = search.Keyword;
278
+                SaveLog(obj);
270
 
279
 
271
                 return GetDisplayDetails(props);
280
                 return GetDisplayDetails(props);
272
             }
281
             }
275
                 List<Property> props;
284
                 List<Property> props;
276
                 PropertyUsageType uType = PropertyUsageType.Both;
285
                 PropertyUsageType uType = PropertyUsageType.Both;
277
 
286
 
278
-                if (!string.IsNullOrEmpty(search.PropertyUsageType) && search.PropertyUsageType != "undefined")
287
+                if (!string.IsNullOrEmpty(search.PropertyUsageType) && search.PropertyUsageType != "undefined" && search.PropertyUsageType.ToUpper() != "ALL")
279
                 {
288
                 {
280
                     if (search.PropertyUsageType.ToUpper() == "COMMERCIAL")
289
                     if (search.PropertyUsageType.ToUpper() == "COMMERCIAL")
281
                         uType = PropertyUsageType.Commercial;
290
                         uType = PropertyUsageType.Commercial;
287
                          where pt.UsageType == uType
296
                          where pt.UsageType == uType
288
                          select p).ToList();
297
                          select p).ToList();
289
 
298
 
299
+                obj.Property = "PropertyUsageType";
300
+                obj.Value = search.PropertyUsageType;
301
+                SaveLog(obj);
302
+
290
                 if (!string.IsNullOrEmpty(search.SalesType) && search.SalesType != "undefined" && search.SalesType.ToUpper() != "ALL")
303
                 if (!string.IsNullOrEmpty(search.SalesType) && search.SalesType != "undefined" && search.SalesType.ToUpper() != "ALL")
291
                 {
304
                 {
292
                     if (search.SalesType.ToUpper() == "SALE")
305
                     if (search.SalesType.ToUpper() == "SALE")
293
                         props = props.Where(p => p.IsSale).ToList();
306
                         props = props.Where(p => p.IsSale).ToList();
294
                     else
307
                     else
295
                         props = props.Where(p => !p.IsSale).ToList();
308
                         props = props.Where(p => !p.IsSale).ToList();
309
+
310
+                    obj.Property = "SalesType";
311
+                    obj.Value = search.SalesType;
312
+                    SaveLog(obj);
296
                 }
313
                 }
297
 
314
 
298
                 if (!string.IsNullOrEmpty(search.Province) && search.Province != "undefined" && search.Province.ToUpper() != "ALL")
315
                 if (!string.IsNullOrEmpty(search.Province) && search.Province != "undefined" && search.Province.ToUpper() != "ALL")
301
                              join pp in dBContext.Provinces on p.ProvinceId equals pp.Id
318
                              join pp in dBContext.Provinces on p.ProvinceId equals pp.Id
302
                              where pp.Description.ToUpper() == search.Province.ToUpper()
319
                              where pp.Description.ToUpper() == search.Province.ToUpper()
303
                              select p).ToList();
320
                              select p).ToList();
321
+
322
+                    obj.Property = "Province";
323
+                    obj.Value = search.Province;
324
+                    SaveLog(obj);
304
                 }
325
                 }
305
 
326
 
306
                 if (!string.IsNullOrEmpty(search.City) && search.City != "undefined" && search.City.ToUpper() != "ALL")
327
                 if (!string.IsNullOrEmpty(search.City) && search.City != "undefined" && search.City.ToUpper() != "ALL")
309
                              join c in dBContext.Cities on p.CityId equals c.Id
330
                              join c in dBContext.Cities on p.CityId equals c.Id
310
                              where c.Description.ToUpper() == search.City.ToUpper()
331
                              where c.Description.ToUpper() == search.City.ToUpper()
311
                              select p).ToList();
332
                              select p).ToList();
333
+
334
+                    obj.Property = "City";
335
+                    obj.Value = search.City;
336
+                    SaveLog(obj);
312
                 }
337
                 }
313
 
338
 
314
                 if (!string.IsNullOrEmpty(search.Suburb) && search.Suburb != "undefined" && search.Suburb.ToUpper() != "ALL")
339
                 if (!string.IsNullOrEmpty(search.Suburb) && search.Suburb != "undefined" && search.Suburb.ToUpper() != "ALL")
317
                              join s in dBContext.Suburbs on p.SuburbId equals s.Id
342
                              join s in dBContext.Suburbs on p.SuburbId equals s.Id
318
                              where s.Description.ToUpper() == search.Suburb.ToUpper()
343
                              where s.Description.ToUpper() == search.Suburb.ToUpper()
319
                              select p).ToList();
344
                              select p).ToList();
345
+
346
+                    obj.Property = "Suburb";
347
+                    obj.Value = search.Suburb;
348
+                    SaveLog(obj);
320
                 }
349
                 }
321
                 if (!string.IsNullOrEmpty(search.PropertyType) && search.PropertyType != "Undefined" && search.PropertyType.ToUpper() != "ALL")
350
                 if (!string.IsNullOrEmpty(search.PropertyType) && search.PropertyType != "Undefined" && search.PropertyType.ToUpper() != "ALL")
322
                 {
351
                 {
325
                     {
354
                     {
326
                         props = props.Where(p => p.PropertyTypeId == pType.Id).ToList();
355
                         props = props.Where(p => p.PropertyTypeId == pType.Id).ToList();
327
                     }
356
                     }
357
+
358
+                    obj.Property = "PropertyType";
359
+                    obj.Value = search.PropertyType;
360
+                    SaveLog(obj);
361
+                }
362
+                if (search.MinPrice > 0)
363
+                {
364
+                    props = props.Where(p => p.Price >= search.MinPrice).ToList();
365
+
366
+                    obj.Property = "MinPrice";
367
+                    obj.Value = search.MinPrice.ToString();
368
+                    SaveLog(obj);
369
+                }
370
+                if (search.MaxPrice > 0)
371
+                {
372
+                    props = props.Where(p => p.Price <= search.MaxPrice).ToList();
373
+
374
+                    obj.Property = "MaxPrice";
375
+                    obj.Value = search.MaxPrice.ToString();
376
+                    SaveLog(obj);
328
                 }
377
                 }
329
 
378
 
330
                 return GetDisplayDetails(props);
379
                 return GetDisplayDetails(props);
331
             }
380
             }
332
         }        
381
         }        
333
 
382
 
383
+        private void SaveLog(SearchObject item)
384
+        {
385
+            var searchLog = new SearchLog
386
+            {
387
+                Type = item.Type,
388
+                Search = JsonConvert.SerializeObject(item)
389
+            };
390
+            dBContext.SearchLogs.Add(searchLog);
391
+            Save();
392
+        }
393
+
334
         private List<PropertyDisplay> GetDisplayDetails(List<Property> props)
394
         private List<PropertyDisplay> GetDisplayDetails(List<Property> props)
335
         {
395
         {
336
             var properties = new List<PropertyDisplay>();
396
             var properties = new List<PropertyDisplay>();
376
                               where s.Id == item.SuburbId
436
                               where s.Id == item.SuburbId
377
                               select s.Description).FirstOrDefault(),
437
                               select s.Description).FirstOrDefault(),
378
                     Price = item.Price,
438
                     Price = item.Price,
379
-                    DateCreated = item.Created
439
+                    DateCreated = item.Created,
440
+                    PropertyUsageType = (from p in dBContext.PropertyTypes
441
+                                         where p.Id == item.PropertyTypeId
442
+                                         select p.UsageType.ToString()).FirstOrDefault()
380
                 };
443
                 };
381
 
444
 
382
                 if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
445
                 if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))

+ 9
- 1
UnivateProperties_API/Repository/Timeshare/WeekRepository.cs View File

116
         public void Insert(TimeshareWeek item)
116
         public void Insert(TimeshareWeek item)
117
         {
117
         {
118
             item = GetDetailedWeek(item);
118
             item = GetDetailedWeek(item);
119
-            if(item.Status == null)
119
+            item.Id = _dbContext.Weeks.Max(x => x.Id) + 1;
120
+            if (item.Owner != null && item.Owner.Id == 0)
121
+            {
122
+                item.Owner.Id = _dbContext.Individuals.Max(x => x.Id) + 1;
123
+            }
124
+            // Set starting Status of A1
125
+            StatusRepository repo = new StatusRepository(_dbContext);
126
+            item.Status = repo.GetDetailed(s => s.Code == "A1");
127
+            if(item.Status != null)
120
             {
128
             {
121
                 //Create initial
129
                 //Create initial
122
                 item.Status = new Status()
130
                 item.Status = new Status()

+ 1
- 0
UnivateProperties_API/Repository/Users/IRegisterRepository.cs View File

20
         void Delete(int id);
20
         void Delete(int id);
21
         void DeleteAgency(int id);
21
         void DeleteAgency(int id);
22
         void DeleteIndividual(int id);
22
         void DeleteIndividual(int id);
23
+        string UserDetails(int userId);
23
     }
24
     }
24
 }
25
 }

+ 22
- 0
UnivateProperties_API/Repository/Users/RegisterRepository.cs View File

274
             id += 1;
274
             id += 1;
275
             return id;
275
             return id;
276
         }
276
         }
277
+
278
+        public string UserDetails(int userId)
279
+        {
280
+            var individual = _dbContext.Individuals.Where(i => i.UserId == userId).FirstOrDefault();
281
+
282
+            if (individual == null)
283
+            {
284
+                var agent = _dbContext.Agents.Where(i => i.UserId == userId).FirstOrDefault();
285
+                if (agent != null)
286
+                {
287
+                    return agent.Name + " " + agent.Surname;
288
+                }
289
+                else
290
+                {
291
+                    return "";
292
+                }
293
+            }
294
+            else
295
+            {
296
+                return individual.Name + " " + individual.Surname;
297
+            }
298
+        }
277
     }
299
     }
278
 }
300
 }

Loading…
Cancel
Save