50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using uWine.Core.Infrastructure.Services;
|
|
|
|
namespace uWine.Api.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("/[controller]")]
|
|
public class VineyardController : Controller
|
|
{
|
|
public VineyardService _vineyardService;
|
|
public VineyardController(VineyardService vineyardService)
|
|
{
|
|
_vineyardService = vineyardService;
|
|
}
|
|
|
|
|
|
[HttpGet("get-user-vineyards")]
|
|
public IActionResult UserVineyards()
|
|
{
|
|
try
|
|
{
|
|
var UserId = int.Parse(User.FindFirst("userId")?.Value);
|
|
var list = _vineyardService.User(UserId);
|
|
|
|
return Ok(list);
|
|
}
|
|
catch
|
|
{
|
|
return Unauthorized(new { status = 401 });
|
|
}
|
|
}
|
|
|
|
[HttpGet("get-owner-vineyards")]
|
|
public IActionResult OwnerVineyards()
|
|
{
|
|
try
|
|
{
|
|
var UserId = int.Parse(User.FindFirst("userId")?.Value);
|
|
var list = _vineyardService.Owner(UserId);
|
|
|
|
return Ok(list);
|
|
}
|
|
catch
|
|
{
|
|
return Unauthorized(new { status = 401 });
|
|
}
|
|
}
|
|
}
|
|
}
|