Pārlūkot izejas kodu

Carousel & Search WIP

master
George Williams 5 gadus atpakaļ
vecāks
revīzija
3d716e307a

+ 1
- 0
UnivateProperties_API/Containers/Property/PropertyList.cs Parādīt failu

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

+ 2
- 0
UnivateProperties_API/Containers/Regions/SuburbSearch.cs Parādīt failu

8
     public class SuburbSearch
8
     public class SuburbSearch
9
     {
9
     {
10
         public int Id { get; set; }
10
         public int Id { get; set; }
11
+        public string Province { get; set; }
12
+        public string City { get; set; }
11
         public string Suburb { get; set; }
13
         public string Suburb { get; set; }
12
         public string Display { get; set; }
14
         public string Display { get; set; }
13
     }
15
     }

+ 1
- 1
UnivateProperties_API/Context/DataContext.cs Parādīt failu

181
             modelBuilder.Entity<BidItem>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
181
             modelBuilder.Entity<BidItem>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
182
             modelBuilder.Entity<ProcessFlow>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
182
             modelBuilder.Entity<ProcessFlow>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
183
             modelBuilder.Entity<Template>().HasQueryFilter(m => EF.Property<bool>(m, "IsDeleted") == false);
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 Parādīt failu

1
 using Microsoft.EntityFrameworkCore;
1
 using Microsoft.EntityFrameworkCore;
2
 using System;
2
 using System;
3
 using System.Collections.Generic;
3
 using System.Collections.Generic;
4
+using System.IO;
4
 using System.Linq;
5
 using System.Linq;
5
 using UnivateProperties_API.Containers.Misc;
6
 using UnivateProperties_API.Containers.Misc;
6
 using UnivateProperties_API.Containers.Property;
7
 using UnivateProperties_API.Containers.Property;
56
 
57
 
57
         public void Insert(Carousel item)
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
             Save();
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
         public void Insert(IEnumerable<Carousel> items)
88
         public void Insert(IEnumerable<Carousel> items)

+ 6
- 5
UnivateProperties_API/Repository/Properties/PropertyRepository.cs Parādīt failu

561
             if (Type.ToUpper() == "MY")
561
             if (Type.ToUpper() == "MY")
562
             {                
562
             {                
563
                 if (individual != null)
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
                 if (agent != null)
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
569
             {
569
             {
570
                 if (individual != null)
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
                 if (agent != null)
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
             List<PropertyList> list = new List<PropertyList>();
576
             List<PropertyList> list = new List<PropertyList>();
583
                     Name = string.IsNullOrEmpty(p.PropertyName) ? p.ShortDescription : p.PropertyName,
583
                     Name = string.IsNullOrEmpty(p.PropertyName) ? p.ShortDescription : p.PropertyName,
584
                     Price = string.Format("R {0:n}", p.Price),
584
                     Price = string.Format("R {0:n}", p.Price),
585
                     Publish = p.Published.ToString(),
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
                 prop.Size = (from u in dBContext.PropertyUserFields
590
                 prop.Size = (from u in dBContext.PropertyUserFields

+ 3
- 1
UnivateProperties_API/Repository/Region/SuburbRepository.cs Parādīt failu

115
 
115
 
116
         public List<SuburbSearch> GetSearchList()
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
             List<SuburbSearch> searchList = new List<SuburbSearch>();
119
             List<SuburbSearch> searchList = new List<SuburbSearch>();
120
             
120
             
121
             foreach (var sub in suburbs)
121
             foreach (var sub in suburbs)
123
                 searchList.Add(new SuburbSearch()
123
                 searchList.Add(new SuburbSearch()
124
                 {
124
                 {
125
                     Id = sub.Id,
125
                     Id = sub.Id,
126
+                    Province = sub.City.Province.Description,
127
+                    City = sub.City.Description,
126
                     Suburb = sub.Description,
128
                     Suburb = sub.Description,
127
                     Display = string.Format("{0} - {1}", sub.Description, sub.City.Description)
129
                     Display = string.Format("{0} - {1}", sub.Description, sub.City.Description)
128
                 });
130
                 });

Notiek ielāde…
Atcelt
Saglabāt