123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- @page "/gestaoprojetos"
- @attribute [Authorize]
- @rendermode InteractiveServer
- @using ConcursoProjetos.Service
- @using Microsoft.AspNetCore.Authorization
- @using Microsoft.AspNetCore.Identity
- @inject UserManager<ApplicationUser> UserManager
- @inject AuthenticationStateProvider AuthenticationStateProvider
- @inject ICandidatoService candidatoService
- @inject IProjetoService projetoService
- @inject NavigationManager Navigation
- <PageTitle>Gestão de Projetos</PageTitle>
- <h1>Gestão de Projetos</h1>
- <button class="btn btn-primary" @onclick="() => EditarProjeto(0)">Add Projeto</button>
- @if (_projetos == null || !_projetos.Any())
- {
- <p><em>@_mensagem</em></p>
- }
- else
- {
- <table class="table">
- <thead>
- <tr>
- <th>Projeto</th>
- <th>Unidades</th>
- <th>Responsável Técnico</th>
- <th>Status</th>
- <th></th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- @foreach (var projeto in _projetos)
- {
- <tr>
- <td>@projeto.Nome</td>
- <td>@projeto.NumeroUnidades.ToString()</td>
- <td>@projeto.ResponsavelTecnicoNomeCompleto</td>
- <td>
- <span class="bi bi-check-all fs-5 text-success" aria-hidden="true"></span>
- <span class="bi bi-x fs-5 text-danger" aria-hidden="true"></span>
- </td>
- <th></th>
- <th><button class="btn btn-primary" @onclick="() => EditarProjeto(projeto.Id)">Editar</button></th>
- </tr>
- }
- </tbody>
- </table>
- }
- @code {
- private Candidato? _candidato;
- private IEnumerable<Projeto>? _projetos;
- private string _mensagem = "Loading...";
- protected override async Task OnInitializedAsync()
- {
- var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
- var user = authState.User;
- if (user.Identity.IsAuthenticated)
- {
- var identityUser = await UserManager.GetUserAsync(user);
- if (identityUser != null)
- {
- _candidato = candidatoService.ObterPorUserID(identityUser.Id);
- _projetos = projetoService.Listar(_candidato!.Id);
- if (_projetos == null || _projetos.Count() <= 0)
- _mensagem = "Você não tem projetos cadastrados.";
- }
- }
- }
- private void EditarProjeto(long projetoId)
- {
- // Your logic to add a new project
- //Console.WriteLine("Adding a new project...");
- Navigation.NavigateTo($"/pageprojeto/{projetoId}");
- }
- }
|