#pragma checksum "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "f5851035ed39f544d3c18a23e17d11b0288dd4d6"
// <auto-generated/>
#pragma warning disable 1591
namespace SPWA.Pages
{
    #line hidden
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Components;
#nullable restore
#line 2 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using System.Net.Http;

#line default
#line hidden
#nullable disable
#nullable restore
#line 4 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using Microsoft.AspNetCore.Components.Authorization;

#line default
#line hidden
#nullable disable
#nullable restore
#line 5 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using Microsoft.AspNetCore.Components.Forms;

#line default
#line hidden
#nullable disable
#nullable restore
#line 6 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using Microsoft.AspNetCore.Components.Routing;

#line default
#line hidden
#nullable disable
#nullable restore
#line 7 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using Microsoft.AspNetCore.Components.Web;

#line default
#line hidden
#nullable disable
#nullable restore
#line 8 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using Microsoft.JSInterop;

#line default
#line hidden
#nullable disable
#nullable restore
#line 9 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using SPWA;

#line default
#line hidden
#nullable disable
#nullable restore
#line 10 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using SPWA.Shared;

#line default
#line hidden
#nullable disable
#nullable restore
#line 11 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using MatBlazor;

#line default
#line hidden
#nullable disable
#nullable restore
#line 12 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using BlazorInputFile;

#line default
#line hidden
#nullable disable
#nullable restore
#line 14 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using Microsoft.AspNetCore.DataProtection;

#line default
#line hidden
#nullable disable
#nullable restore
#line 15 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using SPWA.LoginFeatures.Account.Pages.GoogleLogin;

#line default
#line hidden
#nullable disable
#nullable restore
#line 2 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
using Microsoft.AspNetCore.Authorization;

#line default
#line hidden
#nullable disable
#nullable restore
#line 3 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
using Microsoft.AspNetCore.Identity;

#line default
#line hidden
#nullable disable
#nullable restore
#line 4 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
using Microsoft.AspNetCore.Mvc.ActionConstraints;

#line default
#line hidden
#nullable disable
#nullable restore
#line 5 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
using System.IO;

#line default
#line hidden
#nullable disable
#nullable restore
#line 6 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
using SPWA.DataAccess.Data;

#line default
#line hidden
#nullable disable
    [Microsoft.AspNetCore.Components.RouteAttribute("/administration")]
    public partial class Administration : Microsoft.AspNetCore.Components.ComponentBase
    {
        #pragma warning disable 1998
        protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
        {
            __builder.OpenComponent<MatBlazor.MatCard>(0);
            __builder.AddAttribute(1, "Class", "mat-elevation-z1");
            __builder.AddAttribute(2, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => {
                __builder2.AddMarkupContent(3, "\r\n    ");
                __builder2.OpenComponent<MatBlazor.MatDialogTitle>(4);
                __builder2.AddAttribute(5, "Style", "font-family:\'Nunito\';font-size:x-large");
                __builder2.AddAttribute(6, "Class", "font-weight-bold");
                __builder2.AddAttribute(7, "ChildContent", (Microsoft.AspNetCore.Components.RenderFragment)((__builder3) => {
                    __builder3.AddContent(8, "Users Table");
                }
                ));
                __builder2.CloseComponent();
                __builder2.AddMarkupContent(9, "\r\n");
            }
            ));
            __builder.CloseComponent();
            __builder.AddMarkupContent(10, "\r\n");
            __builder.OpenComponent<MatBlazor.MatDivider>(11);
            __builder.CloseComponent();
            __builder.AddMarkupContent(12, "\r\n\r\n");
            __builder.OpenElement(13, "div");
            __builder.AddAttribute(14, "class", "mat-elevation-z1");
            __builder.AddAttribute(15, "style", "font-family:\'Nunito\'");
            __builder.AddMarkupContent(16, "\r\n    ");
            __Blazor.SPWA.Pages.Administration.TypeInference.CreateMatBlazor_MatTable_0(__builder, 17, 18, 
#nullable restore
#line 44 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                ColUsers

#line default
#line hidden
#nullable disable
            , 19, "table-hover", 20, "flex-wrap:wrap", 21, (__builder2) => {
                __builder2.AddMarkupContent(22, "\r\n            ");
                __builder2.AddMarkupContent(23, "<th style=\"font-weight:bold\">ID</th>\r\n            ");
                __builder2.AddMarkupContent(24, "<th style=\"font-weight:bold\">UserName</th>\r\n            ");
                __builder2.AddMarkupContent(25, "<th style=\"font-weight:bold\">Email</th>\r\n            ");
                __builder2.AddMarkupContent(26, "<th style=\"font-weight:bold\">Actions</th>\r\n        ");
            }
            , 27, (context) => (__builder2) => {
                __builder2.AddMarkupContent(28, "\r\n            ");
                __builder2.OpenElement(29, "td");
                __builder2.AddAttribute(30, "width", "32%");
                __builder2.AddContent(31, 
#nullable restore
#line 52 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                             context.Id

#line default
#line hidden
#nullable disable
                );
                __builder2.CloseElement();
                __builder2.AddMarkupContent(32, "\r\n            ");
                __builder2.OpenElement(33, "td");
                __builder2.AddAttribute(34, "width", "32%");
                __builder2.AddContent(35, 
#nullable restore
#line 53 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                             context.UserName

#line default
#line hidden
#nullable disable
                );
                __builder2.CloseElement();
                __builder2.AddMarkupContent(36, "\r\n            ");
                __builder2.OpenElement(37, "td");
                __builder2.AddAttribute(38, "width", "32%");
                __builder2.AddContent(39, 
#nullable restore
#line 54 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                             context.Email

#line default
#line hidden
#nullable disable
                );
                __builder2.CloseElement();
                __builder2.AddMarkupContent(40, "\r\n            ");
                __builder2.OpenElement(41, "td");
                __builder2.OpenComponent<MatBlazor.MatIconButton>(42);
                __builder2.AddAttribute(43, "Icon", "edit");
                __builder2.AddAttribute(44, "OnClick", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck<Microsoft.AspNetCore.Components.EventCallback<Microsoft.AspNetCore.Components.Web.MouseEventArgs>>(Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, 
#nullable restore
#line 55 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                                       (_) =>EditUser(@context)

#line default
#line hidden
#nullable disable
                )));
                __builder2.AddAttribute(45, "Style", "color:dodgerblue");
                __builder2.CloseComponent();
                __builder2.CloseElement();
                __builder2.AddMarkupContent(46, "\r\n        ");
            }
            );
            __builder.AddMarkupContent(47, "\r\n");
            __builder.CloseElement();
            __builder.AddMarkupContent(48, "\r\n\r\n");
#nullable restore
#line 60 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
 if (ShowPopup)
{

#line default
#line hidden
#nullable disable
            __builder.AddMarkupContent(49, "    \r\n    ");
            __builder.OpenElement(50, "div");
            __builder.AddAttribute(51, "class", "modal");
            __builder.AddAttribute(52, "tabindex", "-1");
            __builder.AddAttribute(53, "style", "display:block");
            __builder.AddAttribute(54, "role", "dialog");
            __builder.AddMarkupContent(55, "\r\n        ");
            __builder.OpenElement(56, "div");
            __builder.AddAttribute(57, "class", "modal-dialog");
            __builder.AddMarkupContent(58, "\r\n            ");
            __builder.OpenElement(59, "div");
            __builder.AddAttribute(60, "class", "modal-content");
            __builder.AddMarkupContent(61, "\r\n                ");
            __builder.OpenElement(62, "div");
            __builder.AddAttribute(63, "class", "modal-header");
            __builder.AddMarkupContent(64, "\r\n                    ");
            __builder.AddMarkupContent(65, "<h3 class=\"modal-title\">Edit User</h3>\r\n                    \r\n                    ");
            __builder.OpenElement(66, "button");
            __builder.AddAttribute(67, "type", "button");
            __builder.AddAttribute(68, "class", "close");
            __builder.AddAttribute(69, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, 
#nullable restore
#line 70 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                      ClosePopup

#line default
#line hidden
#nullable disable
            ));
            __builder.AddMarkupContent(70, "\r\n                        ");
            __builder.AddMarkupContent(71, "<span aria-hidden=\"true\">X</span>\r\n                    ");
            __builder.CloseElement();
            __builder.AddMarkupContent(72, "\r\n                ");
            __builder.CloseElement();
            __builder.AddMarkupContent(73, "\r\n                \r\n                ");
            __builder.OpenElement(74, "div");
            __builder.AddAttribute(75, "class", "modal-body");
            __builder.AddMarkupContent(76, "\r\n                    \r\n");
#nullable restore
#line 77 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                     if (objUser.Id != "")
                    {

#line default
#line hidden
#nullable disable
            __builder.AddContent(77, "                        ");
            __builder.OpenElement(78, "p");
            __builder.AddContent(79, "User ID: ");
            __builder.AddContent(80, 
#nullable restore
#line 79 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                     objUser.Id

#line default
#line hidden
#nullable disable
            );
            __builder.CloseElement();
            __builder.AddMarkupContent(81, "\r\n");
#nullable restore
#line 80 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                    }

#line default
#line hidden
#nullable disable
            __builder.AddMarkupContent(82, "                    \r\n");
#nullable restore
#line 82 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                     if (objUser.Id != "")
                    {

#line default
#line hidden
#nullable disable
            __builder.AddContent(83, "                        ");
            __builder.OpenElement(84, "p");
            __builder.AddContent(85, "Username: ");
            __builder.AddContent(86, 
#nullable restore
#line 84 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                      objUser.UserName

#line default
#line hidden
#nullable disable
            );
            __builder.CloseElement();
            __builder.AddMarkupContent(87, "\r\n");
#nullable restore
#line 85 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                    }
                    else
                    {

#line default
#line hidden
#nullable disable
            __builder.AddContent(88, "                        ");
            __builder.AddMarkupContent(89, "<label for=\"Name\" class=\"control-label\">Username</label>\r\n                        ");
            __builder.OpenElement(90, "input");
            __builder.AddAttribute(91, "class", "form-control");
            __builder.AddAttribute(92, "type", "text");
            __builder.AddAttribute(93, "placeholder", "UserName");
            __builder.AddAttribute(94, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue(
#nullable restore
#line 91 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                      objUser.UserName

#line default
#line hidden
#nullable disable
            ));
            __builder.AddAttribute(95, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => objUser.UserName = __value, objUser.UserName));
            __builder.SetUpdatesAttributeName("value");
            __builder.CloseElement();
            __builder.AddMarkupContent(96, "\r\n");
#nullable restore
#line 92 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                    }

#line default
#line hidden
#nullable disable
            __builder.AddContent(97, "                    ");
            __builder.AddMarkupContent(98, "<label for=\"Name\" class=\"control-label\">Email</label>\r\n                    ");
            __builder.OpenElement(99, "input");
            __builder.AddAttribute(100, "class", "form-control");
            __builder.AddAttribute(101, "type", "text");
            __builder.AddAttribute(102, "placeholder", "Email");
            __builder.AddAttribute(103, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue(
#nullable restore
#line 96 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                  objUser.Email

#line default
#line hidden
#nullable disable
            ));
            __builder.AddAttribute(104, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => objUser.Email = __value, objUser.Email));
            __builder.SetUpdatesAttributeName("value");
            __builder.CloseElement();
            __builder.AddMarkupContent(105, "\r\n\r\n                    ");
            __builder.AddMarkupContent(106, "<label for=\"Name\" class=\"control-label\">Password</label>\r\n                    ");
            __builder.OpenElement(107, "input");
            __builder.AddAttribute(108, "class", "form-control");
            __builder.AddAttribute(109, "type", "password");
            __builder.AddAttribute(110, "placeholder", "Password");
            __builder.AddAttribute(111, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue(
#nullable restore
#line 101 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                  objUser.PasswordHash

#line default
#line hidden
#nullable disable
            ));
            __builder.AddAttribute(112, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => objUser.PasswordHash = __value, objUser.PasswordHash));
            __builder.SetUpdatesAttributeName("value");
            __builder.CloseElement();
            __builder.AddMarkupContent(113, "\r\n\r\n                    ");
            __builder.AddMarkupContent(114, "<label for=\"Name\" class=\"control-label\">User Role</label>\r\n                    ");
            __builder.OpenElement(115, "select");
            __builder.AddAttribute(116, "class", "form-control");
            __builder.AddAttribute(117, "value", Microsoft.AspNetCore.Components.BindConverter.FormatValue(
#nullable restore
#line 105 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                    CurrentUserRole

#line default
#line hidden
#nullable disable
            ));
            __builder.AddAttribute(118, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => CurrentUserRole = __value, CurrentUserRole));
            __builder.SetUpdatesAttributeName("value");
            __builder.AddMarkupContent(119, "\r\n");
