Example #1
0
        public static string GetNewNotificationsForUser(string user)
        {
            DataAccess.MongoDB mdb = new DataAccess.MongoDB("RoutineManagement");
            List<BsonDocument> notifications = new List<BsonDocument>();
            string ret = "null";

            for (int i = 0; i < 600; i++)
            {

                notifications = mdb.Get(NOTIFICATION_COL_NAME, new BsonDocument("user", user).Add("sent", "false"));

                if (notifications.Count > 0)
                {
                    //convert new notifications to JSON string
                    ret = ParseNotifications(notifications, (item) =>
                    {

                        BsonDocument updated = (BsonDocument)item.Clone();
                        updated["sent"] = "true";
                        //mark notification as sent
                        mdb.Update(NOTIFICATION_COL_NAME, item, updated);

                    });

                    break;
                }

                System.Threading.Thread.Sleep(200);
            }

            return ret;
        }
Example #2
0
        public JsonResult GetProducts()
        {
            DataAccess.MongoDB mongo = new DataAccess.MongoDB("ProductsDataBase");

            var products = mongo.GetProducts();

            return(Json(products, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public static void ReadNotifications(string user)
        {
            List<BsonDocument> notifications = new List<BsonDocument>();

            DataAccess.MongoDB mdb = new DataAccess.MongoDB("RoutineManagement");

            notifications = mdb.Get(NOTIFICATION_COL_NAME, new BsonDocument("user", user).Add("seen", "false"));

            foreach (BsonDocument doc in notifications)
            {
                BsonDocument updated = (BsonDocument)doc.Clone();
                updated["seen"] = "true";
                mdb.Update(NOTIFICATION_COL_NAME, doc, updated);
            }
        }
Example #4
0
        public static string GetNotificationsForUser(string user)
        {
            List<BsonDocument> notifications = new List<BsonDocument>();
            DataAccess.MongoDB mdb = new DataAccess.MongoDB("RoutineManagement");

            notifications = mdb.Get(NOTIFICATION_COL_NAME, new BsonDocument("user", user).Add("sent", "true"), "date");

            return ParseNotifications(notifications);
        }
Example #5
0
 public static void ClearNotifications(string user)
 {
     DataAccess.MongoDB mdb = new DataAccess.MongoDB("RoutineManagement");
     mdb.Delete(NOTIFICATION_COL_NAME, new BsonDocument("user", user));
 }
Example #6
0
        public void Send()
        {
            BsonDocument d = new BsonDocument()
                                    .Add("id", BsonValue.Create(BsonType.ObjectId).ToString())
                                    .Add("date", Date)
                                    .Add("user", User)
                                    .Add("text", Text)
                                    .Add("seen", "false")
                                    .Add("sent", "false");

            DataAccess.MongoDB mdb = new DataAccess.MongoDB("RoutineManagement");

            mdb.Insert("Notification", d);
        }