|
@@ -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
|
|
|
@@ -565,13 +565,17 @@ namespace UnivateProperties_API.Repository.Properties
|
565
|
565
|
if (agent != null)
|
566
|
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
|
571
|
properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.OwnerId == individual.Id).ToList();
|
572
|
572
|
if (agent != null)
|
573
|
573
|
properties = dBContext.Properties.Include("City").Include("Suburb").Where(x => x.AgencyId == agent.AgencyId).ToList();
|
574
|
574
|
}
|
|
575
|
+ else if (Type.ToUpper() == "SUPERADMIN")
|
|
576
|
+ {
|
|
577
|
+ properties = dBContext.Properties.Include("City").Include("Suburb").ToList();
|
|
578
|
+ }
|
575
|
579
|
|
576
|
580
|
List<PropertyList> list = new List<PropertyList>();
|
577
|
581
|
|
|
@@ -655,7 +659,7 @@ namespace UnivateProperties_API.Repository.Properties
|
655
|
659
|
|
656
|
660
|
foreach( string prop in property.GetAllProperties())
|
657
|
661
|
{
|
658
|
|
- if (prop != "Item")
|
|
662
|
+ if (prop != "Item" && prop != "Display")
|
659
|
663
|
property[prop] = items[prop];
|
660
|
664
|
}
|
661
|
665
|
|
|
@@ -669,14 +673,9 @@ namespace UnivateProperties_API.Repository.Properties
|
669
|
673
|
|
670
|
674
|
property.Video = property.Video.Replace("https://www.youtube.com/watch?v=", "");
|
671
|
675
|
|
672
|
|
- dBContext.Properties.Add(property);
|
673
|
|
- Save();
|
674
|
|
-
|
675
|
676
|
if (images != null)
|
676
|
677
|
{
|
677
|
|
- var lastID = (from p in dBContext.PropertyImages
|
678
|
|
- orderby p.Id descending
|
679
|
|
- select p.Id).FirstOrDefault();
|
|
678
|
+ var lastID = dBContext.GetMaxID("PropertyImages");
|
680
|
679
|
|
681
|
680
|
bool saveFiles = false;
|
682
|
681
|
var loc = dBContext.Location.FirstOrDefault().PropertyImageLocation;
|
|
@@ -690,6 +689,7 @@ namespace UnivateProperties_API.Repository.Properties
|
690
|
689
|
}
|
691
|
690
|
}
|
692
|
691
|
|
|
692
|
+ property.PropertyImages = new List<PropertyImage>();
|
693
|
693
|
foreach (PropertyImage image in images)
|
694
|
694
|
{
|
695
|
695
|
lastID++;
|
|
@@ -700,26 +700,27 @@ namespace UnivateProperties_API.Repository.Properties
|
700
|
700
|
string path = ImageFormatter.Base64ToImage(image.Image, loc, lastID.ToString());
|
701
|
701
|
image.Image = path;
|
702
|
702
|
}
|
703
|
|
- dBContext.PropertyImages.Add(image);
|
704
|
|
- Save();
|
|
703
|
+ property.PropertyImages.Add(image);
|
705
|
704
|
}
|
706
|
705
|
}
|
707
|
706
|
|
708
|
707
|
if (fields != null)
|
709
|
708
|
{
|
710
|
|
- var lastID = (from p in dBContext.PropertyUserFields
|
711
|
|
- orderby p.Id descending
|
712
|
|
- select p.Id).FirstOrDefault();
|
713
|
|
-
|
|
709
|
+ var lastID = dBContext.GetMaxID("PropertyUserFields");
|
|
710
|
+ property.PropertyUserFields = new List<PropertyUserField>();
|
714
|
711
|
foreach (PropertyUserField field in fields)
|
715
|
712
|
{
|
716
|
713
|
lastID++;
|
717
|
714
|
field.Id = lastID;
|
718
|
715
|
field.PropertyId = property.Id;
|
719
|
|
- dBContext.PropertyUserFields.Add(field);
|
720
|
|
- Save();
|
|
716
|
+ property.PropertyUserFields.Add(field);
|
721
|
717
|
}
|
722
|
718
|
}
|
|
719
|
+
|
|
720
|
+ dBContext.Properties.Add(property);
|
|
721
|
+ Save();
|
|
722
|
+
|
|
723
|
+ items.Id = property.Id;
|
723
|
724
|
}
|
724
|
725
|
|
725
|
726
|
public bool MayEdit(int id)
|
|
@@ -730,6 +731,45 @@ namespace UnivateProperties_API.Repository.Properties
|
730
|
731
|
select b).FirstOrDefault();
|
731
|
732
|
|
732
|
733
|
return (hasBidItems == null) ? true : false;
|
733
|
|
- }
|
|
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
|
+ }
|
734
|
774
|
}
|
735
|
775
|
}
|