瀏覽代碼

Property Banners - changes

master
George Williams 4 年之前
父節點
當前提交
68ac1ae321

+ 3
- 0
UnivateProperties_API/Containers/Property/PropertyContainer.cs 查看文件

13
         public string SalesTypeString { get; set; }
13
         public string SalesTypeString { get; set; }
14
         public int UserId { get; set; }
14
         public int UserId { get; set; }
15
         public string PropertyUsageType { get; set; }
15
         public string PropertyUsageType { get; set; }
16
+        public decimal OldPrice { get; set; }        
17
+        public string OldStatus { get; set; }
18
+        public string CutOffDisplayDateString { get; set; }
16
         public List<NewImage> NewImages { get; set; }
19
         public List<NewImage> NewImages { get; set; }
17
         public List<PropertyFieldGroup> PropertyOverviewFields { get; set; }
20
         public List<PropertyFieldGroup> PropertyOverviewFields { get; set; }
18
         public List<PropertyFieldGroup> PropertyFields { get; set; }
21
         public List<PropertyFieldGroup> PropertyFields { get; set; }

+ 2
- 2
UnivateProperties_API/Containers/Property/PropertyDisplay.cs 查看文件

34
         public decimal Price { get; set; }        
34
         public decimal Price { get; set; }        
35
         public DateTime DateCreated { get; set; }
35
         public DateTime DateCreated { get; set; }
36
         public DateTime DateAvailable { get; set; }
36
         public DateTime DateAvailable { get; set; }
37
-        public string Available { get; set; }
38
-        public bool HasPendingOffer { get; set; }
37
+        public string DisplayColor { get; set; }
38
+        public string DisplayText { get; set; }
39
         #endregion
39
         #endregion
40
     }
40
     }
41
 }
41
 }

+ 1625
- 0
UnivateProperties_API/Migrations/20200917125427_priceredused.Designer.cs
文件差異過大導致無法顯示
查看文件


+ 23
- 0
UnivateProperties_API/Migrations/20200917125427_priceredused.cs 查看文件

1
+using Microsoft.EntityFrameworkCore.Migrations;
2
+
3
+namespace UnivateProperties_API.Migrations
4
+{
5
+    public partial class priceredused : Migration
6
+    {
7
+        protected override void Up(MigrationBuilder migrationBuilder)
8
+        {
9
+            migrationBuilder.AddColumn<bool>(
10
+                name: "PriceRedused",
11
+                table: "Properties",
12
+                nullable: false,
13
+                defaultValue: false);
14
+        }
15
+
16
+        protected override void Down(MigrationBuilder migrationBuilder)
17
+        {
18
+            migrationBuilder.DropColumn(
19
+                name: "PriceRedused",
20
+                table: "Properties");
21
+        }
22
+    }
23
+}

+ 1627
- 0
UnivateProperties_API/Migrations/20200918092143_Added Cutoff show date.Designer.cs
文件差異過大導致無法顯示
查看文件


+ 24
- 0
UnivateProperties_API/Migrations/20200918092143_Added Cutoff show date.cs 查看文件

