public async Task Add(UnicornModel item) { try { await _context.Unicorns.InsertOneAsync(item); } catch (Exception ex) { // log or manage the exception throw ex; } }
public async Task <bool> UpdateUnicorn(string id, UnicornModel item) { try { ReplaceOneResult actionResult = await _context.Unicorns .ReplaceOneAsync(n => n.Id.Equals(id) , item , new UpdateOptions { IsUpsert = true }); return(actionResult.IsAcknowledged && actionResult.ModifiedCount > 0); } catch (Exception ex) { // log or manage the exception throw ex; } }