Exemplo n.º 1
0
 /// <summary>
 /// This method removes and existing product from the DbContext and saves it
 /// </summary>
 /// <param name="product"></param>
 /// <returns></returns>
 public async Task DeleteProductAsync(vacunados product)
 {
     try
     {
         dbContext.Product.Remove(product);
         await dbContext.SaveChangesAsync();
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// This method add a new product to the DbContext and saves it
 /// </summary>
 /// <param name="product"></param>
 /// <returns></returns>
 public async Task <vacunados> AddProductAsync(vacunados product)
 {
     try
     {
         dbContext.Product.Add(product);
         await dbContext.SaveChangesAsync();
     }
     catch (Exception)
     {
         throw;
     }
     return(product);
 }
Exemplo n.º 3
0
 /// <summary>
 /// This method update and existing product and saves the changes
 /// </summary>
 /// <param name="product"></param>
 /// <returns></returns>
 public async Task <vacunados> UpdateProductAsync(vacunados product)
 {
     try
     {
         var productExist = dbContext.Product.FirstOrDefault(p => p.Id == product.Id);
         if (productExist != null)
         {
             dbContext.Update(product);
             await dbContext.SaveChangesAsync();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(product);
 }