using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
using System.Net.Http;
using System.Web.Http;

namespace WebServer
{
    public class CommonController : BaseController
    {
        [HttpGet]
        public HttpResponseMessage Index()
        {
            var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
            var db = new EEEntities();

            var sb = new System.Text.StringBuilder();
            sb.AppendLine("List");
            sb.AppendLine("Paramter Gcode");
            sb.AppendLine("Paramter Grp");

            //System.Web.Http.Results.JsonResult<string> 
            //var json = JsonConvert.SerializeObject(liast);
            return new HttpResponseMessage()
            {
                Content = new StringContent(
                sb.ToString(),
                System.Text.Encoding.UTF8,
                "text/html")
            };


        }

        [HttpGet]
        public HttpResponseMessage List()
        {
            var getParams = Request.GetQueryNameValuePairs();// GetParameters(data);
            var db = new EEEntities();

            var vGcode = "EET1P";
            var vGrp = "99";
            var liast = db.Common.Where(t => t.gcode == vGcode && t.grp == vGrp).OrderBy(t => t.code).ToArray();

            //System.Web.Http.Results.JsonResult<string> 
            var json = JsonConvert.SerializeObject(liast);
            return new HttpResponseMessage()
            {
                Content = new StringContent(
                json.ToString(),
                System.Text.Encoding.UTF8,
                "application/json")
            };


        }

        
    }
}
