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); }
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); }
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); }