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

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

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

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

    List<Question> questions;
    bool NewQuestion = false;

    protected override async Task OnInitializedAsync()
    {
        // Get the current user
        var user = (await authenticationStateTask).User;
        // Get the Question for the current user
        // We access QuestionService using @Service
        questions = await @Service.GetQuestionAsync(user.Identity.Name);
    }
    string strError = "";
    Question objQuestion = new Question();
    bool ShowPopup = false;
    bool ReadMorePopup = false;

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


    void AddNewQuestion()
    {
        //System.Diagnostics.Debug.WriteLine("read value =" + ReadMorePopup);
        // Make new Question
        objQuestion = new Question();
        // Set Id to 0 so we know it is a new record
        objQuestion.QuestionID = 0;
        // Open the Popup
        ShowPopup = true;
        //NewQuestion = true;
    }



    async Task SaveQuestion()
    {
        // Close the Popup
        ShowPopup = false;
        // Get the current user
        var user = (await authenticationStateTask).User;
        // A new Question will have newQuestion set to true
        if (objQuestion.QuestionID == 0)
        {
            // Create new Question
            Question objNewQuestion = new Question();
            objNewQuestion.text = objQuestion.text;
            objNewQuestion.Default = objQuestion.Default;
            objNewQuestion.value = objQuestion.value;
            objNewQuestion.display = objQuestion.display;


        

            // Save the result
            var result =
            @Service.CreateQuestionAsync(objNewQuestion);
        }
        else
        {
            // This is an update
            var result =
            @Service.UpdateQuestionAsync(objQuestion);
        }
        // Get the Question for the current user
        questions =
        await @Service.GetQuestionAsync(user.Identity.Name);
    }


    void EditQuestion(Question question)
    {
        //System.Diagnostics.Debug.WriteLine("read value =" + ReadMorePopup);
        // Set the selected Question
        // as the current Question
        objQuestion = question;
        // Open the Popup
        ShowPopup = true;
    }

    void ReadQuestion(Question question)
    {
        //System.Diagnostics.Debug.WriteLine("In Readmorepopup ");
        // Set the selected Question
        // as the current Question
        objQuestion = question;
        // Open the Popup
        ReadMorePopup = true;
        //System.Diagnostics.Debug.WriteLine(ReadMorePopup);
    }

    async Task DeleteQuestion()
    {
        // Close the Popup
        ShowPopup = false;
        // Get the Question

    }



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