LibraryManagement / Frontend /Controllers /SubscriptionsController.cs
sannlynnhtun-coding's picture
feat: implement authentication and authorization features, add book and user management controllers, and enhance UI for login and registration
b0a0ed0
Raw
History Blame
865 Bytes
using Microsoft.AspNetCore.Mvc;
using Frontend.Services;
using Frontend.Models.Dtos;
using Frontend.Models;
using Microsoft.AspNetCore.Authorization;
using System.Threading.Tasks;
using System.Linq;
namespace Frontend.Controllers
{
[Authorize(Roles = "Admin")]
public class SubscriptionsController : Controller
{
private readonly LibraryApiClient _apiClient;
public SubscriptionsController(LibraryApiClient apiClient)
{
_apiClient = apiClient;
}
public async Task<IActionResult> Index()
{
var memberships = await _apiClient.GetMembershipsAsync();
var viewModel = new SubscriptionsViewModel
{
AvailableMemberships = memberships?.ToList() ?? new List<MembershipDto>()
};
return View(viewModel);
}
}
}