public ActionResult AdStorm()
        {
            SetMenuSelection("AdminAdStorm");

            if (Session["UserID"] == null || ((List <UserUserType>)Session["UserTypes"]).Where(i => i.UserType.Name == Constants.UserTypes.Admin).Count() == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                var       apps = mongo.GetCollection <MApp>().AsQueryable();
                DBContext db   = new DBContext();

                var collection = mongo.GetCollection <AppApproval>().AsQueryable();
                var query      = from t in collection
                                 where t.IsApproved == false
                                 select t.PackageID;

                List <MApp> unapproved = new List <MApp>();
                if (query != null && query.Count() > 0)
                {
                    foreach (var packageID in query)
                    {
                        MApp a = apps.Where(i => i.PackageID == packageID).FirstOrDefault();
                        if (a != null)
                        {
                            unapproved.Add(a);
                        }
                    }
                }

                ViewData["Unapproved"] = unapproved;

                query = from t in collection
                        where t.IsApproved == true
                        select t.PackageID;

                List <MApp> approved = new List <MApp>();

                if (query != null && query.Count() > 0)
                {
                    foreach (var packageID in query)
                    {
                        MApp a = apps.Where(i => i.PackageID == packageID).FirstOrDefault();
                        if (a != null)
                        {
                            approved.Add(a);
                        }
                    }
                }

                ViewData["Approved"] = approved;

                return(View());
            }
        }
Exemplo n.º 2
0
 public UpdateModifiersTests()
 {
     var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");
     _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false&strict=true");
     _collection = _server.GetCollection<Post>("Posts");
     _buildInfo = admin.BuildInfo();
 }
        protected bool CheckAppSecurity(string packageid)
        {
            if (Session["UserID"] == null || packageid == null)
            {
                return(false);
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                var collection = mongo.GetCollection <MetrixApp>();
                var app        = collection.AsQueryable().SingleOrDefault(i => i.PackageID == packageid);

                if (Session["UserID"] == null || ((List <UserUserType>)Session["UserTypes"]).Where(i => i.UserType.Name == Constants.UserTypes.Admin).Count() > 0)
                {
                    return(true);
                }

                if (app == null || app.UserID.ToString() != Session["UserID"].ToString())
                {
                    return(false);
                }

                return(true);
            }
        }
Exemplo n.º 4
0
 public void AddHighScore(Score score)
 {
     using (IMongo mongo = Mongo.Create("mongodb://localhost/worms"))
     {
         mongo.GetCollection <Score>("Score").Insert(score);
     }
 }
