Ejemplo n.º 1
0
        public GamePostModel getGames(string gameid)
        {
            GamePostModel data = new GamePostModel();

            errorMessage = string.Empty;
            try
            {
                var filter = Builders <GamePostModel> .Filter.Eq(x => x.id, ObjectId.Parse(gameid));

                var client     = new MongoClient(MongoConnectionString);
                var database   = client.GetDatabase(dbServerID);
                var collection = database.GetCollection <GamePostModel>("GamesMaster");
                data = collection.Find(filter).First();
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                FileLogger.AppendLog("DataSQL", LogType.Error, "getAllReports >> ", ex.Message);
            }
            return(data);
        }
Ejemplo n.º 2
0
        public bool addNewGame(GamePostModel game)
        {
            bool flag = false;

            try
            {
                var client     = new MongoClient(MongoConnectionString);
                var database   = client.GetDatabase(dbServerID);
                var collection = database.GetCollection <GamePostModel>("GamesMaster");
                game.is_validated        = false;
                game.submited_by_name    = objIdentification.Name;
                game.submited_by_user_id = objIdentification.ObjectID.ToString();
                game.submited_date       = DateTime.Now;
                collection.InsertOne(game);
                flag = true;
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                FileLogger.AppendLog("Rx ", LogType.Error, "getRx >> ", ex.Message);
            }
            return(flag);
        }