#nullable restore
#line 106 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                         foreach (var option in Options)
                        {

#line default
#line hidden
#nullable disable
            __builder.AddContent(120, "                            ");
            __builder.OpenElement(121, "option");
            __builder.AddAttribute(122, "value", 
#nullable restore
#line 108 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                            option

#line default
#line hidden
#nullable disable
            );
            __builder.AddMarkupContent(123, "\r\n                                ");
            __builder.AddContent(124, 
#nullable restore
#line 109 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                 option

#line default
#line hidden
#nullable disable
            );
            __builder.AddMarkupContent(125, "\r\n                            ");
            __builder.CloseElement();
            __builder.AddMarkupContent(126, "\r\n");
#nullable restore
#line 111 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                        }

#line default
#line hidden
#nullable disable
            __builder.AddContent(127, "                    ");
            __builder.CloseElement();
            __builder.AddMarkupContent(128, "\r\n                    <br><br>\r\n                    \r\n                    ");
            __builder.OpenElement(129, "button");
            __builder.AddAttribute(130, "class", "btn btn-primary");
            __builder.AddAttribute(131, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, 
#nullable restore
#line 116 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                      SaveUser

#line default
#line hidden
#nullable disable
            ));
            __builder.AddMarkupContent(132, "\r\n                        Save\r\n                    ");
            __builder.CloseElement();
            __builder.AddMarkupContent(133, "\r\n                    \r\n");