Exemplo n.º 5
0
 public void AddHighScore(Score score)
 {
     using (IMongo mongo = Mongo.Create(this.MongoURL))
     {
         mongo.GetCollection <Score>("Score").Insert(score);
     }
 }
        public void ApproveApp(string id)
        {
            if (id == null)
            {
                return;
            }

            if (Session["UserID"] == null || ((List <UserUserType>)Session["UserTypes"]).Where(i => i.UserType.Name == Constants.UserTypes.Admin).Count() == 0)
            {
                return;
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                var collection = mongo.GetCollection <AppApproval>();

                AppApproval aa = collection.AsQueryable().SingleOrDefault(i => i.PackageID == id);
                if (aa == null)
                {
                    return;
                }

                aa.IsApproved = true;
                collection.Save(aa);
            }
        }
        public JsonResult CheckName(string old, string name)
        {
            if (Session["UserID"] == null)
            {
                return(null);
            }

            if (old == name)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                var collection = mongo.GetCollection <AdContainer>().AsQueryable();
                var check      = from t in collection
                                 where t.ContainerName == name && t.UserID == new Guid(Session["UserID"].ToString()).ToString()
                                 select t;

                if (check.Count() > 0)
                {
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(false, JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemplo n.º 8
0
 public SCORMObjectModel(String connectionString)
 {
     _ConnectionString = connectionString;
     _Connection = Mongo.Create(connectionString);
     _DB = _Connection.GetCollection<SCORMObject>();
     _FileStore = Norm.GridFS.Helpers.Files<SCORMObject>(_DB);
 }
Exemplo n.º 9
0
        public UpdateModifiersTests()
        {
            var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");

            _server     = Mongo.Create("mongodb://localhost/NormTests?pooling=false&strict=true");
            _collection = _server.GetCollection <Post>("Posts");
            _buildInfo  = admin.BuildInfo();
        }
        public ActionResult SaveContainer(string packageid, FormCollection form)
        {
            if (!CheckAppSecurity(packageid))
            {
                return(RedirectToAction("Login", "Home"));
            }

            string oldName = form["hdnOldName"];

            List <AdNetwork> networks = MDB.Instance().GetAdNetworks();

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                var containers = mongo.GetCollection <AdContainer>();

                List <AdContainer> conList = (from t in containers.AsQueryable()
                                              where t.AppPackageID == packageid && t.ContainerName == oldName
                                              select t).ToList();

                if (conList.Count() == 0) //new container
                {
                    foreach (var item in networks)
                    {
                        AdContainer con = new AdContainer();
                        con.AppPackageID = packageid;
                        con.UserID       = new Guid(Session["UserID"].ToString()).ToString();

                        con.AdNetworkID   = item.ID;
                        con.AdNetworkName = item.Name;

                        conList.Add(con);
                    }
                }

                foreach (var con in conList)
                {
                    con.ContainerName = form["txtName"];
                    con.ContainerSize = form["ddlSize"];

                    AdNetwork network = networks.Where(i => i.ID == con.AdNetworkID).First();

                    string val = form["txtPercent" + network.ID];

                    if (val == string.Empty)
                    {
                        con.ShowPercentage = 0;
                    }
                    else
                    {
                        con.ShowPercentage = int.Parse(val);
                    }

                    containers.Save(con);
                }

                return(RedirectToAction("AdStorm/" + packageid, "Apps"));
            }
        }
Exemplo n.º 11
0
 public QueryTests()
 {
     var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");
     _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false");
     _collection = _server.GetCollection<Person>("People");
     _buildInfo = admin.BuildInfo();
     //cause the collection to exist on the server by inserting, then deleting some things.
     _collection.Insert(new Person());
     _collection.Delete(new { });
 }
Exemplo n.º 12
0
        public QueryTests()
        {
            var admin = new MongoAdmin("mongodb://localhost/admin?pooling=false&strict=true");

            _server     = Mongo.Create("mongodb://localhost/NormTests?pooling=false");
            _collection = _server.GetCollection <Person>("People");
            _buildInfo  = admin.BuildInfo();
            //cause the collection to exist on the server by inserting, then deleting some things.
            _collection.Insert(new Person());
            _collection.Delete(new { });
        }
        public ActionResult EditContainer(string packageid, string container)
        {
            if (!CheckAppSecurity(packageid))
            {
                return(RedirectToAction("Login", "Home"));
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                List <AdContainer> containers = mongo.GetCollection <AdContainer>().AsQueryable().Where(i => i.AppPackageID == packageid && i.ContainerName == container).ToList();

                AppApproval aa = mongo.GetCollection <AppApproval>().AsQueryable().SingleOrDefault(i => i.PackageID == packageid);

                ViewData["Approval"]   = aa;
                ViewData["Containers"] = containers;
                ViewData["AdNetworks"] = MDB.Instance().GetAdNetworks();

                return(View());
            }
        }
Exemplo n.º 14
0
        public List <Score> GetHighScores(int count)
        {
            List <Score> scores = null;

            using (IMongo mongo = Mongo.Create(this.MongoURL))
            {
                scores = mongo.GetCollection <Score>("Score").Find(new { },
                                                                   new { Value = Norm.OrderBy.Descending, CreatedAt = Norm.OrderBy.Descending }, count, 0).ToList <Score>();
            }

            return(scores);
        }
        public ActionResult Apps(FormCollection form)
        {
            SetMenuSelection("AdminApps");

            if (Session["UserID"] == null || ((List <UserUserType>)Session["UserTypes"]).Where(i => i.UserType.Name == Constants.UserTypes.Admin).Count() == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                DBContext db     = new DBContext();
                var       metrix = mongo.GetCollection <MetrixApp>().AsQueryable();
                var       apps   = mongo.GetCollection <MApp>().AsQueryable();

                List <MApp> appList = new List <MApp>();
                foreach (var item in metrix)
                {
                    MApp a = apps.SingleOrDefault(i => i.PackageID == item.PackageID);
                    if (a != null)
                    {
                        appList.Add(a);
                    }
                }

                ViewData["AppList"] = appList.OrderBy(i => i.Name).ToList();

                if (form.Count > 0)
                {
                    string package = form[0];
                    var    a       = metrix.SingleOrDefault(i => i.PackageID == package);

                    ViewData["App"] = a;
                }

                return(View());
            }
        }
Exemplo n.º 16
0
        public bool QualifiesForHall(int score)
        {
            bool qualifies = false;

            using (IMongo mongo = Mongo.Create(this.MongoURL))
            {
                IEnumerable <Score> scores = mongo.GetCollection <Score>("Score").Find(new { },
                                                                                       new { Value = Norm.OrderBy.Descending, CreatedAt = Norm.OrderBy.Descending }, HALL_THRESHOLD, 0).ToList <Score>();

                qualifies = scores.Count() == 0 || (scores.Last <Score>().Value <= score || scores.Count() < HALL_THRESHOLD);
            }

            return(qualifies);
        }
        public ActionResult AddContainer(string packageid)
        {
            if (!CheckAppSecurity(packageid))
            {
                return(RedirectToAction("Login", "Home"));
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                AppApproval aa = mongo.GetCollection <AppApproval>().AsQueryable().SingleOrDefault(i => i.PackageID == packageid);

                ViewData["Approval"]   = aa;
                ViewData["AdNetworks"] = MDB.Instance().GetAdNetworks();

                return(View());
            }
        }
        public ActionResult Reset()
        {
            if (Session["UserID"] == null || ((List <UserUserType>)Session["UserTypes"]).Where(i => i.UserType.Name == Constants.UserTypes.Admin).Count() == 0)
            {
                return(RedirectToAction("Login", "Home"));
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                var collection = mongo.GetCollection <AppApproval>();
                foreach (var item in collection.AsQueryable())
                {
                    item.IsApproved = false;
                    collection.Save(item);
                }

                return(RedirectToAction("Adstorm", "Admin"));
            }
        }
        public void DeleteContainer(string container)
        {
            if (Session["UserID"] == null)
            {
                return;
            }

            using (IMongo mongo = MDB.Instance().GetMongo())
            {
                var collection = mongo.GetCollection <AdContainer>();

                List <AdContainer> containers = collection.AsQueryable().Where(i => i.ContainerName == container && i.UserID == new Guid(Session["UserID"].ToString()).ToString()).ToList();

                foreach (var item in containers)
                {
                    collection.Delete(item);
                }
            }
        }
Exemplo n.º 20
0
        public void Save_should_insert_and_then_update_when_id_is_nullable_int()
        {
            var collection = _server.GetCollection <CheeseClubContactWithNullableIntId>();
            var subject    = new CheeseClubContactWithNullableIntId();

            collection.Save(subject);

            var a = collection.FindOne(new { subject.Id });

            //prove it was inserted.
            Assert.Equal(subject.Id, a.Id);

            subject.Name = "hello";
            collection.Save(subject);

            var b = collection.FindOne(new { subject.Id });

            //prove that it was updated.
            Assert.Equal(subject.Name, b.Name);

            _server.Database.DropCollection(typeof(CheeseClubContactWithNullableIntId).Name);
        }
Exemplo n.º 21
0
        public override void Add <T>(T entity)
        {
            Action a = () => mongo.GetCollection <T>().Insert(entity);

            actions.Add(a);
        }
Exemplo n.º 22
0
 public WhereQualifierTests()
 {
     _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false");
     _collection = _server.GetCollection<TestClass>("TestClasses");
 }
Exemplo n.º 23
0
 public IQueryable <T> All <T>() where T : class, new()
 {
     return(_provider.GetCollection <T>().AsQueryable());
 }
Exemplo n.º 24
0
 public MongoSearchQualifierTests()
 {
     _server = Mongo.Create(TestHelper.ConnectionString("pooling=false"));
     _coll   = _server.GetCollection <TestClass>("TestClasses");
 }
Exemplo n.º 25
0
 public WhereQualifierTests()
 {
     _server     = Mongo.Create("mongodb://localhost/NormTests?pooling=false");
     _collection = _server.GetCollection <TestClass>("TestClasses");
 }
Exemplo n.º 26
0
 public MongoSearchQualifierTests()
 {
     _server = Mongo.Create(TestHelper.ConnectionString("pooling=false"));
     _coll = _server.GetCollection<TestClass>("TestClasses");
 }
Exemplo n.º 27
0
 public Shoppers(IMongo conn)
 {
     _provider       = conn;
     this._queryable = conn.GetCollection <Shopper>().AsQueryable();
 }
Exemplo n.º 28
0
 public UpdateTests()
 {
     _server     = Mongo.Create("mongodb://localhost/NormTests?pooling=false");
     _collection = _server.GetCollection <CheeseClubContact>("CheeseClubContacts");
 }
 public void Init()
 {
     _store      = Mongo.Create("mongodb://localhost/test");
     _collection = _store.GetCollection <Dummy>();
 }
Exemplo n.º 30
0
 public void Delete <T>(T item) where T : class
 {
     _provider.GetCollection <T>().Delete(item);
 }
Exemplo n.º 31
0
 public UpdateTests()
 {
     _server = Mongo.Create("mongodb://localhost/NormTests?pooling=false");
     _collection = _server.GetCollection<CheeseClubContact>("CheeseClubContacts");
 }
Exemplo n.º 32
0
 public void Init()
 {
     _store = Mongo.Create("mongodb://localhost/test");
     _collection = _store.GetCollection<Dummy>();
 }