Spaces:
Sleeping
Sleeping
Download Controllers/Admin/CustomersController.cs from Danishathugging/danstore: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/Danishathugging/danstore/resolve/main/Controllers/Admin/CustomersController.cs
- Command line
-
hf download hf://spaces/Danishathugging/danstore/Controllers/Admin/CustomersController.cs
-
curl -L -o CustomersController.cs https://huggingface.co/spaces/Danishathugging/danstore/resolve/main/Controllers/Admin/CustomersController.cs
1.16 kB
| using ECommerce.Presenter.Presenters; | |
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Identity; | |
| using Microsoft.AspNetCore.Mvc; | |
| namespace Ecommerce_web_project.Controllers.Admin; | |
| [] | |
| [] | |
| public class CustomersController : Controller | |
| { | |
| private readonly AdminDashboardPresenter _presenter; | |
| private readonly UserManager<IdentityUser> _userManager; | |
| public CustomersController(AdminDashboardPresenter presenter, UserManager<IdentityUser> userManager) | |
| { | |
| _presenter = presenter; | |
| _userManager = userManager; | |
| } | |
| public async Task<IActionResult> Index() | |
| { | |
| var customers = await _presenter.GetAllCustomersAsync(); | |
| var adminUserIds = (await _userManager.GetUsersInRoleAsync("Admin")) | |
| .Select(u => u.Id) | |
| .ToHashSet(); | |
| var filtered = customers.Where(c => !adminUserIds.Contains(c.UserId)).ToList(); | |
| foreach (var customer in filtered) | |
| { | |
| var user = await _userManager.FindByIdAsync(customer.UserId); | |
| customer.Email = user?.Email ?? ""; | |
| } | |
| return View(filtered); | |
| } | |
| } | |