1
+using System;
2
+using Microsoft.EntityFrameworkCore.Migrations;
3
+
4
+namespace UnivateProperties_API.Migrations
5
+{
6
+    public partial class AddedCutoffshowdate : Migration
7
+    {
8
+        protected override void Up(MigrationBuilder migrationBuilder)
9
+        {
10
+            migrationBuilder.AddColumn<DateTime>(
11
+                name: "CutOffDisplayDate",
12
+                table: "Properties",
13
+                nullable: false,
14
+                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
15
+        }
16
+
17
+        protected override void Down(MigrationBuilder migrationBuilder)
18
+        {
19
+            migrationBuilder.DropColumn(
20
+                name: "CutOffDisplayDate",
21
+                table: "Properties");
22
+        }
23
+    }
24
+}

+ 4
- 0
UnivateProperties_API/Migrations/DataContextModelSnapshot.cs 查看文件

670
 
670
 
671
                     b.Property<DateTime>("Created");
671
                     b.Property<DateTime>("Created");
672
 
672
 
673
+                    b.Property<DateTime>("CutOffDisplayDate");
674
+
673
                     b.Property<DateTime>("DateAvailable");
675
                     b.Property<DateTime>("DateAvailable");
674
 
676
 
675
                     b.Property<DateTime>("DatePublished");
677
                     b.Property<DateTime>("DatePublished");
694
 
696
 
695
                     b.Property<string>("PricePer");
697
                     b.Property<string>("PricePer");
696
 
698
 
699
+                    b.Property<bool>("PriceRedused");
700
+
697
                     b.Property<string>("PropertCoords");
701
                     b.Property<string>("PropertCoords");
698
 
702
 
699
                     b.Property<string>("PropertyName");
703
                     b.Property<string>("PropertyName");

+ 5
- 17
UnivateProperties_API/Model/Properties/Property.cs 查看文件

38
         public bool Published { get; set; }
38
         public bool Published { get; set; }
39
         public DateTime DatePublished { get; set; }
39
         public DateTime DatePublished { get; set; }
40
         public string VirtualTour { get; set; }
40
         public string VirtualTour { get; set; }
41
+        public bool PriceRedused { get; set; }
41
         public string Video { get; set; }
42
         public string Video { get; set; }
42
         [ForeignKey("Status")]
43
         [ForeignKey("Status")]
43
-        public int? StatusId 
44
-        { 
45
-            get
46
-            {
47
-                return _StatusID;
48
-            }
49
-            set
50
-            {
51
-                _StatusID = value;
52
-                if (value != null)
53
-                {
54
-                    StatusDate = DateTime.Now;
55
-                }
56
-            }
57
-        }
44
+        public int? StatusId { get; set; }       
58
         [ForeignKey("Owner")]
45
         [ForeignKey("Owner")]
59
         public int? OwnerId { get; set; }
46
         public int? OwnerId { get; set; }
60
         [ForeignKey("Agent")]
47
         [ForeignKey("Agent")]
66
         public virtual PropertyType PropertyType { get; set; }            
53
         public virtual PropertyType PropertyType { get; set; }            
67
         [NotMapped]
54
         [NotMapped]
68
         public Status Status { get; set; }        
55
         public Status Status { get; set; }        
69
-        public virtual Individual Owner { get; set; }        
70
-        public virtual Agent Agent { get; set; }        
56
+        public virtual Individual Owner { get; set; }
57
+        public virtual Agent Agent { get; set; }
71
         public virtual Agency Agency { get; set; }
58
         public virtual Agency Agency { get; set; }
59
+        public DateTime CutOffDisplayDate { get; set; }        
72
 
60
 
73
         public ICollection<PropertyUserField> PropertyUserFields { get; set; }
61
         public ICollection<PropertyUserField> PropertyUserFields { get; set; }
74
         public ICollection<PropertyImage> PropertyImages { get; set; }
62
         public ICollection<PropertyImage> PropertyImages { get; set; }

+ 76
- 22
UnivateProperties_API/Repository/Properties/PropertyRepository.cs 查看文件

138
 
138
 
139
             var propertyDetails = new PropertyContainer();
139
             var propertyDetails = new PropertyContainer();
140
 
140
 
141
-            propertyDetails.SalesTypeString = property.IsSale ? "Sale" : "Rental";            
141
+            propertyDetails.SalesTypeString = property.IsSale ? "Sale" : "Rental";
142
+            propertyDetails.OldPrice = property.Price;
142
 
143
 
143
             foreach (string prop in property.GetAllProperties())
144
             foreach (string prop in property.GetAllProperties())
144
             {
145
             {
147
             }
148
             }
148
 
149
 
149
             if (property.StatusId != null)
150
             if (property.StatusId != null)
151
+            {
150
                 propertyDetails.StatusString = dBContext.Status.Where(s => s.Id == property.StatusId).FirstOrDefault()?.Description;
152
                 propertyDetails.StatusString = dBContext.Status.Where(s => s.Id == property.StatusId).FirstOrDefault()?.Description;
153
+                propertyDetails.OldStatus = propertyDetails.StatusString;
154
+            }
151
 
155
 
152
             propertyDetails.PropertyUsageType = propertyType.UsageType == PropertyUsageType.Commercial ? "Commercial" : "Residential";
156
             propertyDetails.PropertyUsageType = propertyType.UsageType == PropertyUsageType.Commercial ? "Commercial" : "Residential";
153
 
157
 
157
                 propertyDetails.UserId = (dBContext.Agents.Where(p => p.Id == property.AgentId).FirstOrDefault().UserId).Value;
161
                 propertyDetails.UserId = (dBContext.Agents.Where(p => p.Id == property.AgentId).FirstOrDefault().UserId).Value;
158
 
162
 
159
             propertyDetails.NewImages = new List<NewImage>();
163
             propertyDetails.NewImages = new List<NewImage>();
160
-            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);
161
 
172
 
162
             return propertyDetails;
173
             return propertyDetails;
163
         }
174
         }
225
             {
236
             {
226
                 if (prop != "Item" && prop != "Display")
237
                 if (prop != "Item" && prop != "Display")
227
                     property[prop] = item[prop];
238
                     property[prop] = item[prop];
228
-            }
239
+            }            
229
 
240
 
230
             property.PropertyUserFields = null;
241
             property.PropertyUserFields = null;
231
             property.PropertyImages = null;
242
             property.PropertyImages = null;
232
 
243
 
244
+            if (item.Price < item.OldPrice)
245
+            {
246
+                property.PriceRedused = true;
247
+            }            
248
+
233
             if (!string.IsNullOrEmpty(item.StatusString))
249
             if (!string.IsNullOrEmpty(item.StatusString))
234
             {
250
             {
251
+                if (item.StatusString != item.OldStatus)
252
+                    property.StatusDate = DateTime.Now;
253
+
235
                 property.StatusId = dBContext.Status.Where(s => s.Description == item.StatusString && s.StatusType == StatusType.Property).FirstOrDefault()?.Id;
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;
236
             }
267
             }
237
 
268
 
238
             if (!string.IsNullOrEmpty(item.DateAvailableString))
269
             if (!string.IsNullOrEmpty(item.DateAvailableString))
535
                 PropertyDisplay display = new PropertyDisplay
566
                 PropertyDisplay display = new PropertyDisplay
536
                 {
567
                 {
537
                     PropertyReference = item.PropertyRef,
568
                     PropertyReference = item.PropertyRef,
538
-                    DateAvailable = item.DateAvailable,
539
-                    Available = item.DateAvailable.Date > DateTime.Now.Date ? string.Format("Available form: {0: dd MMM yyyy}", item.DateAvailable) : "Available Now",
569
+                    DateAvailable = item.DateAvailable,                    
540
                     Id = item.Id,
570
                     Id = item.Id,
541
                     ShortDescription = item.ShortDescription,
571
                     ShortDescription = item.ShortDescription,
542
                     IsSale = item.IsSale,
572
                     IsSale = item.IsSale,
572
                     DateCreated = item.Created,
602
                     DateCreated = item.Created,
573
                     PropertyUsageType = (from p in dBContext.PropertyTypes
603
                     PropertyUsageType = (from p in dBContext.PropertyTypes
574
                                          where p.Id == item.PropertyTypeId
604
                                          where p.Id == item.PropertyTypeId
575
-                                         select p.UsageType.ToString()).FirstOrDefault(),
576
-                    HasPendingOffer = false
577
-                };                
605
+                                         select p.UsageType.ToString()).FirstOrDefault()
606
+                };
578
 
607
 
579
-                if (item.StatusId != null)
608
+                var status = dBContext.Status.Where(s => s.Id == item.StatusId).FirstOrDefault();
609
+                switch (status.Description.ToUpper())
580
                 {
610
                 {
581
-                    var status = dBContext.Status.Where(s => s.Id == item.StatusId).FirstOrDefault();
582
-                    if (status.Description.ToUpper() == "OFFER PENDING")
583
-                        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
+
584
                 }
644
                 }
585
 
645
 
586
                 if (display.DisplayImage != null && !display.DisplayImage.StartsWith("data:image"))
646
                 if (display.DisplayImage != null && !display.DisplayImage.StartsWith("data:image"))
587
                 {
647
                 {
588
                     display.DisplayImage = ImageFormatter.ImageToBase64(display.DisplayImage);
648
                     display.DisplayImage = ImageFormatter.ImageToBase64(display.DisplayImage);
589
                 }
649
                 }
590
-
591
-                //if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
592
-                //{
593
-                //    display.Area = display.Area.Substring(0, display.Area.Length - 1) + "<sup>" + display.Area.Last() + "</sup>";
594
-                //}
595
-
596
-                if (display.HasPendingOffer)
597
-                    display.Available = "Offer Pending";
598
 #if !ReturnImages
650
 #if !ReturnImages
599
                 display.DisplayImage = "";
651
                 display.DisplayImage = "";
600
 #endif
652
 #endif
617
 
669
 
618
         public List<PropertyDisplay> GetLatestDisplay()
670
         public List<PropertyDisplay> GetLatestDisplay()
619
         {
671
         {
620
-            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();
621
             return GetDisplayDetails(props);
673
             return GetDisplayDetails(props);
622
         }
674
         }
623
 
675
 
634
                     break;
686
                     break;
635
             }
687
             }
636
 
688
 
637
-            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();
638
             return GetDisplayDetails(props);
692
             return GetDisplayDetails(props);
639
         }
693
         }
640
 
694
 

Loading…
取消
儲存