Ver código fonte

Additional Fields on Individual

master
LeneS 5 anos atrás
pai
commit
e1b790ced9

+ 0
- 8
UnivateProperties_API/Containers/Property/PropertyDetail.cs Ver arquivo

@@ -8,12 +8,4 @@
8 8
         public string Description { get; set; }
9 9
         #endregion 
10 10
     }
11
-
12
-    public class PropertyEditDetails
13
-    {
14
-        #region Properties
15
-        public string PropertyType { get; set; }
16
-        public string SaleType { get; set; }
17
-        #endregion
18
-    }
19 11
 }

+ 5
- 1
UnivateProperties_API/Containers/Property/PropertyDisplay.cs Ver arquivo

@@ -1,4 +1,6 @@
1
-namespace UnivateProperties_API.Containers.Property
1
+using System;
2
+
3
+namespace UnivateProperties_API.Containers.Property
2 4
 {
3 5
     public class PropertyDisplay
4 6
     {
@@ -27,6 +29,8 @@
27 29
         public string City { get; set; }
28 30
         public string Suburb { get; set; }
29 31
         public string DisplayImage { get; set; }
32
+        public decimal Price { get; set; }
33
+        public DateTime DateCreated { get; set; }
30 34
         #endregion 
31 35
     }
32 36
 }

+ 15
- 0
UnivateProperties_API/Containers/Property/PropertyList.cs Ver arquivo

@@ -0,0 +1,15 @@
1
+namespace UnivateProperties_API.Containers.Property
2
+{
3
+    public class PropertyList
4
+    {
5
+        #region Properties
6
+        public string Name { get; set; }
7
+        public int Id { get; set; }
8
+        public string Size { get; set; }
9
+        public string Price { get; set; }
10
+        public string Type { get; set; }
11
+        public string Publish { get; set; }
12
+        public string Status { get; set; }
13
+        #endregion
14
+    }
15
+}

+ 4
- 4
UnivateProperties_API/Controllers/Properties/PropertyController.cs Ver arquivo

@@ -7,7 +7,7 @@ using UnivateProperties_API.Repository.Properties;
7 7
 
8 8
 namespace UnivateProperties_API.Controllers.Properties
