|
@@ -4,7 +4,9 @@ using System;
|
4
|
4
|
using System.Collections.Generic;
|
5
|
5
|
using System.Linq;
|
6
|
6
|
using UnivateProperties_API.Containers.Property;
|
|
7
|
+using UnivateProperties_API.Containers.Timeshare;
|
7
|
8
|
using UnivateProperties_API.Context;
|
|
9
|
+using UnivateProperties_API.Model.Logging;
|
8
|
10
|
using UnivateProperties_API.Model.Properties;
|
9
|
11
|
|
10
|
12
|
namespace UnivateProperties_API.Repository.Properties
|
|
@@ -247,16 +249,14 @@ namespace UnivateProperties_API.Repository.Properties
|
247
|
249
|
|
248
|
250
|
return GetDisplayDetails(props);
|
249
|
251
|
}
|
250
|
|
-
|
|
252
|
+
|
251
|
253
|
public List<PropertyDisplay> GetDisplay(PropertySearch search)
|
252
|
254
|
{
|
253
|
|
- //Save to Log
|
254
|
|
- dBContext.SearchLogs.Add(new Model.Logging.SearchLog()
|
|
255
|
+ SearchObject obj = new SearchObject()
|
255
|
256
|
{
|
256
|
|
- Type = "Property",
|
257
|
|
- Search = JsonConvert.SerializeObject(search)
|
258
|
|
- });
|
259
|
|
- Save();
|
|
257
|
+ UserName = search.UserName,
|
|
258
|
+ Type = "Property"
|
|
259
|
+ };
|
260
|
260
|
|
261
|
261
|
if (!string.IsNullOrEmpty(search.Keyword) && search.Keyword.ToUpper() != "ALL")
|
262
|
262
|
{
|
|
@@ -273,6 +273,9 @@ namespace UnivateProperties_API.Repository.Properties
|
273
|
273
|
|| EF.Functions.Like(s.Description.ToLower(), $"%{keyword}%")
|
274
|
274
|
|| EF.Functions.Like(pt.Description.ToLower(), $"%{keyword}%")
|
275
|
275
|
select p).ToList();
|
|
276
|
+ obj.Property = "Keyword";
|
|
277
|
+ obj.Value = search.Keyword;
|
|
278
|
+ SaveLog(obj);
|
276
|
279
|
|
277
|
280
|
return GetDisplayDetails(props);
|
278
|
281
|
}
|
|
@@ -281,7 +284,7 @@ namespace UnivateProperties_API.Repository.Properties
|
281
|
284
|
List<Property> props;
|
282
|
285
|
PropertyUsageType uType = PropertyUsageType.Both;
|
283
|
286
|
|
284
|
|
- if (!string.IsNullOrEmpty(search.PropertyUsageType) && search.PropertyUsageType != "undefined")
|
|
287
|
+ if (!string.IsNullOrEmpty(search.PropertyUsageType) && search.PropertyUsageType != "undefined" && search.PropertyUsageType.ToUpper() != "ALL")
|
285
|
288
|
{
|
286
|
289
|
if (search.PropertyUsageType.ToUpper() == "COMMERCIAL")
|
287
|
290
|
uType = PropertyUsageType.Commercial;
|
|
@@ -293,12 +296,20 @@ namespace UnivateProperties_API.Repository.Properties
|
293
|
296
|
where pt.UsageType == uType
|
294
|
297
|
select p).ToList();
|
295
|
298
|
|
|
299
|
+ obj.Property = "PropertyUsageType";
|
|
300
|
+ obj.Value = search.PropertyUsageType;
|
|
301
|
+ SaveLog(obj);
|
|
302
|
+
|
296
|
303
|
if (!string.IsNullOrEmpty(search.SalesType) && search.SalesType != "undefined" && search.SalesType.ToUpper() != "ALL")
|
297
|
304
|
{
|
298
|
305
|
if (search.SalesType.ToUpper() == "SALE")
|
299
|
306
|
props = props.Where(p => p.IsSale).ToList();
|
300
|
307
|
else
|
301
|
308
|
props = props.Where(p => !p.IsSale).ToList();
|
|
309
|
+
|
|
310
|
+ obj.Property = "SalesType";
|
|
311
|
+ obj.Value = search.SalesType;
|
|
312
|
+ SaveLog(obj);
|
302
|
313
|
}
|
303
|
314
|
|
304
|
315
|
if (!string.IsNullOrEmpty(search.Province) && search.Province != "undefined" && search.Province.ToUpper() != "ALL")
|
|
@@ -307,6 +318,10 @@ namespace UnivateProperties_API.Repository.Properties
|
307
|
318
|
join pp in dBContext.Provinces on p.ProvinceId equals pp.Id
|
308
|
319
|
where pp.Description.ToUpper() == search.Province.ToUpper()
|
309
|
320
|
select p).ToList();
|
|
321
|
+
|
|
322
|
+ obj.Property = "Province";
|
|
323
|
+ obj.Value = search.Province;
|
|
324
|
+ SaveLog(obj);
|
310
|
325
|
}
|
311
|
326
|
|
312
|
327
|
if (!string.IsNullOrEmpty(search.City) && search.City != "undefined" && search.City.ToUpper() != "ALL")
|
|
@@ -315,6 +330,10 @@ namespace UnivateProperties_API.Repository.Properties
|
315
|
330
|
join c in dBContext.Cities on p.CityId equals c.Id
|
316
|
331
|
where c.Description.ToUpper() == search.City.ToUpper()
|
317
|
332
|
select p).ToList();
|
|
333
|
+
|
|
334
|
+ obj.Property = "City";
|
|
335
|
+ obj.Value = search.City;
|
|
336
|
+ SaveLog(obj);
|
318
|
337
|
}
|
319
|
338
|
|
320
|
339
|
if (!string.IsNullOrEmpty(search.Suburb) && search.Suburb != "undefined" && search.Suburb.ToUpper() != "ALL")
|
|
@@ -323,6 +342,10 @@ namespace UnivateProperties_API.Repository.Properties
|
323
|
342
|
join s in dBContext.Suburbs on p.SuburbId equals s.Id
|
324
|
343
|
where s.Description.ToUpper() == search.Suburb.ToUpper()
|
325
|
344
|
select p).ToList();
|
|
345
|
+
|
|
346
|
+ obj.Property = "Suburb";
|
|
347
|
+ obj.Value = search.Suburb;
|
|
348
|
+ SaveLog(obj);
|
326
|
349
|
}
|
327
|
350
|
if (!string.IsNullOrEmpty(search.PropertyType) && search.PropertyType != "Undefined" && search.PropertyType.ToUpper() != "ALL")
|
328
|
351
|
{
|
|
@@ -331,12 +354,43 @@ namespace UnivateProperties_API.Repository.Properties
|
331
|
354
|
{
|
332
|
355
|
props = props.Where(p => p.PropertyTypeId == pType.Id).ToList();
|
333
|
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);
|
334
|
377
|
}
|
335
|
378
|
|
336
|
379
|
return GetDisplayDetails(props);
|
337
|
380
|
}
|
338
|
381
|
}
|
339
|
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
|
+
|
340
|
394
|
private List<PropertyDisplay> GetDisplayDetails(List<Property> props)
|
341
|
395
|
{
|
342
|
396
|
var properties = new List<PropertyDisplay>();
|
|
@@ -382,7 +436,10 @@ namespace UnivateProperties_API.Repository.Properties
|
382
|
436
|
where s.Id == item.SuburbId
|
383
|
437
|
select s.Description).FirstOrDefault(),
|
384
|
438
|
Price = item.Price,
|
385
|
|
- 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()
|
386
|
443
|
};
|
387
|
444
|
|
388
|
445
|
if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
|