40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
// 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();
|
|
}
|
|
}
|
|
} |