9 9
 {
10
-    [Route("Property/[controller]")]
10
+    [Route("api/[controller]")]
11 11
     [ApiController]
12 12
     public class PropertyController : ControllerBase
13 13
     {
@@ -70,11 +70,11 @@ namespace UnivateProperties_API.Controllers.Properties
70 70
 
71 71
                 if (string.IsNullOrEmpty(by) || by.ToUpper() == "ALL")
72 72
                 {
73
-                    return new OkObjectResult(_Repo.Get(x => proptypeIds.Contains(x.PropertyTypeId)));
73
+                    return new OkObjectResult(_Repo.GetPropertyList(x => proptypeIds.Contains(x.PropertyTypeId)));
74 74
                 }
75 75
                 else
76 76
                 {
77
-                    return new OkObjectResult(_Repo.Get(x => proptypeIds.Contains(x.PropertyTypeId) && x.CreatedBy == by));
77
+                    return new OkObjectResult(_Repo.GetPropertyList(x => proptypeIds.Contains(x.PropertyTypeId) && x.CreatedBy == by));
78 78
                 }
79 79
             }
80 80
             else
@@ -84,7 +84,7 @@ namespace UnivateProperties_API.Controllers.Properties
84 84
         [HttpGet("GetEditDisplay/{id}")]
85 85
         public IActionResult GetEditDisplay(int id)
86 86
         {
87
-            return new OkObjectResult(_Repo.GetEditDisplay(x => x.Id == id));
87
+            return new OkObjectResult(_Repo.GetPropertyList(x => x.Id == id));
88 88
         }
89 89
         #endregion
90 90
 

+ 1
- 1
UnivateProperties_API/Controllers/Properties/PropertyFieldsController.cs Ver arquivo

@@ -3,7 +3,7 @@ using UnivateProperties_API.Repository.Properties;
3 3
 
4 4
 namespace UnivateProperties_API.Controllers.Properties
5 5
 {
6
-    [Route("Property/[controller]")]
6
+    [Route("api/[controller]")]
7 7
     [ApiController]
8 8
     public class PropertyFieldsController : ControllerBase
9 9
     {

+ 1
- 1
UnivateProperties_API/Controllers/Properties/PropertyImageController.cs Ver arquivo

@@ -5,7 +5,7 @@ using UnivateProperties_API.Repository.Properties;
5 5
 
6 6
 namespace UnivateProperties_API.Controllers.Properties
7 7
 {
8
-    [Route("Property/[controller]")]
8
+    [Route("api/[controller]")]
9 9
     [ApiController]
10 10
     public class PropertyImageController : ControllerBase
11 11
     {

+ 1
- 1
UnivateProperties_API/Controllers/Properties/PropertyTypeController.cs Ver arquivo

@@ -5,7 +5,7 @@ using UnivateProperties_API.Repository;
5 5
 
6 6
 namespace UnivateProperties_API.Controllers.Properties
7 7
 {
8
-    [Route("Property/[controller]")]
8
+    [Route("api/[controller]")]
9 9
     [ApiController]
10 10
     public class PropertyTypeController : ControllerBase
11 11
     {

+ 1
- 1
UnivateProperties_API/Controllers/Properties/PropertyUserFieldController.cs Ver arquivo

@@ -5,7 +5,7 @@ using UnivateProperties_API.Repository;
5 5
 
6 6
 namespace UnivateProperties_API.Controllers.Properties
7 7
 {
8
-    [Route("Property/[controller]")]
8
+    [Route("api/[controller]")]
9 9
     [ApiController]
10 10
     public class PropertyUserFieldController : ControllerBase
11 11
     {

+ 1
- 1
UnivateProperties_API/Controllers/Properties/UserDefinedFieldController.cs Ver arquivo

@@ -5,7 +5,7 @@ using UnivateProperties_API.Repository;
5 5
 
6 6
 namespace UnivateProperties_API.Controllers.Properties
7 7
 {
8
-    [Route("Property/[controller]")]
8
+    [Route("api/[controller]")]
9 9
     [ApiController]
10 10
     public class UserDefinedFieldController : ControllerBase
11 11
     {

+ 1
- 1
UnivateProperties_API/Controllers/Properties/UserDefinedGroupController.cs Ver arquivo

@@ -5,7 +5,7 @@ using UnivateProperties_API.Repository.Properties;
5 5
 
6 6
 namespace UnivateProperties_API.Controllers.Properties
7 7
 {
8
-    [Route("Property/[controller]")]
8
+    [Route("api/[controller]")]
9 9
     [ApiController]
10 10
     public class UserDefinedGroupController : ControllerBase
11 11
     {

+ 1
- 1
UnivateProperties_API/Controllers/Region/CityController.cs Ver arquivo

@@ -5,7 +5,7 @@ using UnivateProperties_API.Repository.Region;
5 5
 
6 6
 namespace UnivateProperties_API.Controllers.Region
7 7
 {
8
-    [Route("Region/[controller]")]
8
+    [Route("api/[controller]")]
9 9
     [ApiController]
10 10
     public class CityController : ControllerBase
11 11
     {

+ 1
- 1
UnivateProperties_API/Controllers/Region/ProvinceController.cs Ver arquivo

@@ -5,7 +5,7 @@ using UnivateProperties_API.Repository;
5 5
 
6 6
 namespace UnivateProperties_API.Controllers.Region
7 7
 {
8
-    [Route("Region/[controller]")]
8
+    [Route("api/[controller]")]
9 9
     [ApiController]
10 10
     public class ProvinceController : ControllerBase
11 11
     {

+ 1
- 1
UnivateProperties_API/Controllers/Region/SuburbController.cs Ver arquivo

@@ -5,7 +5,7 @@ using UnivateProperties_API.Repository.Region;
5 5
 
6 6
 namespace UnivateProperties_API.Controllers.Region
7 7
 {
8
-    [Route("Region/[controller]")]
8
+    [Route("api/[controller]")]
9 9
     [ApiController]
10 10
     public class SuburbController : ControllerBase
11 11
     {

+ 21
- 0
UnivateProperties_API/Model/ProcessFlow/ProcessFlow.cs Ver arquivo

@@ -0,0 +1,21 @@
1
+using UnivateProperties_API.Model.Timeshare;
2
+
3
+namespace UnivateProperties_API.Model.ProcessFlow
4
+{
5
+    public class ProcessFlow : BaseEntity
6
+    {
7
+        public int? TimeshareID { get; set; }
8
+        public int? PropertyID { get; set; }
9
+        public int StatusID { get; set; }
10
+
11
+
12
+        public virtual TimeshareWeek Timeshare { get; set; }
13
+        public virtual Property.Property Property { get; set; }
14
+        public virtual Status Status { get; set; }
15
+
16
+        public override string ToString()
17
+        {
18
+            return $"{(TimeshareID ?? PropertyID).Value} - {Status?.Code}";
19
+        }
20
+    }
21
+}

+ 10
- 0
UnivateProperties_API/Model/Property/Property.cs Ver arquivo

@@ -2,6 +2,8 @@
2 2
 using System.ComponentModel.DataAnnotations.Schema;
3 3
 using UnivateProperties_API.Containers.Property;
4 4
 using UnivateProperties_API.Model.Region;
5
+using UnivateProperties_API.Model.Timeshare;
6
+using UnivateProperties_API.Model.Users;
5 7
 
6 8
 namespace UnivateProperties_API.Model.Property
7 9
 {
@@ -26,11 +28,19 @@ namespace UnivateProperties_API.Model.Property
26 28
         public int CityId { get; set; }
27 29
         public int ProvinceId { get; set; }
28 30
         public bool Published { get; set; }
31
+        public int? StatusId { get; set; }
32
+        public int? OwnerId { get; set; }
33
+        public int? AgentId { get; set; }
34
+        public int? AgencyId { get; set; }
29 35
 
30 36
         public virtual PropertyType PropertyType { get; set; }
31 37
         public virtual Province Province { get; set; }
32 38
         public virtual City City { get; set; }
33 39
         public virtual Suburb Suburb { get; set; }
40
+        public virtual Status Status { get; set; }
41
+        public virtual Individual Owner { get; set; }
42
+        public virtual Agent Agent { get; set; }
43
+        public virtual Agency Agency { get; set; }
34 44
 
35 45
         public ICollection<PropertyUserField> PropertyUserFields { get; set; }
36 46
         public ICollection<PropertyImage> PropertyImages { get; set; }

+ 1
- 0
UnivateProperties_API/Model/Users/Agency.cs Ver arquivo

@@ -17,6 +17,7 @@ namespace UnivateProperties_API.Model.Users
17 17
         public string CompanyRegNumber { get; set; }
18 18
 
19 19
         public virtual ICollection<Agent> Agents { get; set; }
20
+        public virtual ICollection<Property.Property> Properties { get; set; }
20 21
         #endregion Properties
21 22
     }
22 23
 }

+ 2
- 0
UnivateProperties_API/Model/Users/Agent.cs Ver arquivo

@@ -16,6 +16,8 @@ namespace UnivateProperties_API.Model.Users
16 16
         [ForeignKey("Agency")]
17 17
         public int? AgencyId { get; set; }
18 18
         public virtual Agency Agency { get; set; }
19
+
20
+        public virtual ICollection<Property.Property> Properties { get; set; }
19 21
         #endregion Properties
20 22
     }
21 23
 }

+ 1
- 0
UnivateProperties_API/Model/Users/Individual.cs Ver arquivo

@@ -22,6 +22,7 @@ namespace UnivateProperties_API.Model.Users
22 22
         public string IncomeTaxNumber { get; set; }
23 23
         public virtual Address Address { get; set; }
24 24
 
25
+        public virtual ICollection<Property.Property> Properties { get; set; }
25 26
         #endregion Properties
26 27
     }
27 28
 }

+ 1
- 1
UnivateProperties_API/Repository/Properties/IPropertyRepository.cs Ver arquivo

@@ -13,6 +13,6 @@ namespace UnivateProperties_API.Repository.Properties
13 13
         List<PropertyDisplay> GetDisplay(string type, string propertyType, string province, string city, string suburb, string propType);
14 14
         List<PropertyDisplay> GetLatestDisplay();
15 15
         List<PropertyType> GetPropertyTypes(Func<PropertyType, bool> where);
16
-        PropertyEditDetails GetEditDisplay(Func<Property, bool> where);
16
+        List<PropertyList> GetPropertyList(Func<Property, bool> where);
17 17
     }
18 18
 }

+ 37
- 12
UnivateProperties_API/Repository/Properties/PropertyRepository.cs Ver arquivo

@@ -121,10 +121,10 @@ namespace UnivateProperties_API.Repository.Properties
121 121
             {
122 122
                 if (pt.UsageType == PropertyUsageType.Residential)
123 123
                 {
124
+                    string type = dBContext.PropertyTypes.Find(item.PropertyTypeId).Description;
124 125
                     if (item.PropertyUserFields.Count > 0)
125 126
                     {
126
-                        string shortDesc = "{0} {1} {2}";
127
-                        string type = dBContext.PropertyTypes.Find(item.PropertyTypeId).Description;
127
+                        string shortDesc = "{0} {1} {2}";                        
128 128
                         UserDefinedField bedrooms = dBContext.UserDefinedFields.Where(u => u.FieldName == "Bedrooms").FirstOrDefault();
129 129
                         var udValue = item.PropertyUserFields.Where(u => u.UserDefinedFieldId == bedrooms.Id).FirstOrDefault();
130 130
                         if (udValue != null)
@@ -132,6 +132,10 @@ namespace UnivateProperties_API.Repository.Properties
132 132
                         else
133 133
                             item.ShortDescription = string.Format(shortDesc, "", "", pt.Description).Trim();
134 134
                     }
135
+                    else
136
+                    {
137
+                        item.ShortDescription = type;
138
+                    }
135 139
                 }
136 140
                 else
137 141
                 {
@@ -327,8 +331,9 @@ namespace UnivateProperties_API.Repository.Properties
327 331
                             select c.Description).FirstOrDefault(),
328 332
                     Suburb = (from s in dBContext.Suburbs
329 333
                               where s.Id == item.SuburbId
330
-                              select s.Description).FirstOrDefault()
331
-
334
+                              select s.Description).FirstOrDefault(),
335
+                    Price = item.Price,
336
+                    DateCreated = item.Created
332 337
                 };
333 338
 
334 339
                 if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
@@ -359,18 +364,38 @@ namespace UnivateProperties_API.Repository.Properties
359 364
             return GetDisplayDetails(props);
360 365
         }
361 366
 
362
-        public PropertyEditDetails GetEditDisplay(Func<Property, bool> where)
367
+        public List<PropertyList> GetPropertyList(Func<Property, bool> where)
363 368
         {
364
-            var property = dBContext.Properties.Include("PropertyType").Where(where).FirstOrDefault();
365
-            PropertyEditDetails details = new PropertyEditDetails();
369
+            var properties = Get(where);
366 370
 
367
-            if (property != null)
371
+            List<PropertyList> list = new List<PropertyList>();
372
+
373
+            foreach (Property p in properties)
368 374
             {
369
-                details.SaleType = property.IsSale ? "Sale" : "Rental";
370
-                details.PropertyType = property.PropertyType.UsageType.ToString();
371
-            }
375
+                var prop = new PropertyList()
376
+                {
377
+                    Id = p.Id,
378
+                    Name = string.IsNullOrEmpty(p.PropertyName) ? p.ShortDescription : p.PropertyName,
379
+                    Price = string.Format("R {0:n}", p.Price),
380
+                    Publish = p.Published.ToString(),
381
+                    Type = dBContext.PropertyTypes.Find(p.PropertyTypeId)?.Description
382
+                };
372 383
 
373
-            return details;
384
+                prop.Size = (from u in dBContext.PropertyUserFields
385
+                             join f in dBContext.UserDefinedFields on u.UserDefinedFieldId equals f.Id
386
+                             where u.PropertyId == p.Id
387
+                             && f.FieldName == "Floor Size"
388
+                             select u.Value).FirstOrDefault();
389
+
390
+                if (!string.IsNullOrEmpty(prop.Size) && prop.Size.EndsWith("2"))
391
+                {
392
+                    prop.Size = prop.Size.Substring(0, prop.Size.Length - 1) + "<sup>" + prop.Size.Last() + "</sup>";
393
+                }
394
+
395
+                list.Add(prop);
396
+            }
397
+                
398
+            return list;
374 399
         }
375 400
     }
376 401
 }

Carregando…
Cancelar
Salvar