|
@@ -114,22 +114,18 @@ namespace UnivateProperties_API.Repository.Properties
|
114
|
114
|
|
115
|
115
|
foreach (var val in groupFields)
|
116
|
116
|
{
|
117
|
|
- var item = new PropertyDetail()
|
|
117
|
+ if (!string.IsNullOrEmpty(val.Value))
|
118
|
118
|
{
|
119
|
|
- Name = val.FieldName,
|
120
|
|
- Description = val.Description
|
121
|
|
- };
|
122
|
|
-
|
123
|
|
- detailGroup.Values.Add(item);
|
124
|
|
-
|
125
|
|
- //if (!string.IsNullOrEmpty(val.Value) && (val.FieldName == "Erf Size" || val.FieldName == "Floor Size") && val.Value.EndsWith("2"))
|
126
|
|
- //{
|
127
|
|
- // item.Value = val.Value.Substring(0, val.Value.Length - 1) + "<sup>" + val.Value.Last() + "</sup>";
|
128
|
|
- //}
|
129
|
|
- //else
|
130
|
|
- item.Value = val.Value;
|
|
119
|
+ var item = new PropertyDetail()
|
|
120
|
+ {
|
|
121
|
+ Name = val.FieldName,
|
|
122
|
+ Description = val.Description,
|
|
123
|
+ Value = val.Value
|
|
124
|
+ };
|
|
125
|
+
|
|
126
|
+ detailGroup.Values.Add(item);
|
|
127
|
+ }
|
131
|
128
|
}
|
132
|
|
-
|
133
|
129
|
property.DisplayData.Add(detailGroup);
|
134
|
130
|
}
|
135
|
131
|
}
|
|
@@ -142,7 +138,8 @@ namespace UnivateProperties_API.Repository.Properties
|
142
|
138
|
|
143
|
139
|
var propertyDetails = new PropertyContainer();
|
144
|
140
|
|
145
|
|
- propertyDetails.SalesTypeString = property.IsSale ? "Sale" : "Rental";
|
|
141
|
+ propertyDetails.SalesTypeString = property.IsSale ? "Sale" : "Rental";
|
|
142
|
+ propertyDetails.OldPrice = property.Price;
|
146
|
143
|
|
147
|
144
|
foreach (string prop in property.GetAllProperties())
|
148
|
145
|
{
|
|
@@ -151,7 +148,10 @@ namespace UnivateProperties_API.Repository.Properties
|
151
|
148
|
}
|
152
|
149
|
|
153
|
150
|
if (property.StatusId != null)
|
|
151
|
+ {
|
154
|
152
|
propertyDetails.StatusString = dBContext.Status.Where(s => s.Id == property.StatusId).FirstOrDefault()?.Description;
|
|
153
|
+ propertyDetails.OldStatus = propertyDetails.StatusString;
|
|
154
|
+ }
|
155
|
155
|
|
156
|
156
|
propertyDetails.PropertyUsageType = propertyType.UsageType == PropertyUsageType.Commercial ? "Commercial" : "Residential";
|
157
|
157
|
|
|
@@ -161,7 +161,14 @@ namespace UnivateProperties_API.Repository.Properties
|
161
|
161
|
propertyDetails.UserId = (dBContext.Agents.Where(p => p.Id == property.AgentId).FirstOrDefault().UserId).Value;
|
162
|
162
|
|
163
|
163
|
propertyDetails.NewImages = new List<NewImage>();
|
164
|
|
- propertyDetails.DateAvailableString = string.Format("{0:yyyy-MM-dd}", property.DateAvailable);
|
|
164
|
+
|
|
165
|
+ if (property.DateAvailable != DateTime.MinValue)
|
|
166
|
+ propertyDetails.DateAvailableString = string.Format("{0:yyyy-MM-dd}", property.DateAvailable);
|
|
167
|
+
|
|
168
|
+ if (property.CutOffDisplayDate == DateTime.MinValue)
|
|
169
|
+ propertyDetails.CutOffDisplayDateString = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddMonths(1));
|
|
170
|
+ else
|
|
171
|
+ propertyDetails.CutOffDisplayDateString = string.Format("{0:yyyy-MM-dd}", property.CutOffDisplayDate);
|
165
|
172
|
|
166
|
173
|
return propertyDetails;
|
167
|
174
|
}
|
|
@@ -229,14 +236,34 @@ namespace UnivateProperties_API.Repository.Properties
|
229
|
236
|
{
|
230
|
237
|
if (prop != "Item" && prop != "Display")
|
231
|
238
|
property[prop] = item[prop];
|
232
|
|
- }
|
|
239
|
+ }
|
233
|
240
|
|
234
|
241
|
property.PropertyUserFields = null;
|
235
|
242
|
property.PropertyImages = null;
|
236
|
243
|
|
|
244
|
+ if (item.Price < item.OldPrice)
|
|
245
|
+ {
|
|
246
|
+ property.PriceRedused = true;
|
|
247
|
+ }
|
|
248
|
+
|
237
|
249
|
if (!string.IsNullOrEmpty(item.StatusString))
|
238
|
250
|
{
|
|
251
|
+ if (item.StatusString != item.OldStatus)
|
|
252
|
+ property.StatusDate = DateTime.Now;
|
|
253
|
+
|
239
|
254
|
property.StatusId = dBContext.Status.Where(s => s.Description == item.StatusString && s.StatusType == StatusType.Property).FirstOrDefault()?.Id;
|
|
255
|
+ if ((item.StatusString.ToUpper() == "RENTED OUT" || item.StatusString.ToUpper() == "SOLD") && item.StatusString != item.OldStatus)
|
|
256
|
+ {
|
|
257
|
+ property.CutOffDisplayDate = DateTime.Now.AddMonths(1);
|
|
258
|
+ }
|
|
259
|
+ else
|
|
260
|
+ {
|
|
261
|
+ property.CutOffDisplayDate = DateTime.MinValue;
|
|
262
|
+ }
|
|
263
|
+ if (item.StatusString.ToUpper() == "FOR SALE")
|
|
264
|
+ property.IsSale = true;
|
|
265
|
+ if (item.StatusString.ToUpper() == "FOR RENT")
|
|
266
|
+ property.IsSale = false;
|
240
|
267
|
}
|
241
|
268
|
|
242
|
269
|
if (!string.IsNullOrEmpty(item.DateAvailableString))
|
|
@@ -539,8 +566,7 @@ namespace UnivateProperties_API.Repository.Properties
|
539
|
566
|
PropertyDisplay display = new PropertyDisplay
|
540
|
567
|
{
|
541
|
568
|
PropertyReference = item.PropertyRef,
|
542
|
|
- DateAvailable = item.DateAvailable,
|
543
|
|
- Available = item.DateAvailable.Date > DateTime.Now.Date ? string.Format("Available form: {0: dd MMM yyyy}", item.DateAvailable) : "Available Now",
|
|
569
|
+ DateAvailable = item.DateAvailable,
|
544
|
570
|
Id = item.Id,
|
545
|
571
|
ShortDescription = item.ShortDescription,
|
546
|
572
|
IsSale = item.IsSale,
|
|
@@ -576,29 +602,51 @@ namespace UnivateProperties_API.Repository.Properties
|
576
|
602
|
DateCreated = item.Created,
|
577
|
603
|
PropertyUsageType = (from p in dBContext.PropertyTypes
|
578
|
604
|
where p.Id == item.PropertyTypeId
|
579
|
|
- select p.UsageType.ToString()).FirstOrDefault(),
|
580
|
|
- HasPendingOffer = false
|
581
|
|
- };
|
|
605
|
+ select p.UsageType.ToString()).FirstOrDefault()
|
|
606
|
+ };
|
582
|
607
|
|
583
|
|
- if (item.StatusId != null)
|
|
608
|
+ var status = dBContext.Status.Where(s => s.Id == item.StatusId).FirstOrDefault();
|
|
609
|
+ switch (status.Description.ToUpper())
|
584
|
610
|
{
|
585
|
|
- var status = dBContext.Status.Where(s => s.Id == item.StatusId).FirstOrDefault();
|
586
|
|
- if (status.Description.ToUpper() == "OFFER PENDING")
|
587
|
|
- display.HasPendingOffer = true;
|
|
611
|
+ case "FOR RENT":
|
|
612
|
+ if (item.DateAvailable < DateTime.Now)
|
|
613
|
+ {
|
|
614
|
+ display.DisplayText = "Available Now";
|
|
615
|
+ display.DisplayColor = "green";
|
|
616
|
+ }
|
|
617
|
+ else
|
|
618
|
+ {
|
|
619
|
+ display.DisplayText = string.Format("Available From: {0:dd MMM yyyy}", item.DateAvailable);
|
|
620
|
+ display.DisplayColor = "blue";
|
|
621
|
+ }
|
|
622
|
+ break;
|
|
623
|
+ case "FOR SALE":
|
|
624
|
+ if (item.PriceRedused)
|
|
625
|
+ {
|
|
626
|
+ display.DisplayText = "Price Redused";
|
|
627
|
+ display.DisplayColor = "green";
|
|
628
|
+ }
|
|
629
|
+ else
|
|
630
|
+ {
|
|
631
|
+ display.DisplayText = "For Sale";
|
|
632
|
+ display.DisplayColor = "blue";
|
|
633
|
+ }
|
|
634
|
+ break;
|
|
635
|
+ case "OFFER PENDING":
|
|
636
|
+ display.DisplayText = "Offer Pending";
|
|
637
|
+ display.DisplayColor = "orange";
|
|
638
|
+ break;
|
|
639
|
+ default:
|
|
640
|
+ display.DisplayText = status.Description;
|
|
641
|
+ display.DisplayColor = "red";
|
|
642
|
+ break;
|
|
643
|
+
|
588
|
644
|
}
|
589
|
645
|
|
590
|
646
|
if (display.DisplayImage != null && !display.DisplayImage.StartsWith("data:image"))
|
591
|
647
|
{
|
592
|
648
|
display.DisplayImage = ImageFormatter.ImageToBase64(display.DisplayImage);
|
593
|
649
|
}
|
594
|
|
-
|
595
|
|
- //if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
|
596
|
|
- //{
|
597
|
|
- // display.Area = display.Area.Substring(0, display.Area.Length - 1) + "<sup>" + display.Area.Last() + "</sup>";
|
598
|
|
- //}
|
599
|
|
-
|
600
|
|
- if (display.HasPendingOffer)
|
601
|
|
- display.Available = "Offer Pending";
|
602
|
650
|
#if !ReturnImages
|
603
|
651
|
display.DisplayImage = "";
|
604
|
652
|
#endif
|
|
@@ -621,7 +669,7 @@ namespace UnivateProperties_API.Repository.Properties
|
621
|
669
|
|
622
|
670
|
public List<PropertyDisplay> GetLatestDisplay()
|
623
|
671
|
{
|
624
|
|
- List<Property> props = GetAll().Where(x => x.Published).OrderByDescending(x => x.DatePublished).Take(4).ToList();
|
|
672
|
+ List<Property> props = GetAll().Where(x => x.Published && (x.CutOffDisplayDate == DateTime.MinValue || x.CutOffDisplayDate.Date > DateTime.Now.Date)).OrderByDescending(x => x.DatePublished).Take(4).ToList();
|
625
|
673
|
return GetDisplayDetails(props);
|
626
|
674
|
}
|
627
|
675
|
|
|
@@ -638,7 +686,9 @@ namespace UnivateProperties_API.Repository.Properties
|
638
|
686
|
break;
|
639
|
687
|
}
|
640
|
688
|
|
641
|
|
- List<Property> props = dBContext.Properties.Include("PropertyType").Where(x => x.Published && x.PropertyType.UsageType == type).OrderByDescending(x => x.DatePublished).Take(4).ToList();
|
|
689
|
+ List<Property> props = dBContext.Properties.Include("PropertyType").Where(x => x.Published
|
|
690
|
+ && x.PropertyType.UsageType == type
|
|
691
|
+ && (x.CutOffDisplayDate == DateTime.MinValue || x.CutOffDisplayDate.Date > DateTime.Now.Date)).OrderByDescending(x => x.DatePublished).Take(4).ToList();
|
642
|
692
|
return GetDisplayDetails(props);
|
643
|
693
|
}
|
644
|
694
|
|