#nullable restore
#line 120 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                     if (objUser.Id != "")
                    {

#line default
#line hidden
#nullable disable
            __builder.AddMarkupContent(134, "                        \r\n                        ");
            __builder.OpenElement(135, "button");
            __builder.AddAttribute(136, "class", "btn btn-danger");
            __builder.AddAttribute(137, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, 
#nullable restore
#line 124 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                          DeleteUser

#line default
#line hidden
#nullable disable
            ));
            __builder.AddMarkupContent(138, "\r\n                            Delete\r\n                        ");
            __builder.CloseElement();
            __builder.AddMarkupContent(139, "\r\n");
#nullable restore
#line 127 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                    }

#line default
#line hidden
#nullable disable
            __builder.AddMarkupContent(140, "                    <br>\r\n                    ");
            __builder.OpenElement(141, "span");
            __builder.AddAttribute(142, "style", "color:red");
            __builder.AddContent(143, 
#nullable restore
#line 129 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                             strError

#line default
#line hidden
#nullable disable
            );
            __builder.CloseElement();
            __builder.AddMarkupContent(144, "\r\n                ");
            __builder.CloseElement();
            __builder.AddMarkupContent(145, "\r\n            ");
            __builder.CloseElement();
            __builder.AddMarkupContent(146, "\r\n        ");
            __builder.CloseElement();
            __builder.AddMarkupContent(147, "\r\n    ");
            __builder.CloseElement();
            __builder.AddMarkupContent(148, "\r\n");
