LeneS vor 5 Jahren
Ursprung
Commit
e221a4aeba

+ 1
- 0
UnivateProperties_API/Containers/Property/GroupFields.cs Datei anzeigen

@@ -6,6 +6,7 @@
6 6
         public int ID { get; set; }
7 7
         public string Name { get; set; }
8 8
         public string Type { get; set; }
9
+        public string Value { get; set; }
9 10
         #endregion
10 11
     }
11 12
 }

+ 8
- 0
UnivateProperties_API/Containers/Property/PropertyDetail.cs Datei anzeigen

@@ -8,4 +8,12 @@
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
+    }
11 19
 }

+ 8
- 0
UnivateProperties_API/Controllers/Properties/PropertyController.cs Datei anzeigen

@@ -18,6 +18,7 @@ namespace UnivateProperties_API.Controllers.Properties
18 18
             _Repo = repo;
19 19
         }
20 20
 
21
+        #region Get Methods
21 22
         [HttpGet]
22 23
         public IActionResult Get()
23 24
         {
@@ -80,6 +81,13 @@ namespace UnivateProperties_API.Controllers.Properties
80 81
                 return new NoContentResult();
81 82
         }
82 83
 
84
+        [HttpGet("GetEditDisplay/{id}")]
85
+        public IActionResult GetEditDisplay(int id)
86
+        {
87
+            return new OkObjectResult(_Repo.GetEditDisplay(x => x.Id == id));
88
+        }
89
+        #endregion
90
+
83 91
         [HttpPost]
84 92
         public IActionResult Post([FromBody] Property property)
85 93
         {

+ 6
- 0
UnivateProperties_API/Controllers/Properties/PropertyFieldsController.cs Datei anzeigen

@@ -31,6 +31,12 @@ namespace UnivateProperties_API.Controllers.Properties
31 31
         {
32 32
             return new OkObjectResult(_Repo.GetFieldListByPropType(type));
33 33
         }
34
+
35
+        [HttpGet("GetSavedValues/{propertyType}/{name}/{id}")]
36
+        public IActionResult GetSavedValues(string propertyType, string name, int id)
37
+        {
38
+            return new OkObjectResult(_Repo.GetFieldList(propertyType, name, id));
39
+        }
34 40
     }
35 41
 
36 42
 

+ 6
- 0
UnivateProperties_API/Controllers/Properties/PropertyUserFieldController.cs Datei anzeigen

@@ -28,6 +28,12 @@ namespace UnivateProperties_API.Controllers.Properties
28 28
             return new OkObjectResult(_Repo.GetDetailed(x => x.Id == id));
29 29
         }
30 30
 
31
+        [HttpGet("PropertyFields/{id}")]
32
+        public IActionResult GetPropertyFields(int id)
33
+        {
34
+            return new OkObjectResult(_Repo.Get(x => x.PropertyId == id));
35
+        }
36
+
31 37
         [HttpPost]
32 38
         public IActionResult Post([FromBody] PropertyUserField propertyUserField)
33 39
         {

+ 1
- 0
UnivateProperties_API/Repository/Properties/IPropertyRepository.cs Datei anzeigen

@@ -13,5 +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 17
     }
17 18
 }

+ 2
- 0
UnivateProperties_API/Repository/Properties/IUserDefinedGroupRepository.cs Datei anzeigen

@@ -8,6 +8,8 @@ namespace UnivateProperties_API.Repository.Properties
8 8
     {
9 9
         List<Group> GetFieldList(string name);
10 10
 
11
+        List<Group> GetFieldList(string propertyType, string name, int propertyID);
12
+
11 13
         List<Group> GetFieldListByPropType(string propertyType);
12 14
     }
13 15
 }

+ 14
- 0
UnivateProperties_API/Repository/Properties/PropertyRepository.cs Datei anzeigen

