using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ViewModels;
using WebAPIServer.Common;

namespace WebAPIServer.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        [HttpGet()]
        public ReturnInfo GetAll_WebApiMethod(string VariableName)
        {
            ReturnInfo i = new ReturnInfo();
            i.isok = true;
            try
            {
                var result = StaticData.scope.GetVariable(VariableName);
                i.response = result;
            }
            catch (Exception ex)
            {
                i.isok = false;
                i.message = ex.Message;
            }
            return i;
        }
        [HttpPost()]
        public ReturnInfo UpdateData()
        {
            ReturnInfo i = new ReturnInfo();
            i.isok = true;
            try
            {
                StaticData.GetWebAPIMethod(); 
                i.response = "sucess";
            }
            catch (Exception ex)
            {
                i.isok = false;
                i.message = ex.Message;
            }
            return i;
        }
    }
}
