using MongoDB.Bson; using MongoDB.Driver; using System; using System.Collections.Generic; using System.Configuration; namespace DentalDecks.Server.Models { public class ApplicationSettings { public static dynamic GetApplicationSettings(string applicationName, string userId = null) { try { var client = new MongoClient(); var db = client.GetDatabase(ConfigurationManager.AppSettings["database"]); var col = db.GetCollection("app-settings"); dynamic appSettings = col.Find(Builders.Filter.Eq("app", applicationName)).Limit(1).SingleOrDefault(); //if (userId != null) //{ // var colUser = db.GetCollection("users"); // dynamic user = colUser.Find(Builders.Filter.Eq("_id", ObjectId.Parse(userId))).SingleOrDefault(); // if (user != null) // { // string role = user.role.ToString(); // for (int i = 0; i < appSettings.menu.menuItems.Count; i++) // { // //List menuItems = new List(); // for (int j = 0; j < appSettings.menu.menuItems[i].roles.Count; j++) // { // if (appSettings.menu.menuItems[i].roles[j].ToString() == role) // { // } // } // } // } //} return appSettings; } catch (Exception ex) { return null; } } } }