﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ninject;

namespace homeWork_08.addVotes
{
    public partial class addNewVote : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (tb_descVote.Text != "")
            {
                string desc = tb_descVote.Text;

                BusinessLogicLayer.NinjKernel nj = new BusinessLogicLayer.NinjKernel();
                BusinessLogicLayer.VoteService bll_vs = nj.ninjectKernel.Get<BusinessLogicLayer.VoteService>();

                try
                {
                    int idNewVote = bll_vs.addVoteGetId(tb_descVote.Text);

                    int cnt = 2;
                    try
                    {
                        cnt = int.Parse(tb_cnt.Text);
                        if (cnt < 2 || cnt > 20)
                        {
                            cnt = 2;
                        }
                    }
                    catch { };

                    Response.Redirect("~/addVotes/addCategoryesToVote.aspx?idVote=" + idNewVote.ToString() + "&cnt=" + cnt.ToString());
                }
                catch { };
            }
        }


    }
}