Sfoglia il codice sorgente

Additional Fields on Individual

master
LeneS 5 anni fa
parent
commit
e1b790ced9

+ 0
- 8
UnivateProperties_API/Containers/Property/PropertyDetail.cs Vedi File

8
         public string Description { get; set; }
8
         public string Description { get; set; }
9
         #endregion 
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 Vedi File

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

+ 15
- 0
UnivateProperties_API/Containers/Property/PropertyList.cs Vedi File

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 Vedi File

7
 
7
 
8
 namespace UnivateProperties_API.Controllers.Properties
8
 namespace UnivateProperties_API.Controllers.Properties
9
 {
9
 {
10
-    [Route("Property/[controller]")]
10
+    [Route("api/[controller]")]
11
     [ApiController]
11
     [ApiController]
12
     public class PropertyController : ControllerBase
12
     public class PropertyController : ControllerBase
13
     {
13
     {
70
 
70
 
71
                 if (string.IsNullOrEmpty(by) || by.ToUpper() == "ALL")
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
                 else
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
             else
80
             else
84
         [HttpGet("GetEditDisplay/{id}")]
84
         [HttpGet("GetEditDisplay/{id}")]
85
         public IActionResult GetEditDisplay(int id)
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
         #endregion
89
         #endregion
90
 
90
 

+ 1
- 1
UnivateProperties_API/Controllers/Properties/PropertyFieldsController.cs Vedi File

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

+ 1
- 1
UnivateProperties_API/Controllers/Properties/PropertyImageController.cs Vedi File

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

+ 1
- 1
UnivateProperties_API/Controllers/Properties/PropertyTypeController.cs Vedi File

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

+ 1
- 1
UnivateProperties_API/Controllers/Properties/PropertyUserFieldController.cs Vedi File

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

+ 1
- 1
UnivateProperties_API/Controllers/Properties/UserDefinedFieldController.cs Vedi File

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

+ 1
- 1
UnivateProperties_API/Controllers/Properties/UserDefinedGroupController.cs Vedi File

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

+ 1
- 1
UnivateProperties_API/Controllers/Region/CityController.cs Vedi File

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

+ 1
- 1
UnivateProperties_API/Controllers/Region/ProvinceController.cs Vedi File

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

+ 1
- 1
UnivateProperties_API/Controllers/Region/SuburbController.cs Vedi File

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

+ 21
- 0
UnivateProperties_API/Model/ProcessFlow/ProcessFlow.cs Vedi File

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 Vedi File

2
 using System.ComponentModel.DataAnnotations.Schema;
2
 using System.ComponentModel.DataAnnotations.Schema;
3
 using UnivateProperties_API.Containers.Property;
3
 using UnivateProperties_API.Containers.Property;
4
 using UnivateProperties_API.Model.Region;
4
 using UnivateProperties_API.Model.Region;
5
+using UnivateProperties_API.Model.Timeshare;
6
+using UnivateProperties_API.Model.Users;
5
 
7
 
6
 namespace UnivateProperties_API.Model.Property
8
 namespace UnivateProperties_API.Model.Property
7
 {
9
 {
26
         public int CityId { get; set; }
28
         public int CityId { get; set; }
27
         public int ProvinceId { get; set; }
29
         public int ProvinceId { get; set; }
28
         public bool Published { get; set; }
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
         public virtual PropertyType PropertyType { get; set; }
36
         public virtual PropertyType PropertyType { get; set; }
31
         public virtual Province Province { get; set; }
37
         public virtual Province Province { get; set; }
32
         public virtual City City { get; set; }
38
         public virtual City City { get; set; }
33
         public virtual Suburb Suburb { get; set; }
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
         public ICollection<PropertyUserField> PropertyUserFields { get; set; }
45
         public ICollection<PropertyUserField> PropertyUserFields { get; set; }
36
         public ICollection<PropertyImage> PropertyImages { get; set; }
46
         public ICollection<PropertyImage> PropertyImages { get; set; }

+ 1
- 0
UnivateProperties_API/Model/Users/Agency.cs Vedi File

17
         public string CompanyRegNumber { get; set; }
17
         public string CompanyRegNumber { get; set; }
18
 
18
 
19
         public virtual ICollection<Agent> Agents { get; set; }
19
         public virtual ICollection<Agent> Agents { get; set; }
20
+        public virtual ICollection<Property.Property> Properties { get; set; }
20
         #endregion Properties
21
         #endregion Properties
21
     }
22
     }
22
 }
23
 }

+ 2
- 0
UnivateProperties_API/Model/Users/Agent.cs Vedi File

16
         [ForeignKey("Agency")]
16
         [ForeignKey("Agency")]
17
         public int? AgencyId { get; set; }
17
         public int? AgencyId { get; set; }
18
         public virtual Agency Agency { get; set; }
18
         public virtual Agency Agency { get; set; }
19
+
20
+        public virtual ICollection<Property.Property> Properties { get; set; }
19
         #endregion Properties
21
         #endregion Properties
20
     }
22
     }
