Преглед на файлове

Carousel & Search WIP

master
George Williams преди 5 години
родител
ревизия
3d716e307a

+ 1
- 0
UnivateProperties_API/Containers/Property/PropertyList.cs Целия файл

@@ -12,6 +12,7 @@
12 12
         public string SaleType { get; set; }
13 13
         public string Publish { get; set; }
14 14
         public string Status { get; set; }
15
+        public string CarouselDescription { get; set; }
15 16
         #endregion
16 17
     }
17 18
 }

+ 2
- 0
UnivateProperties_API/Containers/Regions/SuburbSearch.cs Целия файл

@@ -8,6 +8,8 @@ namespace UnivateProperties_API.Containers.Regions
8 8
     public class SuburbSearch
9 9
     {
10 10
         public int Id { get; set; }
11
+        public string Province { get; set; }
12
+        public string City { get; set; }
11 13
         public string Suburb { get; set; }
12 14
         public string Display { get; set; }
13 15
     }

+ 1
- 1
UnivateProperties_API/Context/DataContext.cs Целия файл

@@ -181,7 +181,7 @@ namespace UnivateProperties_API.Context
181 181
             modelBuilder.Entity<BidItem>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
182 182
             modelBuilder.Entity<ProcessFlow>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
183 183
             modelBuilder.Entity<Template>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
184
-
184
+            modelBuilder.Entity<Carousel>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
185 185
             
186 186
         }
187 187
 

+ 26
- 1
UnivateProperties_API/Repository/Misc/CarouselRepository.cs Целия файл

@@ -1,6 +1,7 @@
1 1
 using Microsoft.EntityFrameworkCore;
2 2
 using System;
3 3
 using System.Collections.Generic;
4
+using System.IO;
4 5
 using System.Linq;
5 6
 using UnivateProperties_API.Containers.Misc;
6 7
 using UnivateProperties_API.Containers.Property;
@@ -56,8 +57,32 @@ namespace UnivateProperties_API.Repository.Misc
56 57
 
57 58
         public void Insert(Carousel item)
58 59
         {
59
-            dBContext.Carousel.Add(item);
60
+            string image = item.Image;
61
+            item.Image = "";
62
+            dBContext.Add(item);
60 63
             Save();
64
+
65
+            bool saveFiles = false;
66
+            var loc = dBContext.Location.FirstOrDefault().PropertyImageLocation;
67
+            var lastID = item.Id;
68
+            item.Id = lastID;
69
+            if (!string.IsNullOrEmpty(loc))
70
+            {
71
+                saveFiles = true;
72
+                loc = loc.Replace("Properties", "Carousel");
73
+                if (Directory.Exists(loc))
74
+                {
75
+                    Directory.CreateDirectory(loc);
76
+                }
77
+            }
78
+            if (saveFiles)
79
+            {
80
+                string path = ImageFormatter.Base64ToImage(item.Image, loc, lastID.ToString());
81
+                item.Image = path;
82
+            }
83
+
84
+            Update(item);
85
+            
61 86
         }
62 87
 
63 88
         public void Insert(IEnumerable<Carousel> items)

+ 6
- 5
UnivateProperties_API/Repository/Properties/PropertyRepository.cs Целия файл

@@ -561,16 +561,16 @@ 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 568
             else
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 574
             }
575 575
             
576 576
             List<PropertyList> list = new List<PropertyList>();
@@ -583,7 +583,8 @@ namespace UnivateProperties_API.Repository.Properties
583 583
                     Name = string.IsNullOrEmpty(p.PropertyName) ? p.ShortDescription : p.PropertyName,
584 584
                     Price = string.Format("R {0:n}", p.Price),
585 585
                     Publish = p.Published.ToString(),
586
-                    Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description
586
+                    Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description,
587
+                    CarouselDescription = string.Format("{0}, {1} <br/>{2}", p.Suburb.Description, p.City.Description, p.AddressLine3)
587 588
                 };
588 589
 
589 590
                 prop.Size = (from u in dBContext.PropertyUserFields

+ 3
- 1
UnivateProperties_API/Repository/Region/SuburbRepository.cs Целия файл

@@ -115,7 +115,7 @@ namespace UnivateProperties_API.Repository.Region
115 115
 
116 116
         public List<SuburbSearch> GetSearchList()
117 117
         {
118
-            var suburbs = dBContext.Suburbs.Include("City").ToList();
118
+            var suburbs = dBContext.Suburbs.Include("City").Include("City.Province").ToList();
119 119
             List<SuburbSearch> searchList = new List<SuburbSearch>();
120 120
             
121 121
             foreach (var sub in suburbs)
@@ -123,6 +123,8 @@ namespace UnivateProperties_API.Repository.Region
123 123
                 searchList.Add(new SuburbSearch()
124 124
                 {
125 125
                     Id = sub.Id,
126
+                    Province = sub.City.Province.Description,
127
+                    City = sub.City.Description,
126 128
                     Suburb = sub.Description,
127 129
                     Display = string.Format("{0} - {1}", sub.Description, sub.City.Description)
128 130
                 });

Loading…
Отказ
Запис