#nullable restore
#line 134 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
}

#line default
#line hidden
#nullable disable
            __builder.AddMarkupContent(149, "\r\n\r\n\r\n");
            __builder.OpenElement(150, "button");
            __builder.AddAttribute(151, "class", "btn btn-success");
            __builder.AddAttribute(152, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create<Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, 
#nullable restore
#line 151 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
                                          AddNewUser

#line default
#line hidden
#nullable disable
            ));
            __builder.AddContent(153, "Add User");
            __builder.CloseElement();
            __builder.AddMarkupContent(154, "\r\n\r\n");
            __builder.OpenElement(155, "p");
            __builder.AddContent(156, 
#nullable restore
#line 153 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
    status

#line default
#line hidden
#nullable disable
            );
            __builder.CloseElement();
        }
        #pragma warning restore 1998
#nullable restore
#line 157 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Administration.razor"
       
    [CascadingParameter]
    private Task<AuthenticationState> authenticationStateTask { get; set; }
    string ADMINISTRATION_ROLE = "Administrators";
    System.Security.Claims.ClaimsPrincipal CurrentUser;

    // Property used to add or edit the currently selected user
    ApplicationUser objUser = new ApplicationUser();
    // Tracks the selected role for the currently selected user
    string CurrentUserRole { get; set; } = "Users";
    // Collection to display the existing users
    List<ApplicationUser> ColUsers = new List<ApplicationUser>();
    // Options to display in the roles dropdown when editing a user
    List<string> Options = new List<string>() { "Users","Administrators", "Judges", "PMs", "Students" };
    // To hold any possible errors
    string strError = "";
    // To enable showing the Popup
    bool ShowPopup = false;
    string status;

    string filePath = Path.Combine(Environment.CurrentDirectory, @"App_Data\Data.txt");

    protected override async Task OnInitializedAsync()
    {
        // ensure there is a ADMINISTRATION_ROLE
        var RoleResult = await _RoleManager.FindByNameAsync(ADMINISTRATION_ROLE);
        if (RoleResult == null)
        {
            // Create ADMINISTRATION_ROLE Role
            await _RoleManager.CreateAsync(new IdentityRole(ADMINISTRATION_ROLE));
        }
        // Ensure a user named Admin@BlazorHelpWebsite.com is an Administrator
        var user = await _UserManager.FindByNameAsync("Admin@BlazorHelpWebsite.com");
        if (user != null)
        {
            // Is Admin@BlazorHelpWebsite.com in administrator role?
            var UserResult = await _UserManager.IsInRoleAsync(user, ADMINISTRATION_ROLE);
            if (!UserResult)
            {
                // Put admin in Administrator role
                await _UserManager.AddToRoleAsync(user, ADMINISTRATION_ROLE);
            }
        }
        // Get the current logged in user
        CurrentUser = (await authenticationStateTask).User;
        
        // Get the users
        GetUsers();
    }

    public void GetUsers()
    {
        // clear any error messages
        strError = "";
        // Collection to hold users
        ColUsers = new List<ApplicationUser>();
        // get users from _UserManager
        var user = _UserManager.Users.Select(x => new ApplicationUser
        {
            Id = x.Id,
            UserName = x.UserName,
            Email = x.Email,
            PasswordHash = "*****"
        });
        foreach (var item in user)
        {
            ColUsers.Add(item);
        }
    }

    void AddNewUser()
    {
        // Make new user
        objUser = new ApplicationUser();
        objUser.PasswordHash = "*****";
        // Set Id to blank so we know it is a new record
        objUser.Id = "";
        // Open the Popup
        ShowPopup = true;
    }
    async Task SaveUser()
    {
        try
        {
            // Is this an existing user?
            if (objUser.Id != "")
            {
                // Get the user
                var user = await _UserManager.FindByIdAsync(objUser.Id.ToString());
                // Update Email
                user.Email = objUser.Email;
                // Update the user
                await _UserManager.UpdateAsync(user);
                // Only update password if the current value
                // is not the default value
                if (objUser.PasswordHash != "*****")
                {
                    var resetToken =
                        await _UserManager.GeneratePasswordResetTokenAsync(user);
                    var passworduser =
                        await _UserManager.ResetPasswordAsync(
                            user,
                            resetToken,
                            objUser.PasswordHash);
                    if (!passworduser.Succeeded)
                    {
                        if (passworduser.Errors.FirstOrDefault() != null)
                        {
                            strError =
                                passworduser
                                .Errors
                                .FirstOrDefault()
                                .Description;
                        }
                        else
                        {
                            strError = "Pasword error";
                        }
                        // Keep the popup opened
                        return;
                    }
                }
                // Handle Roles
                // Is user in administrator role?
                var UserResult =
                    await _UserManager
                    .IsInRoleAsync(user, ADMINISTRATION_ROLE);
                // Is Administrator role selected
                // but user is not an Administrator?
                if (
                    (CurrentUserRole == ADMINISTRATION_ROLE)
                    &
                    (!UserResult))
                {
                    // Put admin in Administrator role
                    await _UserManager
                        .AddToRoleAsync(user, ADMINISTRATION_ROLE);
                }
                else
                {
                    // Is Administrator role not selected
                    // but user is an Administrator?
                    if ((CurrentUserRole != ADMINISTRATION_ROLE)
                        &
                        (UserResult))
                    {
                        // Remove user from Administrator role
                        await _UserManager
                            .RemoveFromRoleAsync(user, ADMINISTRATION_ROLE);
                    }
                }
            }
            else
            {
                // Insert new user
                var NewUser =
                    new ApplicationUser
                    {
                        UserName = objUser.UserName,
                        Email = objUser.Email
                    };
                var CreateResult =
                    await _UserManager
                    .CreateAsync(NewUser, objUser.PasswordHash);
                System.Diagnostics.Debug.WriteLine("NewUser Succeeded: " + CreateResult.Succeeded);
                if (!CreateResult.Succeeded)
                {
                    if (CreateResult
                        .Errors
                        .FirstOrDefault() != null)
                    {
                        strError =
                            CreateResult
                            .Errors
                            .FirstOrDefault()
                            .Description;
                    }
                    else
                    {
                        strError = "Create error";
                    }
                    // Keep the popup opened
                    return;
                }
                else
                {
                    // Handle Roles
                    if (CurrentUserRole == ADMINISTRATION_ROLE)
                    {
                        // Put admin in Administrator role
                        await _UserManager
                            .AddToRoleAsync(NewUser, ADMINISTRATION_ROLE);
                    }
                }
            }
            // Close the Popup
            ShowPopup = false;
            // Refresh Users
            GetUsers();
        }
        catch (Exception ex)
        {
            strError = ex.GetBaseException().Message;
        }
    }

    async Task EditUser(ApplicationUser _ApplicationUser)
    {
        // Set the selected user
        // as the current user
        objUser = _ApplicationUser;
        // Get the user
        var user = await _UserManager.FindByIdAsync(objUser.Id.ToString());
         
        if (user != null)
        {
            // Is user in administrator role?
            var UserResult =
                await _UserManager
                .IsInRoleAsync(user, ADMINISTRATION_ROLE);
            if (UserResult)
            {
                CurrentUserRole = ADMINISTRATION_ROLE;
            }
            else
            {
                CurrentUserRole = "Users";
            }
        }
        // Open the Popup
        ShowPopup = true;
    }

    async Task DeleteUser()
    {
        // Close the Popup
        ShowPopup = false;
        // Get the user
        var user = await _UserManager.FindByIdAsync(objUser.Id.ToString());
        if (user != null)
        {
            // Delete the user
            await _UserManager.DeleteAsync(user);
        }
        // Refresh Users
        GetUsers();
    }

    void ClosePopup()
    {
        // Close the Popup
        ShowPopup = false;
    }

    async Task HandleSelection(BlazorInputFile.IFileListEntry[] files)
    {
        var file = files.FirstOrDefault();
        if (file != null)
        {

            var FileStream = File.Create(filePath);

            await file.Data.CopyToAsync(FileStream);
            FileStream.Close();

            status = $"Finished loading {file.Size} bytes from {file.Name}";

        }
    }





