|
@@ -1,4 +1,7 @@
|
1
|
|
-using Microsoft.EntityFrameworkCore;
|
|
1
|
+#define ReturnImages
|
|
2
|
+//#undef ReturnImages //Comment out to return images
|
|
3
|
+
|
|
4
|
+using Microsoft.EntityFrameworkCore;
|
2
|
5
|
using Newtonsoft.Json;
|
3
|
6
|
using System;
|
4
|
7
|
using System.Collections.Generic;
|
|
@@ -104,20 +107,20 @@ namespace UnivateProperties_API.Repository.Properties
|
104
|
107
|
|
105
|
108
|
foreach (var val in groupFields)
|
106
|
109
|
{
|
107
|
|
- var irem = new PropertyDetail()
|
|
110
|
+ var item = new PropertyDetail()
|
108
|
111
|
{
|
109
|
112
|
Name = val.FieldName,
|
110
|
113
|
Description = val.Description
|
111
|
114
|
};
|
112
|
115
|
|
113
|
|
- detailGroup.Values.Add(irem);
|
|
116
|
+ detailGroup.Values.Add(item);
|
114
|
117
|
|
115
|
|
- if ((val.FieldName == "Erf Size" || val.FieldName == "Floor Size") && val.Value.EndsWith("2"))
|
|
118
|
+ if (!string.IsNullOrEmpty(val.Value) && (val.FieldName == "Erf Size" || val.FieldName == "Floor Size") && val.Value.EndsWith("2"))
|
116
|
119
|
{
|
117
|
|
- irem.Value = val.Value.Substring(0, val.Value.Length - 1) + "<sup>" + val.Value.Last() + "</sup>";
|
|
120
|
+ item.Value = val.Value.Substring(0, val.Value.Length - 1) + "<sup>" + val.Value.Last() + "</sup>";
|
118
|
121
|
}
|
119
|
122
|
else
|
120
|
|
- irem.Value = val.Value;
|
|
123
|
+ item.Value = val.Value;
|
121
|
124
|
}
|
122
|
125
|
|
123
|
126
|
property.DisplayData.Add(detailGroup);
|
|
@@ -329,6 +332,12 @@ namespace UnivateProperties_API.Repository.Properties
|
329
|
332
|
|
330
|
333
|
public List<PropertyDisplay> GetDisplay(PropertySearch search)
|
331
|
334
|
{
|
|
335
|
+ //return GetDisplayDetails(dBContext.Properties.ToList());
|
|
336
|
+
|
|
337
|
+ //StreamWriter SW = new StreamWriter(@"c:\temp\SearchData.txt", true);
|
|
338
|
+ //SW.WriteLine(string.Format("{0:yyyy-MM-dd hh:mm:ss} - {1}", DateTime.Now, JsonConvert.SerializeObject(search)));
|
|
339
|
+ //SW.Close();
|
|
340
|
+
|
332
|
341
|
SearchObject obj = new SearchObject()
|
333
|
342
|
{
|
334
|
343
|
UserName = search.UserName,
|
|
@@ -359,6 +368,14 @@ namespace UnivateProperties_API.Repository.Properties
|
359
|
368
|
else
|
360
|
369
|
{
|
361
|
370
|
List<Property> props;
|
|
371
|
+
|
|
372
|
+ //Property ID search will override other searches.
|
|
373
|
+ if (search.PropertyId > 0)
|
|
374
|
+ {
|
|
375
|
+ props = dBContext.Properties.Where(p => p.Id == search.PropertyId).ToList();
|
|
376
|
+ return GetDisplayDetails(props);
|
|
377
|
+ }
|
|
378
|
+
|
362
|
379
|
PropertyUsageType uType = PropertyUsageType.Both;
|
363
|
380
|
|
364
|
381
|
if (!string.IsNullOrEmpty(search.PropertyUsageType) && search.PropertyUsageType != "undefined" && search.PropertyUsageType.ToUpper() != "ALL")
|
|
@@ -380,7 +397,10 @@ namespace UnivateProperties_API.Repository.Properties
|
380
|
397
|
if (!string.IsNullOrEmpty(search.SalesType) && search.SalesType != "undefined" && search.SalesType.ToUpper() != "ALL")
|
381
|
398
|
{
|
382
|
399
|
if (search.SalesType.ToUpper() == "SALE")
|
|
400
|
+ {
|
383
|
401
|
props = props.Where(p => p.IsSale).ToList();
|
|
402
|
+ search.AvailableFrom = DateTime.MinValue; //Sales do not have an available from date.
|
|
403
|
+ }
|
384
|
404
|
else
|
385
|
405
|
props = props.Where(p => !p.IsSale).ToList();
|
386
|
406
|
|
|
@@ -453,6 +473,15 @@ namespace UnivateProperties_API.Repository.Properties
|
453
|
473
|
SaveLog(obj);
|
454
|
474
|
}
|
455
|
475
|
|
|
476
|
+ if (search.AvailableFrom != DateTime.MinValue)
|
|
477
|
+ {
|
|
478
|
+ props = props.Where(p => p.DateAvailable.Date >= search.AvailableFrom.Date).ToList();
|
|
479
|
+
|
|
480
|
+ obj.Property = "AvailableFrom";
|
|
481
|
+ obj.Value = search.AvailableFrom.ToString();
|
|
482
|
+ SaveLog(obj);
|
|
483
|
+ }
|
|
484
|
+
|
456
|
485
|
return GetDisplayDetails(props);
|
457
|
486
|
}
|
458
|
487
|
}
|
|
@@ -472,9 +501,11 @@ namespace UnivateProperties_API.Repository.Properties
|
472
|
501
|
{
|
473
|
502
|
var properties = new List<PropertyDisplay>();
|
474
|
503
|
foreach (var item in props)
|
475
|
|
- {
|
|
504
|
+ {
|
476
|
505
|
PropertyDisplay display = new PropertyDisplay
|
477
|
|
- {
|
|
506
|
+ {
|
|
507
|
+ DateAvailable = item.DateAvailable,
|
|
508
|
+ Available = item.DateAvailable.Date > DateTime.Now.Date ? string.Format("Available form: {0: dd MMM yyyy}", item.DateAvailable) : "Available Now",
|
478
|
509
|
Id = item.Id,
|
479
|
510
|
ShortDescription = item.ShortDescription,
|
480
|
511
|
IsSale = item.IsSale,
|
|
@@ -516,7 +547,8 @@ namespace UnivateProperties_API.Repository.Properties
|
516
|
547
|
DateCreated = item.Created,
|
517
|
548
|
PropertyUsageType = (from p in dBContext.PropertyTypes
|
518
|
549
|
where p.Id == item.PropertyTypeId
|
519
|
|
- select p.UsageType.ToString()).FirstOrDefault()
|
|
550
|
+ select p.UsageType.ToString()).FirstOrDefault(),
|
|
551
|
+ HasPendingOffer = !MayEdit(item.Id)
|
520
|
552
|
};
|
521
|
553
|
|
522
|
554
|
if (display.DisplayImage != null && !display.DisplayImage.StartsWith("data:image"))
|
|
@@ -529,6 +561,11 @@ namespace UnivateProperties_API.Repository.Properties
|
529
|
561
|
display.Area = display.Area.Substring(0, display.Area.Length - 1) + "<sup>" + display.Area.Last() + "</sup>";
|
530
|
562
|
}
|
531
|
563
|
|
|
564
|
+ if (display.HasPendingOffer)
|
|
565
|
+ display.Available = "Offer Pending";
|
|
566
|
+#if !ReturnImages
|
|
567
|
+ display.DisplayImage = "";
|
|
568
|
+#endif
|
532
|
569
|
properties.Add(display);
|
533
|
570
|
}
|
534
|
571
|
|
|
@@ -588,7 +625,8 @@ namespace UnivateProperties_API.Repository.Properties
|
588
|
625
|
Price = string.Format("R {0:n}", p.Price),
|
589
|
626
|
Publish = p.Published.ToString(),
|
590
|
627
|
Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description,
|
591
|
|
- CarouselDescription = string.Format("{0}, {1} <br/>{2}", p.Suburb.Description, p.City.Description, p.AddressLine3)
|
|
628
|
+ CarouselDescription = string.Format("{0}, {1} <br/>{2}", p.Suburb.Description, p.City.Description, p.AddressLine3),
|
|
629
|
+ DateAvailable = p.DateAvailable
|
592
|
630
|
};
|
593
|
631
|
|
594
|
632
|
prop.Size = (from u in dBContext.PropertyUserFields
|