Exemple #1
0
        protected async Task <BoolResult> UpdateAsync(string id, UpdateDefinition <T> update)
        {
            var result = new BoolResult();

            try
            {
                var collection = GetCollection();
                var filter     = GetFilterById(id);
                await collection.UpdateOneAsync(filter, update);

                result.SetSucces();
            }
            catch (Exception ex)
            {
                result.SetError(ex);
            }
            return(result);
        }
Exemple #2
0
        private async Task <BoolResult> AddAsync(T item)
        {
            var result = new BoolResult();

            try
            {
                var collection = GetCollection();
                await collection.InsertOneAsync(item);

                result.SetSucces();
            }
            catch (Exception ex)
            {
                result.SetError(ex);
            }

            return(result);
        }
Exemple #3
0
        public async Task <BoolResult> RemoveAsync(ObjectId id)
        {
            var result = new BoolResult();

            try
            {
                var collection = GetCollection();
                var filter     = GetFilterById(id);
                await collection.DeleteOneAsync(filter);

                result.SetSucces();
            }
            catch (Exception ex)
            {
                result.SetError(ex);
            }

            return(result);
        }
        public BoolResult UpdateUseVolumeAndWeight(string socetId, double weight, int volume)
        {
            var result = new BoolResult();

            try
            {
                var socet = GetById(socetId);
                socet.UseVolume += volume;
                socet.UseWeight += weight;
                Update(socet);
                result.SetSucces();
            }
            catch (Exception ex)
            {
                result.SetError(ex);
            }

            return(result);
        }