Users.cs 841 Bytes
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MongoDB.Driver;
using MongoDB.Bson;
using AIAHTML5.API.Properties;

namespace AIAHTML5.API.Models
{
    public class Users
    {
        internal static dynamic Authenticate(Newtonsoft.Json.Linq.JObject credentials)
        {
            var client = new MongoClient();
            var db = client.GetDatabase(Settings.Default.database);

            var col = db.GetCollection<dynamic>("Users");

            BsonDocument filter = new BsonDocument();
            filter.Add("username", credentials["username"].ToString());
            filter.Add("password", credentials["password"].ToString());

            dynamic userDetails = col.Find(filter).SingleOrDefault();

            return userDetails;

        }
    }
}