using AppData;
using Newtonsoft.Json;
using NKC_SDK;
using System;

namespace NKC_WF.WebUserControls
{
    public partial class cmp_devUtils : BaseUserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void lbtResetStackBuild_Click(object sender, EventArgs e)
        {
            DataLayer.man.taSHL.resetPrepared(-9999);
        }

        protected void lbtResetNest_Click(object sender, EventArgs e)
        {
            DataLayer.man.taBL.resetNesting(-9999);
        }

        protected void lbtSaveLastAnsw_Click(object sender, EventArgs e)
        {
            string content = ComLib.lastRestAnsw();

            // deserializzo.
            baseNestAnsw batchProcAnsw = JsonConvert.DeserializeObject<baseNestAnsw>(content);

            // se non nullo...
            if (batchProcAnsw != null)
            {
                if (batchProcAnsw.OrderType == oType.BatchRequest)
                {
                    if (batchProcAnsw.ProcType == 1)
                    {
                        // deserializzo come BatchreqIniziale (stima)
                        nestReplyBatchInitial rispStima = JsonConvert.DeserializeObject<nestReplyBatchInitial>(content);
                        // 2020.01.16 salvo su mongoDb la risposta...
                        ComLib.man.saveEstAnsw(rispStima);
                    }
                    else
                    {
                        // deserializzo come BatchreqFinale
                        nestReplyBatchFinal rispNest = JsonConvert.DeserializeObject<nestReplyBatchFinal>(content);
                        // 2020.01.16 salvo su mongoDb la risposta...
                        ComLib.man.saveNestAnsw(rispNest);
                    }
                }
            }
        }

        protected void lbtResetProd_Click(object sender, EventArgs e)
        {
            DataLayer.man.taBL.resetProdCall();
        }
    }
}