You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RegistrationController.cs 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Microsoft.AspNetCore.Mvc;
  2. using ProRestaurant.Containers;
  3. using ProRestaurant.Repository.Accounts;
  4. using System.Transactions;
  5. namespace ProRestaurant.Controllers.Accounts
  6. {
  7. [Route("api/[controller]")]
  8. [ApiController]
  9. public class RegistrationController : ControllerBase
  10. {
  11. private readonly IRegistrationRepository regRepository;
  12. public RegistrationController(IRegistrationRepository regRepo)
  13. {
  14. regRepository = regRepo;
  15. }
  16. [HttpGet("GetUserContainer")]
  17. public IActionResult GetUserContainer()
  18. {
  19. var userContainer = regRepository.GetUserContainer();
  20. return new OkObjectResult(userContainer);
  21. }
  22. [HttpGet("GetRestaurantContainer")]
  23. public IActionResult GetRestaurantContainer()
  24. {
  25. var container = regRepository.GetRestaurantContainer();
  26. return new OkObjectResult(container);
  27. }
  28. [HttpPost("resgisterRestaurant")]
  29. public IActionResult ResgisterRestaurant([FromBody] RestaurantContainer container)
  30. {
  31. using (var scope = new TransactionScope())
  32. {
  33. regRepository.RegisterRestaurant(container);
  34. scope.Complete();
  35. return new OkObjectResult(container);
  36. }
  37. }
  38. [HttpPost("resgisterUser")]
  39. public IActionResult ResgisterUser([FromBody] UserContainer container)
  40. {
  41. using (var scope = new TransactionScope())
  42. {
  43. regRepository.RegisterUser(container);
  44. scope.Complete();
  45. return new OkObjectResult(container);
  46. }
  47. }
  48. }
  49. }