Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
 private Product MapProduct(product.Product product)
 {
     return(new Product()
     {
         Name = product.Name,
         UpdateDate = DateTime.Today,
         CreateDate = DateTime.Today,
         PricePerGram = product.PricePerGram
     });
 }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
 public IHttpActionResult UpdateProduct(product.Product product)
 {
     prod = new ProductOrc();
     return(Ok(prod.UpdateProduct(product)));
 }
Esempio n. 5
0
 /// <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));
 }
Esempio n. 6
0
 /// <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));
 }