Exemplo n.º 1
0
        public void CreateUserOperaions(UserOperations colleciton)
        {
            try
            {
                int Id = 0;
                if (UOperations.Any())
                {
                    Id = UOperations.Max(x => x.Id);
                }
                Id += 1;
                MongoCollection <UserOperations> MCollection = database.GetCollection <UserOperations>("UserOperations");
                BsonDocument doc = new BsonDocument {
                    { "Id", Id },
                    { "Operation", colleciton.Operation },
                    { "Result", colleciton.Result },
                    { "FirstValue", colleciton.FirstValue },
                    { "SecondValue", colleciton.SecondValue }
                };

                IMongoQuery query  = Query.EQ("Id", colleciton.Id);
                var         exists = MCollection.Find(query);
                if (exists.ToList().Count == 0)
                {
                    MCollection.Insert(doc);
                }
            }
            catch { }
        }
        public void Save(int operationType, OperationInput <long> input, OperationOutput <long> output)
        {
            UserOperations opr = new UserOperations();

            opr.Operation   = operationType;
            opr.Result      = output.Result.ToString();
            opr.FirstValue  = input.Num1.ToString();
            opr.SecondValue = input.Num2.ToString();
            _jatodb.UserOperations.Add(opr);
            _jatodb.SaveChanges();
        }