public async Task <bool> UpdateWorkDocumentAsync(WorkDocument document) { // Find the same document and update it. var filter = new FilterDefinitionBuilder <WorkDocument>().Eq(x => x.UserId, document.UserId); var replaceResult = await _workQueue.ReplaceOneAsync(filter, document); return(replaceResult.IsAcknowledged); }
public async Task <bool> CreateWorkDocumentAsync(WorkDocument document) { var filter = new FilterDefinitionBuilder <WorkDocument>().Eq(x => x.ID, document.ID); var docExists = (await FindByUserId(document.UserId)) != null; if (docExists) { // User already has a work job that needs to be appended too. return(false); } await _workQueue.InsertOneAsync(document); return(true); }