using System;

using System.Collections.Generic;

using System.Linq;

using System.Threading.Tasks;

using Microsoft.AspNetCore.Http;

using Microsoft.AspNetCore.Mvc;

 

namespace Core2WebAPI.Controllers

{

    [Produces("application/json")]

    [Route("api/Vote")]

    public class VoteController : Controller

    {

        [HttpGet("RecordVote")]

        public int Vote()

        {

            int count = 0;

            if (HttpContext.Session.GetString("VoteCount") != null)

            {

                count = (int)HttpContext.Session.GetInt32("VoteCount");              

            }

 

            count++;

            HttpContext.Session.SetInt32("VoteCount", count);

 

            return count;

        }

 

        [HttpGet("GetVotes")]

        public int GetVotes()

        {

            int count = 0;

 

            if (HttpContext.Session.GetString("VoteCount") != null)

            {

                count = (int)HttpContext.Session.GetInt32("VoteCount");

            }

 

            return count;

        }

    }

}