#pragma checksum "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Terms.razor" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "91109f4eece34dc5500fb7ee8ebd9f6b611bcc30"
// <auto-generated/>
#pragma warning disable 1591
#pragma warning disable 0414
#pragma warning disable 0649
#pragma warning disable 0169

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 3 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using Microsoft.AspNetCore.Authorization;

#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 13 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\_Imports.razor"
using Microsoft.AspNetCore.Identity;

#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\Terms.razor"
using SPWA.DataAccess.Data.TermServices;

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

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

#line default
#line hidden
#nullable disable
    [Microsoft.AspNetCore.Components.RouteAttribute("/terms")]
    public partial class Terms : OwningComponentBase<TermService>
    {
        #pragma warning disable 1998
        protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
        {
        }
        #pragma warning restore 1998
#nullable restore
#line 106 "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Terms.razor"
       

    // AuthenticationState is available as a CascadingParameter
    [CascadingParameter]
    private Task<AuthenticationState> authenticationStateTask { get; set; }

    List<Term> terms;

    protected override async Task OnInitializedAsync()
    {
        // Get the current user
        var user = (await authenticationStateTask).User;
        // Get the term for the current user
        // We access termService using @Service
        terms = await @Service.GetTermAsync(user.Identity.Name);
    }
    string strError = "";
    Term objTerm = new Term();
    bool ShowPopup = false;
    bool ReadMorePopup = false;

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


    void AddNewTerm()
    {
        //System.Diagnostics.Debug.WriteLine("read value =" + ReadMorePopup);
        // Make new term
        objTerm = new Term();
        // Set Id to 0 so we know it is a new record
        objTerm.TermID = 0;
        // Open the Popup
        ShowPopup = true;
    }



    async Task SaveTerm()
    {
        // Close the Popup
        ShowPopup = false;
        // Get the current user
        var user = (await authenticationStateTask).User;
        // A new Term will have the Id set to 0
        if (objTerm.TermID == 0)
        {
            // Create new term
            Term objNewTerm = new Term();
            objNewTerm.Name = objTerm.Name;
            objNewTerm.StudentPerJudge = objTerm.StudentPerJudge;
            objNewTerm.Location = objTerm.Location;
            objNewTerm.MapUrl = objTerm.MapUrl;

            

            // Save the result
            var result =
            @Service.CreateTermAsync(objNewTerm);
        }
        else
        {
            // This is an update
            var result =
            @Service.UpdateTermAsync(objTerm);
        }
        // Get the term for the current user
        terms =
        await @Service.GetTermAsync(user.Identity.Name);
    }


    void EditTerm(Term term)
    {
        //System.Diagnostics.Debug.WriteLine("read value =" + ReadMorePopup);
        // Set the selected term
        // as the current term
        objTerm = term;
        // Open the Popup
        ShowPopup = true;
    }

    void ReadTerm(Term term)
    {
        //System.Diagnostics.Debug.WriteLine("In Readmorepopup ");
        // Set the selected term
        // as the current term
        objTerm = term;
        // Open the Popup
        ReadMorePopup = true;
        //System.Diagnostics.Debug.WriteLine(ReadMorePopup);
    }

    async Task DeleteTerm()
    {
        // Close the Popup
        ShowPopup = false;
       

    }



#line default
#line hidden
#nullable disable
        [global::Microsoft.AspNetCore.Components.InjectAttribute] private AuthenticationStateProvider AuthenticationStateProvider { get; set; }
    }
}
#pragma warning restore 1591
