using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using RMApi.Models; using System.Diagnostics; namespace RMApi.Controllers { public class HomeController : Controller { private readonly ILogger _logger; private readonly RoleManager _roleManager; private readonly UserManager _userManager; public HomeController(ILogger logger, RoleManager roleManager, UserManager userManager) { _logger = logger; _roleManager = roleManager; _userManager = userManager; } public IActionResult Index() { return View(); } public async Task Privacy() { //string[] roles = { "Admin", "Manager", "Cashier" }; //foreach (string role in roles) //{ // var roleExist = await _roleManager.RoleExistsAsync(role); // if (roleExist == false) // { // await _roleManager.CreateAsync(new IdentityRole(role)); // } //} //var user = await _userManager.FindByEmailAsync("test@test.test"); //if (user != null) //{ // await _userManager.AddToRoleAsync(user, "Admin"); // await _userManager.AddToRoleAsync(user, "Cashier"); //} return View(); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } }