Exemple #1
0
        public bool Modify(Order order)
        {
            var result = _mongoClient.Update(Convert(order)) > 0;

            _cache.Add(order.Id, order);
            return(result);
        }
Exemple #2
0
        public void UpdateSuccess()
        {
            var model = new GetModelService().GetModel();

            _client.Add(model);
            model.Int         = 199;
            model.String      = Guid.NewGuid().ToString();
            model.DateTimeUtc = DateTime.UtcNow;
            _client.Update(model);
            var result = _client.GetQueryable <TestModel>().FirstOrDefault(p => p.Id == model.Id);

            Assert.Equal(model.ToJson(), result.ToJson());
        }
        public bool Update(ArticleCategory category, int version)
        {
            var entity = _client.GetQueryable <ArticleCategoryEntity>().FirstOrDefault(e => e.Id == category.Id);

            if (entity == null)
            {
                entity = new ArticleCategoryEntity(category)
                {
                    Version = ++version
                };
                _client.Add(entity);
                return(true);
            }

            if (entity.Version != version)
            {
                return(false);
            }

            entity.Version++;
            _client.Update(entity);
            return(true);
        }