AuthenticateController.cs 1.44 KB
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace AIAHTML5.API.Controllers
{
    public class AuthenticateController : ApiController
    {
        // GET api/authenticate
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/authenticate/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/authenticate
        public HttpResponseMessage Post([FromBody]JObject credentials)

        {
            dynamic userDetails = AIAHTML5.API.Models.Users.AuthenticateUser(credentials);


            //JsonSerializerSettings settings = new JsonSerializerSettings()
            //{
            //    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
            //    DateFormatHandling = DateFormatHandling.IsoDateFormat,
            //};

            return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(userDetails)) };

        }

        // PUT api/authenticate/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/authenticate/5
        public void Delete(int id)
        {
        }
    }
}