shop info
This commit is contained in:
40
Webshop.Api/Controllers/Admin/AdminShopInfoController.cs
Normal file
40
Webshop.Api/Controllers/Admin/AdminShopInfoController.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
// src/Webshop.Api/Controllers/Admin/AdminShopInfoController.cs
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Shop;
|
||||
using Webshop.Application.Services.Admin;
|
||||
|
||||
namespace Webshop.Api.Controllers.Admin
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/admin/[controller]")]
|
||||
[Authorize(Roles = "Admin")]
|
||||
public class AdminShopInfoController : ControllerBase
|
||||
{
|
||||
private readonly IAdminShopInfoService _shopInfoService;
|
||||
|
||||
public AdminShopInfoController(IAdminShopInfoService shopInfoService)
|
||||
{
|
||||
_shopInfoService = shopInfoService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<AdminShopInfoDto>> GetShopInfo()
|
||||
{
|
||||
var info = await _shopInfoService.GetShopInfoAsync();
|
||||
return Ok(info);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
public async Task<IActionResult> UpdateShopInfo([FromBody] AdminShopInfoDto shopInfoDto)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
await _shopInfoService.UpdateShopInfoAsync(shopInfoDto);
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
Webshop.Api/Controllers/Public/ShopInfoController.cs
Normal file
29
Webshop.Api/Controllers/Public/ShopInfoController.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
// src/Webshop.Api/Controllers/Public/ShopInfoController.cs
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Application.DTOs.Shop;
|
||||
using Webshop.Application.Services.Public;
|
||||
|
||||
namespace Webshop.Api.Controllers.Public
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/v1/public/[]controller")]
|
||||
[AllowAnonymous]
|
||||
public class ShopInfoController : ControllerBase
|
||||
{
|
||||
private readonly IShopInfoService _shopInfoService;
|
||||
|
||||
public ShopInfoController(IShopInfoService shopInfoService)
|
||||
{
|
||||
_shopInfoService = shopInfoService;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<PublicShopInfoDto>> GetPublicShopInfo()
|
||||
{
|
||||
var info = await _shopInfoService.GetPublicShopInfoAsync();
|
||||
return Ok(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user