refact program.cs vineyardController, service e repo
This commit is contained in:
1 parent
a373201ca4
commit
3a1a0ca7ef
17 files changed
+769
-306
No files matched your search
@@ -0,0 +1,49 @@
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user