LeneS il y a 5 ans
Parent
révision
e221a4aeba

+ 1
- 0
UnivateProperties_API/Containers/Property/GroupFields.cs Voir le fichier

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

+ 8
- 0
UnivateProperties_API/Containers/Property/PropertyDetail.cs Voir le fichier

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
+    }
11
 }
19
 }

+ 8
- 0
UnivateProperties_API/Controllers/Properties/PropertyController.cs Voir le fichier

18
             _Repo = repo;
18
             _Repo = repo;
19
         }
19
         }
20
 
20
 
21
+        #region Get Methods
21
         [HttpGet]
22
         [HttpGet]
22
         public IActionResult Get()
23
         public IActionResult Get()
23
         {
24
         {
80
                 return new NoContentResult();
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
         [HttpPost]
91
         [HttpPost]
84
         public IActionResult Post([FromBody] Property property)
92
         public IActionResult Post([FromBody] Property property)
85
         {
93
         {

+ 6
- 0
UnivateProperties_API/Controllers/Properties/PropertyFieldsController.cs Voir le fichier

31
         {
31
         {
32
             return new OkObjectResult(_Repo.GetFieldListByPropType(type));
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 Voir le fichier

28
             return new OkObjectResult(_Repo.GetDetailed(x => x.Id == id));
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
         [HttpPost]
37
         [HttpPost]
32
         public IActionResult Post([FromBody] PropertyUserField propertyUserField)
38
         public IActionResult Post([FromBody] PropertyUserField propertyUserField)
33
         {
39
         {

+ 1
- 0
UnivateProperties_API/Repository/Properties/IPropertyRepository.cs Voir le fichier

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
     }
17
     }
17
 }
18
 }

+ 2
- 0
UnivateProperties_API/Repository/Properties/IUserDefinedGroupRepository.cs Voir le fichier

8
     {
8
     {
9
         List<Group> GetFieldList(string name);
9
         List<Group> GetFieldList(string name);
10
 
10
 
11
+        List<Group> GetFieldList(string propertyType, string name, int propertyID);
12
+
11
         List<Group> GetFieldListByPropType(string propertyType);
13
         List<Group> GetFieldListByPropType(string propertyType);
12
     }
14
     }
13
 }
15
 }

+ 14
- 0
UnivateProperties_API/Repository/Properties/PropertyRepository.cs Voir le fichier

358
             List<Property> props = GetAll().OrderBy(x => x.Created).Take(3).ToList();
358
             List<Property> props = GetAll().OrderBy(x => x.Created).Take(3).ToList();
359
             return GetDisplayDetails(props);
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 Voir le fichier

18
 
18
 
19
         public List<UserDefinedField> Get(Func<UserDefinedField, bool> where)
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
         public List<UserDefinedField> GetAll()
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
         public UserDefinedField GetDetailed(Func<UserDefinedField, bool> first)
29
         public UserDefinedField GetDetailed(Func<UserDefinedField, bool> first)

+ 24
- 2
UnivateProperties_API/Repository/Properties/UserDefinedGroupRepository.cs Voir le fichier

19
 
19
 
20
         public List<UserDefinedGroup> Get(Func<UserDefinedGroup, bool> where)
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
         public List<UserDefinedGroup> GetAll()
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
         public UserDefinedGroup GetDetailed(Func<UserDefinedGroup, bool> first)
30
         public UserDefinedGroup GetDetailed(Func<UserDefinedGroup, bool> first)
75
             return FieldGroups;
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
         public List<Group> GetFieldListByPropType(string propertyType)
100
         public List<Group> GetFieldListByPropType(string propertyType)
79
         {
101
         {
80
             List<Group> FieldGroups = new List<Group>();
102
             List<Group> FieldGroups = new List<Group>();

Chargement…
Annuler
Enregistrer