public async Task AddCue(CueMongo item) { try { await _context.Cues.InsertOneAsync(item); } catch (Exception ex) { // log or manage the exception throw ex; } }
public void Post([FromBody] CueMongo newCue) { _cueRepository.AddCue(new CueMongo { Id = newCue.Id, Question = newCue.Question, Answer = newCue.Answer, Created = DateTime.Now, Updated = DateTime.Now //,UserId = newCue.UserId }); }
public async Task <bool> UpdateCue(string id, CueMongo item) { try { var actionResult = await _context.Cues .ReplaceOneAsync(n => n.CueId.Equals(id) , item , new UpdateOptions { IsUpsert = true }); return(actionResult.IsAcknowledged && actionResult.ModifiedCount > 0); } catch (Exception ex) { // log or manage the exception throw ex; } }