ConfigurationController.cs 1.24 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Configuration;
using Newtonsoft.Json;

namespace AIAHTML5.API.Controllers
{
    public class ConfigurationController : ApiController
    {
        [Route("api/Configuration/GetConfigurationvalues")]
        [HttpGet]
         public HttpResponseMessage GetConfigurationvalues()
        {
            dynamic responseData;
            MyConfig mconfig = new MyConfig();
            mconfig.current_year= DateTime.Now.Year;
            mconfig.idleTime = Int32.Parse(ConfigurationManager.AppSettings["IDLE_TIME"]);
            mconfig.idelTimeOut = Int32.Parse(ConfigurationManager.AppSettings["IDLE_TIME_OUT"]);
            mconfig.pingInterval = Int32.Parse(ConfigurationManager.AppSettings["PING_INTERVAL"]);


            responseData = JsonConvert.SerializeObject(mconfig);
            
            return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(responseData) };
        }
    }
}
public class MyConfig
{
    public int current_year { get; set; }
    public int idleTime { get; set; }
    public int idelTimeOut { get; set; }
    public int pingInterval { get; set; }
}