@@ -358,5 +358,19 @@ namespace UnivateProperties_API.Repository.Properties
358 358
             List<Property> props = GetAll().OrderBy(x => x.Created).Take(3).ToList();
359 359
             return GetDisplayDetails(props);
360 360
         }
361
+
362
+        public PropertyEditDetails GetEditDisplay(Func<Property, bool> where)
363
+        {
364
+            var property = dBContext.Properties.Include("PropertyType").Where(where).FirstOrDefault();
365
+            PropertyEditDetails details = new PropertyEditDetails();
366
+
367
+            if (property != null)
368
+            {
369
+                details.SaleType = property.IsSale ? "Sale" : "Rental";
370
+                details.PropertyType = property.PropertyType.UsageType.ToString();
371
+            }
372
+
373
+            return details;
374
+        }
361 375
     }
362 376
 }

+ 2
- 2
UnivateProperties_API/Repository/Properties/UserDefinedFieldRepository.cs Datei anzeigen

@@ -18,12 +18,12 @@ namespace UnivateProperties_API.Repository.Properties
18 18
 
19 19
         public List<UserDefinedField> Get(Func<UserDefinedField, bool> where)
20 20
         {
21
-            return dBContext.UserDefinedFields.Where(where).ToList();
21
+            return dBContext.UserDefinedFields.Where(where).OrderBy(x => x.Rank).ToList();
22 22
         }
23 23
 
24 24
         public List<UserDefinedField> GetAll()
25 25
         {
26
-            return dBContext.UserDefinedFields.ToList();
26
+            return dBContext.UserDefinedFields.OrderBy(x => x.Rank).ToList();
27 27
         }
28 28
 
29 29
         public UserDefinedField GetDetailed(Func<UserDefinedField, bool> first)

+ 24
- 2
UnivateProperties_API/Repository/Properties/UserDefinedGroupRepository.cs Datei anzeigen

@@ -19,12 +19,12 @@ namespace UnivateProperties_API.Repository.Properties
19 19
 
20 20
         public List<UserDefinedGroup> Get(Func<UserDefinedGroup, bool> where)
21 21
         {
22
-            return dBContext.UserDefinedGroups.Where(where).ToList();
22
+            return dBContext.UserDefinedGroups.Where(where).OrderBy(x => x.Rank).ToList();
23 23
         }
24 24
 
25 25
         public List<UserDefinedGroup> GetAll()
26 26
         {
27
-            return dBContext.UserDefinedGroups.ToList();
27
+            return dBContext.UserDefinedGroups.OrderBy(x => x.Rank).ToList();
28 28
         }
29 29
 
30 30
         public UserDefinedGroup GetDetailed(Func<UserDefinedGroup, bool> first)
@@ -75,6 +75,28 @@ namespace UnivateProperties_API.Repository.Properties
75 75
             return FieldGroups;
76 76
         }
77 77
 
78
+        public List<Group> GetFieldList(string propertyType, string name, int propertyID)
79
+        {
80
+            List<Group> FieldGroups = GetFieldList(name);
81
+            if (name == "Property Overview")
82
+                FieldGroups = GetFieldList(name);
83
+            else
84
+                FieldGroups = GetFieldListByPropType(propertyType);
85
+
86
+            var savedValues = dBContext.PropertyUserFields.Where(x => x.PropertyId == propertyID).ToList();
87
+            foreach (Group group in FieldGroups)
88
+            {
89
+                foreach(GroupFields field in group.Fields)
90
+                {
91
+                    var item = savedValues.Find(x => x.UserDefinedFieldId == field.ID);
92
+                    if (item != null)
93
+                        field.Value = item.Value;
94
+                }
95
+            }
96
+
97
+            return FieldGroups;
98
+        }
99
+
78 100
         public List<Group> GetFieldListByPropType(string propertyType)
79 101
         {
80 102
             List<Group> FieldGroups = new List<Group>();

Laden…
Abbrechen
Speichern