21
 }
23
 }

+ 1
- 0
UnivateProperties_API/Model/Users/Individual.cs Vedi File

22
         public string IncomeTaxNumber { get; set; }
22
         public string IncomeTaxNumber { get; set; }
23
         public virtual Address Address { get; set; }
23
         public virtual Address Address { get; set; }
24
 
24
 
25
+        public virtual ICollection<Property.Property> Properties { get; set; }
25
         #endregion Properties
26
         #endregion Properties
26
     }
27
     }
27
 }
28
 }

+ 1
- 1
UnivateProperties_API/Repository/Properties/IPropertyRepository.cs Vedi File

13
         List<PropertyDisplay> GetDisplay(string type, string propertyType, string province, string city, string suburb, string propType);
13
         List<PropertyDisplay> GetDisplay(string type, string propertyType, string province, string city, string suburb, string propType);
14
         List<PropertyDisplay> GetLatestDisplay();
14
         List<PropertyDisplay> GetLatestDisplay();
15
         List<PropertyType> GetPropertyTypes(Func<PropertyType, bool> where);
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 Vedi File

121
             {
121
             {
122
                 if (pt.UsageType == PropertyUsageType.Residential)
122
                 if (pt.UsageType == PropertyUsageType.Residential)
123
                 {
123
                 {
124
+                    string type = dBContext.PropertyTypes.Find(item.PropertyTypeId).Description;
124
                     if (item.PropertyUserFields.Count > 0)
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
                         UserDefinedField bedrooms = dBContext.UserDefinedFields.Where(u => u.FieldName == "Bedrooms").FirstOrDefault();
128
                         UserDefinedField bedrooms = dBContext.UserDefinedFields.Where(u => u.FieldName == "Bedrooms").FirstOrDefault();
129
                         var udValue = item.PropertyUserFields.Where(u => u.UserDefinedFieldId == bedrooms.Id).FirstOrDefault();
129
                         var udValue = item.PropertyUserFields.Where(u => u.UserDefinedFieldId == bedrooms.Id).FirstOrDefault();
130
                         if (udValue != null)
130
                         if (udValue != null)
132
                         else
132
                         else
133
                             item.ShortDescription = string.Format(shortDesc, "", "", pt.Description).Trim();
133
                             item.ShortDescription = string.Format(shortDesc, "", "", pt.Description).Trim();
134
                     }
134
                     }
135
+                    else
136
+                    {
137
+                        item.ShortDescription = type;
138
+                    }
135
                 }
139
                 }
136
                 else
140
                 else
137
                 {
141
                 {
327
                             select c.Description).FirstOrDefault(),
331
                             select c.Description).FirstOrDefault(),
328
                     Suburb = (from s in dBContext.Suburbs
332
                     Suburb = (from s in dBContext.Suburbs
329
                               where s.Id == item.SuburbId
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
                 if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
339
                 if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
359
             return GetDisplayDetails(props);
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
 }

Loading…
Annulla
Salva