| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 | 
							- using Microsoft.AspNetCore.Mvc;
 - using System;
 - using System.Collections.Generic;
 - using System.Linq;
 - using System.Transactions;
 - using UnivateProperties_API.Containers.Property;
 - using UnivateProperties_API.Model.Properties;
 - using UnivateProperties_API.Repository.Properties;
 - 
 - namespace UnivateProperties_API.Controllers.Properties
 - {
 -     [Route("api/[controller]")]
 -     [ApiController]
 -     public class PropertyController : ControllerBase
 -     {
 -         private readonly IPropertyRepository _Repo;
 - 
 -         public PropertyController(IPropertyRepository repo)
 -         {
 -             _Repo = repo;
 -         }
 - 
 -         #region Get Methods
 -         [HttpGet]
 -         public IActionResult Get()
 -         {
 -             return new OkObjectResult(_Repo.GetDisplay());
 -         }
 - 
 -         [HttpGet("getDetailed/{id}")]
 -         public IActionResult GetDetailed(int id)
 -         {
 -             return new OkObjectResult(_Repo.GetDetailed(id, true));
 -         }
 - 
 -         [HttpGet("getProperty/{id}")]
 -         public IActionResult GetProperty(int id)
 -         {
 -             return new OkObjectResult(_Repo.GetDetailed(id, false));
 -         }
 - 
 -         [HttpGet("latestProperties")]
 -         public IActionResult GetLatestProperties()
 -         {
 -             return new OkObjectResult(_Repo.GetLatestDisplay());
 -         }
 - 
 -         [HttpGet("GetPropertyList/{by}")]
 -         public IActionResult SearchBy(int by)
 -         {
 -             return new OkObjectResult(_Repo.GetPropertyList(by));
 -         }
 - 
 -         [HttpGet("GetLivePropertyList")]
 -         public IActionResult GetLivePropertyList()
 -         {
 -             return new OkObjectResult(_Repo.GetPropertyList());
 -         }
 - 
 -         [HttpGet("MayEditProperty/{id}")]
 -         public IActionResult MayEditProperty(int id)
 -         {
 -             return new OkObjectResult(_Repo.MayEdit(id));
 -         }
 - 
 -         #endregion
 - 
 -         [HttpGet("search")]
 -         public IActionResult Search([FromBody] PropertySearch search)
 -         {
 -             return new OkObjectResult(_Repo.GetDisplay(search));
 -         }
 - 
 -         //Will need to come out. Post search not working......:(
 -         [HttpGet("search/{userName}/{keyword}/{salesType}/{propertyUsageType}/{propertyType}/{province}/{city}/{suburb}/{minPrice}/{maxPrice}/{availableFrom}/{propertyId}")]
 -         public IActionResult Search(string userName, string keyword, string salesType, string propertyUsageType, string propertyType, string province, string city, string suburb, decimal minPrice, decimal maxPrice, string availableFrom, int propertyId)
 -         {
 -             var search = new PropertySearch()
 -             {
 -                 UserName = userName,
 -                 Keyword = keyword,
 -                 SalesType = salesType,
 -                 PropertyUsageType = propertyUsageType,
 -                 PropertyType = propertyType,
 -                 Province = province,
 -                 City = city,
 -                 Suburb = suburb,
 -                 MinPrice = minPrice,
 -                 MaxPrice = maxPrice,
 -                 PropertyId = propertyId
 -             };            
 - 
 -             if (availableFrom == "undefined")
 -                 search.AvailableFrom = DateTime.MinValue;
 -             else
 -                 search.AvailableFrom = DateTime.Parse(availableFrom);
 - 
 -             return new OkObjectResult(_Repo.GetDisplay(search));
 -         }
 - 
 -         [HttpPost]
 -         public IActionResult Post([FromBody] PropertyContainer property)
 -         {
 -             using (var scope = new TransactionScope(TransactionScopeOption.Suppress))
 -             {
 -                 _Repo.Insert(property);
 -                 scope.Complete();                
 -                 return CreatedAtAction(nameof(Get), new { id = property.Id }, property);
 -             }            
 -         }      
 - 
 -         [HttpPut]
 -         public IActionResult Put([FromBody] PropertyContainer property)
 -         {
 -             if (property != null)
 -             {
 -                 using (var scope = new TransactionScope(TransactionScopeOption.Suppress))
 -                 {
 -                     _Repo.Update(property);
 -                     scope.Complete();
 -                     return new OkResult();
 -                 }
 -             }
 -             return new NoContentResult();
 -         }
 -         
 -         [HttpPut("PublishProperty")]
 -         public IActionResult PublishProperty([FromBody] PropertyDisplay property)
 -         {
 -             _Repo.PublishProperty(property.Id);
 -             return new NoContentResult();
 -         }
 - 
 -         [HttpPut("UnpublishProperty")]
 -         public IActionResult UnpublishProperty(PropertyDisplay property)
 -         {
 -             _Repo.UnpublishProperty(property.Id);
 -             return new NoContentResult();
 -         }
 - 
 -         [HttpDelete("{id}")]
 -         public IActionResult Delete(int id)
 -         {
 -             _Repo.RemoveAtId(id);
 -             return new OkResult();
 -         }
 -     }
 - }
 
 
  |