Example #1
0
 public async Task AddCue(CueMongo item)
 {
     try
     {
         await _context.Cues.InsertOneAsync(item);
     }
     catch (Exception ex)
     {
         // log or manage the exception
         throw ex;
     }
 }
Example #2
0
 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
     });
 }
Example #3
0
        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;
            }
        }