Exemplo n.º 1
0
        public void Execute()
        {
            try
            {
                using (var context = new ContextClass())
                {
                    var product = new Product();
                    //Console.WriteLine("enter the productId");
                    //product.productId = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("enter productName");
                    product.productName = Console.ReadLine();
                    Console.WriteLine("enter productStock");
                    product.productStock = Console.ReadLine();
                    Console.WriteLine("enter productPrice");
                    product.productPrice = Convert.ToDecimal(Console.ReadLine());

                    context.ProductDetails.Add(product);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public void Excecute()
        {
            try
            {
                using (var context = new ContextClass())
                {
                    var order = new OrderDetail();
                    Console.WriteLine("enter orderQuantity");
                    order.orderQuantity = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("orderDiscount");
                    order.orderDiscount = Convert.ToDecimal(Console.ReadLine());
                    Console.WriteLine("enter productPrice");
                    order.productPrice = Convert.ToDecimal(Console.ReadLine());
                    Console.WriteLine("enter productId");
                    order.productId = Convert.ToInt32(Console.ReadLine());

                    context.OrderDetails.Add(order);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }