| 
				
			 | 
			
			
				
				@@ -548,7 +548,7 @@ namespace UnivateProperties_API.Repository.Properties 
			 | 
		
		
	
		
			
			| 
				548
			 | 
			
				548
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				549
			 | 
			
				549
			 | 
			
			
				
				         public List<PropertyDisplay> GetLatestDisplay() 
			 | 
		
		
	
		
			
			| 
				550
			 | 
			
				550
			 | 
			
			
				
				         { 
			 | 
		
		
	
		
			
			| 
				551
			 | 
			
				
			 | 
			
			
				
				-            List<Property> props = GetAll().OrderBy(x => x.Created).Take(3).ToList(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				551
			 | 
			
			
				
				+            List<Property> props = GetAll().OrderByDescending(x => x.Created).Take(3).ToList(); 
			 | 
		
		
	
		
			
			| 
				552
			 | 
			
				552
			 | 
			
			
				
				             return GetDisplayDetails(props); 
			 | 
		
		
	
		
			
			| 
				553
			 | 
			
				553
			 | 
			
			
				
				         } 
			 | 
		
		
	
		
			
			| 
				554
			 | 
			
				554
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -561,16 +561,20 @@ namespace UnivateProperties_API.Repository.Properties 
			 | 
		
		
	
		
			
			| 
				561
			 | 
			
				561
			 | 
			
			
				
				             if (Type.ToUpper() == "MY") 
			 | 
		
		
	
		
			
			| 
				562
			 | 
			
				562
			 | 
			
			
				
				             {                 
			 | 
		
		
	
		
			
			| 
				563
			 | 
			
				563
			 | 
			
			
				
				                 if (individual != null) 
			 | 
		
		
	
		
			
			| 
				564
			 | 
			
				
			 | 
			
			
				
				-                    properties = Get(x => x.OwnerId == individual.Id); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				564
			 | 
			
			
				
				+                    properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.OwnerId == individual.Id).ToList(); 
			 | 
		
		
	
		
			
			| 
				565
			 | 
			
				565
			 | 
			
			
				
				                 if (agent != null) 
			 | 
		
		
	
		
			
			| 
				566
			 | 
			
				
			 | 
			
			
				
				-                    properties = Get(x => x.AgentId == agent.Id); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				566
			 | 
			
			
				
				+                    properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.AgentId == agent.Id).ToList(); 
			 | 
		
		
	
		
			
			| 
				567
			 | 
			
				567
			 | 
			
			
				
				             } 
			 | 
		
		
	
		
			
			| 
				568
			 | 
			
				
			 | 
			
			
				
				-            else 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				568
			 | 
			
			
				
				+            else if (Type.ToUpper() == "ADMIN") 
			 | 
		
		
	
		
			
			| 
				569
			 | 
			
				569
			 | 
			
			
				
				             { 
			 | 
		
		
	
		
			
			| 
				570
			 | 
			
				570
			 | 
			
			
				
				                 if (individual != null) 
			 | 
		
		
	
		
			
			| 
				571
			 | 
			
				
			 | 
			
			
				
				-                    properties = Get(x => x.OwnerId == individual.Id); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				571
			 | 
			
			
				
				+                    properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.OwnerId == individual.Id).ToList(); 
			 | 
		
		
	
		
			
			| 
				572
			 | 
			
				572
			 | 
			
			
				
				                 if (agent != null) 
			 | 
		
		
	
		
			
			| 
				573
			 | 
			
				
			 | 
			
			
				
				-                    properties = Get(x => x.AgencyId == agent.AgencyId); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				573
			 | 
			
			
				
				+                    properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.AgencyId == agent.AgencyId).ToList(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				574
			 | 
			
			
				
				+            } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				575
			 | 
			
			
				
				+            else if (Type.ToUpper() == "SUPERADMIN") 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				576
			 | 
			
			
				
				+            { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				577
			 | 
			
			
				
				+                properties = dBContext.Properties.Include("City").Include("Suburb").ToList(); 
			 | 
		
		
	
		
			
			| 
				574
			 | 
			
				578
			 | 
			
			
				
				             } 
			 | 
		
		
	
		
			
			| 
				575
			 | 
			
				579
			 | 
			
			
				
				              
			 | 
		
		
	
		
			
			| 
				576
			 | 
			
				580
			 | 
			
			
				
				             List<PropertyList> list = new List<PropertyList>(); 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -583,7 +587,8 @@ namespace UnivateProperties_API.Repository.Properties 
			 | 
		
		
	
		
			
			| 
				583
			 | 
			
				587
			 | 
			
			
				
				                     Name = string.IsNullOrEmpty(p.PropertyName) ? p.ShortDescription : p.PropertyName, 
			 | 
		
		
	
		
			
			| 
				584
			 | 
			
				588
			 | 
			
			
				
				                     Price = string.Format("R {0:n}", p.Price), 
			 | 
		
		
	
		
			
			| 
				585
			 | 
			
				589
			 | 
			
			
				
				                     Publish = p.Published.ToString(), 
			 | 
		
		
	
		
			
			| 
				586
			 | 
			
				
			 | 
			
			
				
				-                    Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				590
			 | 
			
			
				
				+                    Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description, 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				591
			 | 
			
			
				
				+                    CarouselDescription = string.Format("{0}, {1} <br/>{2}", p.Suburb.Description, p.City.Description, p.AddressLine3) 
			 | 
		
		
	
		
			
			| 
				587
			 | 
			
				592
			 | 
			
			
				
				                 }; 
			 | 
		
		
	
		
			
			| 
				588
			 | 
			
				593
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				589
			 | 
			
				594
			 | 
			
			
				
				                 prop.Size = (from u in dBContext.PropertyUserFields 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -654,7 +659,7 @@ namespace UnivateProperties_API.Repository.Properties 
			 | 
		
		
	
		
			
			| 
				654
			 | 
			
				659
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				655
			 | 
			
				660
			 | 
			
			
				
				             foreach( string prop in property.GetAllProperties()) 
			 | 
		
		
	
		
			
			| 
				656
			 | 
			
				661
			 | 
			
			
				
				             { 
			 | 
		
		
	
		
			
			| 
				657
			 | 
			
				
			 | 
			
			
				
				-                if (prop != "Item") 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				662
			 | 
			
			
				
				+                if (prop != "Item" && prop != "Display") 
			 | 
		
		
	
		
			
			| 
				658
			 | 
			
				663
			 | 
			
			
				
				                     property[prop] = items[prop]; 
			 | 
		
		
	
		
			
			| 
				659
			 | 
			
				664
			 | 
			
			
				
				             } 
			 | 
		
		
	
		
			
			| 
				660
			 | 
			
				665
			 | 
			
			
				
				  
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -668,14 +673,9 @@ namespace UnivateProperties_API.Repository.Properties 
			 | 
		
		
	
		
			
			| 
				668
			 | 
			
				673
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				669
			 | 
			
				674
			 | 
			
			
				
				             property.Video = property.Video.Replace("https://www.youtube.com/watch?v=", ""); 
			 | 
		
		
	
		
			
			| 
				670
			 | 
			
				675
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				671
			 | 
			
				
			 | 
			
			
				
				-            dBContext.Properties.Add(property); 
			 | 
		
		
	
		
			
			| 
				672
			 | 
			
				
			 | 
			
			
				
				-            Save(); 
			 | 
		
		
	
		
			
			| 
				673
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				674
			 | 
			
				676
			 | 
			
			
				
				             if (images != null) 
			 | 
		
		
	
		
			
			| 
				675
			 | 
			
				677
			 | 
			
			
				
				             { 
			 | 
		
		
	
		
			
			| 
				676
			 | 
			
				
			 | 
			
			
				
				-                var lastID = (from p in dBContext.PropertyImages 
			 | 
		
		
	
		
			
			| 
				677
			 | 
			
				
			 | 
			
			
				
				-                              orderby p.Id descending 
			 | 
		
		
	
		
			
			| 
				678
			 | 
			
				
			 | 
			
			
				
				-                              select p.Id).FirstOrDefault(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				678
			 | 
			
			
				
				+                var lastID = dBContext.GetMaxID("PropertyImages"); 
			 | 
		
		
	
		
			
			| 
				679
			 | 
			
				679
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				680
			 | 
			
				680
			 | 
			
			
				
				                 bool saveFiles = false; 
			 | 
		
		
	
		
			
			| 
				681
			 | 
			
				681
			 | 
			
			
				
				                 var loc = dBContext.Location.FirstOrDefault().PropertyImageLocation; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -689,6 +689,7 @@ namespace UnivateProperties_API.Repository.Properties 
			 | 
		
		
	
		
			
			| 
				689
			 | 
			
				689
			 | 
			
			
				
				                     } 
			 | 
		
		
	
		
			
			| 
				690
			 | 
			
				690
			 | 
			
			
				
				                 } 
			 | 
		
		
	
		
			
			| 
				691
			 | 
			
				691
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				692
			 | 
			
			
				
				+                property.PropertyImages = new List<PropertyImage>(); 
			 | 
		
		
	
		
			
			| 
				692
			 | 
			
				693
			 | 
			
			
				
				                 foreach (PropertyImage image in images) 
			 | 
		
		
	
		
			
			| 
				693
			 | 
			
				694
			 | 
			
			
				
				                 { 
			 | 
		
		
	
		
			
			| 
				694
			 | 
			
				695
			 | 
			
			
				
				                     lastID++; 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -699,26 +700,27 @@ namespace UnivateProperties_API.Repository.Properties 
			 | 
		
		
	
		
			
			| 
				699
			 | 
			
				700
			 | 
			
			
				
				                         string path = ImageFormatter.Base64ToImage(image.Image, loc, lastID.ToString()); 
			 | 
		
		
	
		
			
			| 
				700
			 | 
			
				701
			 | 
			
			
				
				                         image.Image = path; 
			 | 
		
		
	
		
			
			| 
				701
			 | 
			
				702
			 | 
			
			
				
				                     } 
			 | 
		
		
	
		
			
			| 
				702
			 | 
			
				
			 | 
			
			
				
				-                    dBContext.PropertyImages.Add(image); 
			 | 
		
		
	
		
			
			| 
				703
			 | 
			
				
			 | 
			
			
				
				-                    Save(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				703
			 | 
			
			
				
				+                    property.PropertyImages.Add(image); 
			 | 
		
		
	
		
			
			| 
				704
			 | 
			
				704
			 | 
			
			
				
				                 } 
			 | 
		
		
	
		
			
			| 
				705
			 | 
			
				705
			 | 
			
			
				
				             } 
			 | 
		
		
	
		
			
			| 
				706
			 | 
			
				706
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				707
			 | 
			
				707
			 | 
			
			
				
				             if (fields != null) 
			 | 
		
		
	
		
			
			| 
				708
			 | 
			
				708
			 | 
			
			
				
				             { 
			 | 
		
		
	
		
			
			| 
				709
			 | 
			
				
			 | 
			
			
				
				-                var lastID = (from p in dBContext.PropertyUserFields 
			 | 
		
		
	
		
			
			| 
				710
			 | 
			
				
			 | 
			
			
				
				-                              orderby p.Id descending 
			 | 
		
		
	
		
			
			| 
				711
			 | 
			
				
			 | 
			
			
				
				-                              select p.Id).FirstOrDefault(); 
			 | 
		
		
	
		
			
			| 
				712
			 | 
			
				
			 | 
			
			
				
				- 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				709
			 | 
			
			
				
				+                var lastID = dBContext.GetMaxID("PropertyUserFields"); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				710
			 | 
			
			
				
				+                property.PropertyUserFields = new List<PropertyUserField>(); 
			 | 
		
		
	
		
			
			| 
				713
			 | 
			
				711
			 | 
			
			
				
				                 foreach (PropertyUserField field in fields) 
			 | 
		
		
	
		
			
			| 
				714
			 | 
			
				712
			 | 
			
			
				
				                 { 
			 | 
		
		
	
		
			
			| 
				715
			 | 
			
				713
			 | 
			
			
				
				                     lastID++; 
			 | 
		
		
	
		
			
			| 
				716
			 | 
			
				714
			 | 
			
			
				
				                     field.Id = lastID; 
			 | 
		
		
	
		
			
			| 
				717
			 | 
			
				715
			 | 
			
			
				
				                     field.PropertyId = property.Id; 
			 | 
		
		
	
		
			
			| 
				718
			 | 
			
				
			 | 
			
			
				
				-                    dBContext.PropertyUserFields.Add(field); 
			 | 
		
		
	
		
			
			| 
				719
			 | 
			
				
			 | 
			
			
				
				-                    Save(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				716
			 | 
			
			
				
				+                    property.PropertyUserFields.Add(field); 
			 | 
		
		
	
		
			
			| 
				720
			 | 
			
				717
			 | 
			
			
				
				                 } 
			 | 
		
		
	
		
			
			| 
				721
			 | 
			
				718
			 | 
			
			
				
				             } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				719
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				720
			 | 
			
			
				
				+            dBContext.Properties.Add(property); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				721
			 | 
			
			
				
				+            Save(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				722
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				723
			 | 
			
			
				
				+            items.Id = property.Id;             
			 | 
		
		
	
		
			
			| 
				722
			 | 
			
				724
			 | 
			
			
				
				         } 
			 | 
		
		
	
		
			
			| 
				723
			 | 
			
				725
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				724
			 | 
			
				726
			 | 
			
			
				
				         public bool MayEdit(int id) 
			 | 
		
		
	
	
		
			
			| 
				
			 | 
			
			
				
				@@ -729,6 +731,45 @@ namespace UnivateProperties_API.Repository.Properties 
			 | 
		
		
	
		
			
			| 
				729
			 | 
			
				731
			 | 
			
			
				
				                                select b).FirstOrDefault(); 
			 | 
		
		
	
		
			
			| 
				730
			 | 
			
				732
			 | 
			
			
				
				  
			 | 
		
		
	
		
			
			| 
				731
			 | 
			
				733
			 | 
			
			
				
				             return (hasBidItems == null) ? true : false; 
			 | 
		
		
	
		
			
			| 
				732
			 | 
			
				
			 | 
			
			
				
				-        }                 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				734
			 | 
			
			
				
				+        } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				735
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				736
			 | 
			
			
				
				+        public void InsertImages(int propertyID, List<PropertyImage> Images) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				737
			 | 
			
			
				
				+        { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				738
			 | 
			
			
				
				+            if (Images != null) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				739
			 | 
			
			
				
				+            { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				740
			 | 
			
			
				
				+                var lastID = dBContext.GetMaxID("PropertyImages"); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				741
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				742
			 | 
			
			
				
				+                bool saveFiles = false; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				743
			 | 
			
			
				
				+                var loc = dBContext.Location.FirstOrDefault().PropertyImageLocation; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				744
			 | 
			
			
				
				+                if (!string.IsNullOrEmpty(loc)) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				745
			 | 
			
			
				
				+                { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				746
			 | 
			
			
				
				+                    saveFiles = true; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				747
			 | 
			
			
				
				+                    loc += string.Format("\\{0}", propertyID); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				748
			 | 
			
			
				
				+                    if (Directory.Exists(loc)) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				749
			 | 
			
			
				
				+                    { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				750
			 | 
			
			
				
				+                        Directory.CreateDirectory(loc); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				751
			 | 
			
			
				
				+                    } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				752
			 | 
			
			
				
				+                } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				753
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				754
			 | 
			
			
				
				+                foreach (PropertyImage image in Images) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				755
			 | 
			
			
				
				+                { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				756
			 | 
			
			
				
				+                    lastID++; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				757
			 | 
			
			
				
				+                    image.Id = lastID; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				758
			 | 
			
			
				
				+                    image.PropertyId = propertyID; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				759
			 | 
			
			
				
				+                    if (saveFiles) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				760
			 | 
			
			
				
				+                    { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				761
			 | 
			
			
				
				+                        string path = ImageFormatter.Base64ToImage(image.Image, loc, lastID.ToString()); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				762
			 | 
			
			
				
				+                        image.Image = path; 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				763
			 | 
			
			
				
				+                    } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				764
			 | 
			
			
				
				+                    dBContext.PropertyImages.Add(image); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				765
			 | 
			
			
				
				+                    Save(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				766
			 | 
			
			
				
				+                } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				767
			 | 
			
			
				
				+            } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				768
			 | 
			
			
				
				+        } 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				769
			 | 
			
			
				
				+ 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				770
			 | 
			
			
				
				+        public void InsertFields(int propertyID, List<PropertyUserField> Fields) 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				771
			 | 
			
			
				
				+        { 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				772
			 | 
			
			
				
				+            throw new NotImplementedException(); 
			 | 
		
		
	
		
			
			| 
				
			 | 
			
				773
			 | 
			
			
				
				+        } 
			 | 
		
		
	
		
			
			| 
				733
			 | 
			
				774
			 | 
			
			
				
				     } 
			 | 
		
		
	
		
			
			| 
				734
			 | 
			
				775
			 | 
			
			
				
				 } 
			 |