public async Task Add(ProductMongoDB product) { try{ await db.Product.InsertOneAsync(product); }catch { throw; } }
public async Task Update(ProductMongoDB product) { try { await db.Product.ReplaceOneAsync(filter : g => g.Id == product.Id, replacement : product); } catch { throw; } }
public async Task UpdateById(ProductMongoDB product, string id) { try { FilterDefinition <ProductMongoDB> filter = Builders <ProductMongoDB> .Filter.Eq("Id", id); product.Id = id; var result = await db.Product.ReplaceOneAsync(filter, product); } catch { throw; } }
public async Task <ActionResult> UpdateProductById(string id, ProductMongoDB product) { await _repository.UpdateById(product, id); return(Ok(product)); }
public async Task <ActionResult> UpdateProduct(ProductMongoDB product) { await _repository.Update(product); return(Ok(product)); }
public async Task <ActionResult> AddProduct(ProductMongoDB product) { await _repository.Add(product); return(Ok(product)); }