示例#1
0
 // 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);
     }
 }
示例#2
0
        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);
            }
        }
示例#3
0
 public async Task Create(ValuePairTest value)
 {
     await _context.TestValues.InsertOneAsync(value);
 }
示例#4
0
        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);
        }
示例#5
0
 // Insere novo valor no banco de dados
 public void InsertValue(ValuePairTest value)
 {
     value.id = Guid.NewGuid().ToString();
     _context.TestValues.InsertOne(value);
 }