using Microsoft.AspNetCore.Mvc; using ProRestaurant.Containers; using ProRestaurant.Repository.Accounts; using System.Transactions; namespace ProRestaurant.Controllers.Accounts { [Route("api/[controller]")] [ApiController] public class RegistrationController : ControllerBase { private readonly IRegistrationRepository regRepository; public RegistrationController(IRegistrationRepository regRepo) { regRepository = regRepo; } [HttpGet("GetUserContainer")] public IActionResult GetUserContainer() { var userContainer = regRepository.GetUserContainer(); return new OkObjectResult(userContainer); } [HttpGet("GetRestaurantContainer")] public IActionResult GetRestaurantContainer() { var container = regRepository.GetRestaurantContainer(); return new OkObjectResult(container); } [HttpPost("resgisterRestaurant")] public IActionResult ResgisterRestaurant([FromBody] RestaurantContainer container) { using (var scope = new TransactionScope()) { regRepository.RegisterRestaurant(container); scope.Complete(); return new OkObjectResult(container); } } [HttpPost("resgisterUser")] public IActionResult ResgisterUser([FromBody] UserContainer container) { using (var scope = new TransactionScope()) { regRepository.RegisterUser(container); scope.Complete(); return new OkObjectResult(container); } } } }