12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using Microsoft.AspNetCore.Mvc;
- using System.Transactions;
- using UnivateProperties_API.Containers.ProcessFlow;
- using UnivateProperties_API.Model.ProcessFlow;
- using UnivateProperties_API.Repository;
- using UnivateProperties_API.Repository.ProccessFlow;
-
- namespace UnivateProperties_API.Controllers.ProcessFlow
- {
- [Route("api/[controller]")]
- [ApiController]
- public class BidController : ControllerBase
- {
- private readonly IBidRepository _Repo;
-
- public BidController(IBidRepository repo)
- {
- _Repo = repo;
- }
-
- [HttpGet]
- public IActionResult Get()
- {
- var items = _Repo.GetAll();
- return new OkObjectResult(items);
- }
-
- [HttpGet("{id}")]
- public IActionResult Get(int id)
- {
- var item = _Repo.Get(x => x.Id == id);
- return new OkObjectResult(item);
- }
-
- [HttpGet("GetBids/{name}")]
- public IActionResult GetOwnerBids(string name)
- {
- var items = _Repo.GetAllBidBy(name);
- return new OkObjectResult(items);
- }
-
- [HttpGet("GetBidDetails/{id}")]
- public IActionResult GetBidDetail(int id)
- {
- var item = _Repo.GetDispaly(id);
- return new OkObjectResult(item);
- }
-
- [HttpPost]
- public IActionResult Post([FromBody] BidItemNew item)
- {
- using (var scope = new TransactionScope(TransactionScopeOption.Suppress))
- {
- _Repo.InsertNew(item);
- scope.Complete();
- return CreatedAtAction(nameof(Get), new { id = item.Id }, item);
- }
- }
-
- [HttpPut]
- public IActionResult Put([FromBody] BidItem item)
- {
- if (item != null)
- {
- using (var scope = new TransactionScope())
- {
- _Repo.Update(item);
- scope.Complete();
- return new OkResult();
- }
- }
- return new NoContentResult();
- }
-
- [HttpPut("AcceptBid/{id}")]
- public IActionResult AcceptBid(int id)
- {
- return new OkObjectResult(_Repo.AcceptBid(id));
- }
-
- [HttpPut("DeclineBid")]
- public IActionResult DeclineBid([FromBody] BitItemDecline item)
- {
- return new OkObjectResult(_Repo.DecineBid(item));
- }
-
- [HttpDelete("{id}")]
- public IActionResult Delete(int id)
- {
- _Repo.RemoveAtId(id);
- return new OkResult();
- }
- }
- }
|