Browse Source

Added API call for latest 3 properties

master
George Williams 5 years ago
parent
commit
8fcbcfaa84

+ 8
- 2
UnivateProperties_API/Controllers/Properties/PropertyController.cs View File

@@ -30,8 +30,8 @@ namespace UnivateProperties_API.Controllers.Properties
30 30
             return new OkObjectResult(_Repo.GetDetailed(x => x.Id == id));
31 31
         }
32 32
 
33
-        [HttpGet("search/{type}/{keyword}")]
34
-        public IActionResult Get(string type, string Keyword)
33
+        [HttpGet("search/{keyword}")]
34
+        public IActionResult Search(string Keyword)
35 35
         {
36 36
             return new OkObjectResult(_Repo.GetDisplay(Keyword));
37 37
         }
@@ -42,6 +42,12 @@ namespace UnivateProperties_API.Controllers.Properties
42 42
             return new OkObjectResult(_Repo.GetDisplay(type, propertyType, province, city, suburb, propType));
43 43
         }
44 44
 
45
+        [HttpGet("latestProperties")]
46
+        public IActionResult GetLatestProperties()
47
+        {
48
+            return new OkObjectResult(_Repo.GetLatestDisplay());
49
+        }
50
+
45 51
         [HttpGet("{type}/{by}")]
46 52
         public IActionResult SearchBy(string type, string by)
47 53
         {

+ 1
- 0
UnivateProperties_API/Repository/Properties/IPropertyRepository.cs View File

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

+ 6
- 0
UnivateProperties_API/Repository/Properties/PropertyRepository.cs View File

@@ -352,5 +352,11 @@ namespace UnivateProperties_API.Repository.Properties
352 352
 
353 353
             return list;
354 354
         }
355
+
356
+        public List<PropertyDisplay> GetLatestDisplay()
357
+        {
358
+            List<Property> props = GetAll().OrderBy(x => x.Created).Take(3).ToList();
359
+            return GetDisplayDetails(props);
360
+        }
355 361
     }
356 362
 }

Loading…
Cancel
Save