// Editar valor public bool EditById(ValuePairTest value) { try { ReplaceOneResult updateResult = _context.TestValues.ReplaceOne(filter: g => g.id == value.id, replacement: value); return(updateResult.IsAcknowledged && updateResult.ModifiedCount > 0); } catch (Exception ex) { throw new Exception("Erro ao atualizar o valor.", ex); } }
public ValuePairTest GetValueById(string id) { try { ValuePairTest value = new ValuePairTest(); value = _context.TestValues.Find(x => x.id.Equals(id)).FirstOrDefault(); return(value); } catch (Exception ex) { throw new Exception("Erro ao recuperar valor", ex); } }
public async Task Create(ValuePairTest value) { await _context.TestValues.InsertOneAsync(value); }
public async Task <bool> Update(ValuePairTest value) { ReplaceOneResult updateResult = await _context.TestValues.ReplaceOneAsync(filter : g => g.id == value.id, replacement : value); return(updateResult.IsAcknowledged && updateResult.ModifiedCount > 0); }
// Insere novo valor no banco de dados public void InsertValue(ValuePairTest value) { value.id = Guid.NewGuid().ToString(); _context.TestValues.InsertOne(value); }