ConfigurationController.cs 1.5 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"]);
            mconfig.serverPath = ConfigurationManager.AppSettings["ANIMATION_HOSTING_SERVER"];
            mconfig.fileSize = Int32.Parse(ConfigurationManager.AppSettings["UploadMaxFileSize"]);

            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; }
    public string serverPath { get; set; }
    public int fileSize { get; set; }
}