@using System.Security.Claims;
@using SMS_MVCDTO.Enums;

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - SMS_MVCDTO</title>
    <link rel="stylesheet" href="~/css/FontAwesome6.2/css/all.css">
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">
    @*<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css">*@
    <script src="~/js/site.js"></script>

    <!--    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.14.0/css/all.css" integrity="sha384-HzLeBuhoNPvSl5KYnjx0BT+WB0QEEqLprO+NBkkk5gbc67FTaL7XIGa2w1L0Xbgc" crossorigin="anonymous"> -->
    <link rel="stylesheet" href="~/css/styles.css">
    <link rel="stylesheet" href="~/SMS_MVCDTO.styles.css" asp-append-version="true" />

</head>

<body>

    @{
        var loginUser = User?.FindFirst(ClaimTypes.Role);

        string StaffId;
        if (loginUser != null)
        {
            StaffId = User?.FindFirst(ClaimTypes.NameIdentifier).Value;
        }
        else
        {
            StaffId = null;
        }

        var nameOd = new Dictionary<string, string>(){
    {"Ahmad", "Abdulsalam"}
    };
        string result;
        if (nameOd.TryGetValue("France", out result))
        {
            Console.WriteLine(result);
        }
            //}


        @* @if (loginUser != null)

    //{
    //    @if (loginUser.Value == UserRoleType.SuperAdmin.ToString())
    //    {

    //    }

    //}
    *@



        <header>
            <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
                <div class="container-fluid">
                    <a class="navbar-brand" asp-area=""
                   asp-controller="Home"
                   asp-action="Index">Colon Sales Record</a>
                    @* MDelete *@
                    <button class="navbar-toggler" type="button"
                            data-bs-toggle="collapse"
                            data-bs-target=".navbar-collapse"
                            aria-controls="navbarSupportedContent"
                            aria-expanded="false" aria-label="Toggle
                                                                            navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    @* MDelete *@

                    <div class="navbar-collapse collapse d-sm-inline-flex  justify-content-between">
                        <ul class="navbar-nav flex-grow-1">
                            <li class="nav-item">
                                <a class="nav-link text-dark" asp-area=""
                               asp-controller="Home"
                               asp-action="Index">Home</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link text-dark" asp-area=""
                               asp-controller="Home"
                               asp-action="Privacy">
                                    About
                                    us
                                </a>
                            </li>

                            <li class="nav-item">
                                <a class="nav-link text-dark" asp-area=""
                               asp-controller="Home"
                               asp-action="Privacy">
                                    Contact
                                    us
                                </a>
                            </li>

                            <li class="nav-item">
                                <a class="nav-link text-dark" asp-area=""
                               asp-controller="Home"
                               asp-action="Privacy">Privacy</a>
                            </li>

                            <li class="nav-item">
                                <a class="nav-link text-dark" asp-area=""
                               asp-controller="Home"
                               asp-action="Privacy">News</a>
                            </li>

                        </ul>


                        <ul class="navbar-nav">


                            @if (loginUser == null)
                            {
                                <li class="nav-item">
                                    <a class="nav-link text-dark" asp-area=""
                               asp-controller="Home"
                               asp-action="Login">Login</a>
                                </li>
                            }
                            else { }


                            @*byte[] = @(Convert.FromBase64String(User.FindFirstValue(ClaimTypes.UserData)))*@

                            @if (loginUser != null)
                            {
                                @*byte[] pict = Convert.ToBase64String(User?.FindFirst(ClaimTypes.GivenName).Value)*@
                                @*
                        if (TempData["ProfilePicture"] != null)
                        {
                        byte[] picture =  @TempData["ProfilePicture"]
                        }

                        <img style="width:40px;height:40px; object-fit:cover; border-radius:30px" src="data:image/*;base64,@(Convert.ToBase64String(UserManager.GetUserAsync(User).Result.ProfilePicture))">

                        <a asp-area="" asp-asp-controller="Home" asp-action="Index">
                        <img style="width:40px;height:40px; object-fit:cover; border-radius:30px" src="data:image/*;base64,@(Convert.FromBase64String(User.FindFirstValue(ClaimTypes.UserData)))">
                        </a>

                        *@



                                @if (loginUser.Value == 1.ToString())
                                {
                                    <li class="nav-item">
                                        <a class="nav-link text-dark" asp-area="" asp-controller="SuperAdmin" asp-action="Details" asp-route-staffId="@StaffId"> Welcome @User?.FindFirst(ClaimTypes.Name).Value</a>
                                    </li>

                                }
                                else if (loginUser.Value == 2.ToString())
                                {
                                    <li class="nav-item">
                                        <a class="nav-link text-dark" asp-area="" asp-controller="SalesManager" asp-action="Details" asp-route-staffId="@StaffId"> Welcome @User?.FindFirst(ClaimTypes.Name).Value</a>
                                    </li>
                                }
                                else if (loginUser.Value == 3.ToString())
                                {
                                    //<li>
                                //    <img src="data:image/jpeg;base64,@Convert.ToBase64String((byte[])ViewData["ImageData"])" />

                                    //</li>

                                    <li class="nav-item">
                                        <a class="nav-link text-dark" asp-area="" asp-controller="Attendant" asp-action="Details" asp-route-staffId="@StaffId"> Welcome @User?.FindFirst(ClaimTypes.Name).Value</a>
                                    </li>
                                }
                                else
                                {

                                    <li class="nav-item">
                                        <a class="nav-link text-dark" asp-area="" asp-controller="customer" asp-action="Details" asp-route-staffId="@StaffId"> Welcome @User?.FindFirst(ClaimTypes.Name).Value</a>
                                    </li>
                                }



                                <li class="nav-item">
                                    <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Logout</a>
                                </li>

                            }


                            @if (loginUser == null)
                            {
                                <li class="nav-item">
                                    <a class="nav-link text-dark" asp-area="" asp-controller="SuperAdmin" asp-action="Create">Sign-Up</a>
                                </li>
                            }
                            else { }

                        </ul>

                    </div>
                </div>
            </nav>
        </header>

        @* <div class="wrapper"> *@




        @*SIDE BAR*@
        <div class="bodycontain bd-oline">

            @if (loginUser != null)
            {
                @if (loginUser.Value == 1.ToString() || loginUser.Value == 2.ToString() || loginUser.Value == 3.ToString())
                {
                    <div class="sidebar ">
                        <h3>Navigation</h3>
                        <ul>

                            <li><a asp-area="" asp-controller="" asp-action="">Home</a></li>

                            <li class="dropdown">
                                <a href="#">Attendants</a>
                                <ul class="dropdown-content">
                                    @if (loginUser.Value == 1.ToString() || loginUser.Value == 2.ToString())
                                    {
                                        <li>
                                            <a asp-area="" asp-controller="Attendant"
                               asp-action="Create">Create Attendants</a>
                                        </li>

                                        <li>
                                            <a asp-area="" asp-controller="Attendant"
                               asp-action="Dashboard">Manage Attendants</a>
                                        </li>

                                        <li>
                                            <a asp-area="" asp-controller="Attendant"
                               asp-action="">View all attendants</a>
                                        </li>
                                    }
                                    else { }

                                </ul>
                            </li>

                            @if (loginUser.Value == 1.ToString() || loginUser.Value == 3.ToString() || loginUser.Value == 2.ToString())
                            {
                                <li class="dropdown">
                                    <a href="#">Customers</a>
                                    <ul class="dropdown-content">
                                        <li>
                                            <a asp-area="" asp-controller="Customer"
                               asp-action="Create">Create Customer</a>
                                        </li>
                                        <li>
                                            <a asp-area="" asp-controller="Customer"
                               asp-action="Dashboard">Manage Customer</a>
                                        </li>
                                        <li>
                                            <a asp-area="" asp-controller="Customer"
                               asp-action="">View all Customers</a>
                                        </li>
                                    </ul>
                                </li>
                            }
                            else { }



                            <li class="dropdown">
                                <a href="#">Products</a>
                                <ul class="dropdown-content">

                                    @if (loginUser.Value == 1.ToString() || loginUser.Value == 2.ToString())
                                    {
                                        <li>
                                            <a asp-area="" asp-controller="Product"
                               asp-action="Create">Add new products</a>
                                        </li>

                                        <li>
                                            <a asp-area="" asp-controller="Product"
                               asp-action="Dashboard">Manage Product</a>
                                        </li>
                                    }
                                    else { }

                                    <li>
                                        <a asp-area="" asp-controller="Product"
                               asp-action="">View all Products</a>
                                    </li>

                                </ul>
                            </li>

                            @* <li><a href="#">Products</a></li> *@

                            <li class="dropdown">
                                <a href="#">Transactions</a>
                                <ul class="dropdown-content">
                                    <li>
                                        <a asp-area="" asp-controller="Transaction"
                               asp-action="">Transaction</a>
                                    </li>
                                    <li>
                                        <a asp-area="" asp-controller="Cart"
                               asp-action="GetAllPendingTransaction">Pending Trans..</a>
                                    </li>
                                    <li>
                                        <a asp-area="" asp-controller=""
                               asp-action="">Recent</a>
                                    </li>
                                </ul>
                            </li>

                            @* <li>
                <a asp-area="" asp-controller="Transaction"
                asp-action="">Transactions</a>
                </li>*@
                        </ul>
                    </div>
                }
                else { }

            }




            <div class="bodycontains">

                <main role="main" class="pb-3">
                    @* <div class="bd-line"> *@

                    @RenderBody()
                    @* </div> *@
                </main>
                @*
            <footer class="border-top footer text-muted">
            <div class="container">
            &copy; 2022 - SMS_MVCDTO - <a asp-area=""
            asp-controller="Home"
            asp-action="Privacy">Privacy</a>
            </div>
            </footer>*@
            </div>



        </div>



        <script src="~/lib/jquery/dist/jquery.min.js"></script>
        <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
        <script src="~/js/site.js" asp-append-version="true"></script>
        @await RenderSectionAsync("Scripts", required: false)
    }
</body>

</html>