#pragma checksum "C:\Users\jayt7\Source\Repos\Senior-Project\SPWA\Pages\Courses.razor" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "39c0218f6b5ddc42d7c678d5f9af0c2fc803ffcc"
// <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\Courses.razor"
using SPWA.DataAccess.Data.CourseService;

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

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

#line default
#line hidden
#nullable disable
    [Microsoft.AspNetCore.Components.RouteAttribute("/courses")]
    public partial class Courses : OwningComponentBase<CourseService>
    {
        #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\Courses.razor"
       

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

    List<Course> courses;
    bool NewCourse = false;

    protected override async Task OnInitializedAsync()
    {
        // Get the current user
        var user = (await authenticationStateTask).User;
        // Get the courses for the current user
        // We access courseService using @Service
        courses = await @Service.GetCourseAsync(user.Identity.Name);
    }
    string strError = "";
    Course objCourse = new Course();
    bool ShowPopup = false;
    bool ReadMorePopup = false;

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


    void AddNewCourse()
    {
        //System.Diagnostics.Debug.WriteLine("read value =" + ReadMorePopup);
        // Make new courses
        objCourse = new Course();
        // Set Id to 0 so we know it is a new record
        objCourse.CourseID = "";
        // Open the Popup
        ShowPopup = true;
        NewCourse = true;
    }



    async Task SaveCourse()
    {
        // Close the Popup
        ShowPopup = false;
        // Get the current user
        var user = (await authenticationStateTask).User;
        // A new Course will have newcourse set to true
        if (NewCourse == true)
        {
            // Create new Course
            Course objNewCourse = new Course();
            objNewCourse.CourseID = objCourse.CourseID;
            objNewCourse.CourseName = objCourse.CourseName;
            objNewCourse.Active = objCourse.Active;
            objNewCourse.TermId = objCourse.TermId;

            

            // Save the result
            var result =
            @Service.CreateCourseAsync(objNewCourse);
        }
        else
        {
            // This is an update
            var result =
            @Service.UpdateCourseAsync(objCourse);
        }
        // Get the courses for the current user
        courses =
        await @Service.GetCourseAsync(user.Identity.Name);
    }


    void EditCourse(Course course)
    {
        //System.Diagnostics.Debug.WriteLine("read value =" + ReadMorePopup);
        // Set the selected course
        // as the current course
        objCourse = course;
        // Open the Popup
        ShowPopup = true;
    }

    void ReadCourse(Course course)
    {
        //System.Diagnostics.Debug.WriteLine("In Readmorepopup ");
        // Set the selected course
        // as the current course
        objCourse = course;
        // Open the Popup
        ReadMorePopup = true;
        //System.Diagnostics.Debug.WriteLine(ReadMorePopup);
    }

    async Task DeleteCourse()
    {
        // Close the Popup
        ShowPopup = false;
        // Get the user

    }



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