/// <summary> /// The method to create product. /// </summary> /// <param name="product">The product domain object</param> /// <returns>Return true or false; true indicates the the creation is successful.</returns> public bool CreateProduct(product.Product product) { dbContext.Products.Add(MapProduct(product)); var result = dbContext.SaveChanges(); return(result > 0 ? true : false); }
private Product MapProduct(product.Product product) { return(new Product() { Name = product.Name, UpdateDate = DateTime.Today, CreateDate = DateTime.Today, PricePerGram = product.PricePerGram }); }
/// <summary> /// The method to update the product details. /// </summary> /// <param name="product">The product domain object.</param> /// <returns>Return true or false; true indicates the the update is successful.</returns> public bool UpdateProduct(product.Product product) { var productToUpdate = dbContext.Products .Where(s => s.Id == product.Id) .FirstOrDefault(); productToUpdate.Name = product.Name; productToUpdate.UpdateDate = product.UpdateDate; productToUpdate.PricePerGram = product.PricePerGram; dbContext.Products.Add(productToUpdate); var result = dbContext.SaveChanges(); return(result > 0 ? true : false); }
public IHttpActionResult UpdateProduct(product.Product product) { prod = new ProductOrc(); return(Ok(prod.UpdateProduct(product))); }
/// <summary> /// The method to update the product details. /// </summary> /// <param name="product">The product domain object.</param> /// <returns>Return true or false; true indicates the the update is successful.</returns> public bool UpdateProduct(product.Product product) { productRep = new ProductRepository(); return(productRep.UpdateProduct(product)); }
/// <summary> /// The method to create product. /// </summary> /// <param name="product">The product domain object</param> /// <returns>Return true or false; true indicates the the creation is successful.</returns> public bool CreateProduct(product.Product product) { productRep = new ProductRepository(); CurrentGoldPricePerGram.Instance.currentGoldPricePerGram = product.PricePerGram; return(productRep.CreateProduct(product)); }