#line default
#line hidden
#nullable disable
        [global::Microsoft.AspNetCore.Components.InjectAttribute] private IJSRuntime JSrn { get; set; }
        [global::Microsoft.AspNetCore.Components.InjectAttribute] private AuthenticationStateProvider AuthenticationStateProvider { get; set; }
        [global::Microsoft.AspNetCore.Components.InjectAttribute] private RoleManager<IdentityRole> _RoleManager { get; set; }
        [global::Microsoft.AspNetCore.Components.InjectAttribute] private UserManager<ApplicationUser> _UserManager { get; set; }
    }
}
namespace __Blazor.SPWA.Pages.Administration
{
    #line hidden
    internal static class TypeInference
    {
        public static void CreateMatBlazor_MatTable_0<TableItem>(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder, int seq, int __seq0, global::System.Collections.Generic.IEnumerable<TableItem> __arg0, int __seq1, global::System.String __arg1, int __seq2, global::System.String __arg2, int __seq3, global::Microsoft.AspNetCore.Components.RenderFragment __arg3, int __seq4, global::Microsoft.AspNetCore.Components.RenderFragment<TableItem> __arg4)
        {
        __builder.OpenComponent<global::MatBlazor.MatTable<TableItem>>(seq);
        __builder.AddAttribute(__seq0, "Items", __arg0);
        __builder.AddAttribute(__seq1, "Class", __arg1);
        __builder.AddAttribute(__seq2, "Style", __arg2);
        __builder.AddAttribute(__seq3, "MatTableHeader", __arg3);
        __builder.AddAttribute(__seq4, "MatTableRow", __arg4);
        __builder.CloseComponent();
        }
    }
}
#pragma warning restore 1591
