public void DeletePass()
        {
            Prd P = new Prd(db);
            ProductsController obj  = new ProductsController(P);
            ObjectResult       data = (ObjectResult)obj.DeleteProduct(2);

            //  ObjectResult data = (ObjectResult)controller.DeleteProduct(2);
            Assert.AreEqual(200, data.StatusCode);
        }
        public void DeleteFail()
        {
            Prd P = new Prd(db);
            ProductsController obj  = new ProductsController(P);
            BadRequestResult   data = (BadRequestResult)obj.DeleteProduct(290);

            //BadRequestResult data = (BadRequestResult)controller.DeleteProduct(290);
            Assert.AreEqual(400, data.StatusCode);
        }
        public void Test2Fail()
        {
            Prd P = new Prd(db);
            ProductsController obj  = new ProductsController(P);
            BadRequestResult   data = (BadRequestResult)obj.GetProduct(89);

            //BadRequestResult data = (BadRequestResult)controller.GetProduct(89);
            Assert.AreEqual(400, data.StatusCode);
        }
        public void Calculate(Prd p)
        {
            DateTimerManager.from = DateTime.Today;
            DateTimerManager.to = p.date;
            var nb = DateTimerManager.GetDays();
            double raise = 0;

            for (int i = 0; i < nb; i++)
                raise += p.price * p.param/100;

            if (p.date > DateTime.Today)
                p.isFuture = true;

            p.price = raise + (p.price*nb);
        }
        private void Search_Click(object sender, RoutedEventArgs e)
        {
            listview.Items.Clear();
            DateTime a = Date1.SelectedDate.Value.Date;
            DateTime b = Date2.SelectedDate.Value.Date;

            if (Date1 != null && Date2 != null && a <= b && a != null && b != null)
            {
                using (SqlConnection connection = new SqlConnection("Data Source=.;Initial Catalog=AppTraSua;Integrated Security=True"))
                {
                    String query = "exec getProductByDate '" + a + "','" + b + "'";
                    connection.Open();
                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            if (reader != null)
                            {
                                while (reader.Read())
                                {
                                    Prd prd = new Prd();
                                    prd.productNameR = reader["ProductName"].ToString();
                                    int cus = Convert.ToInt32(reader["CusTypeID"].ToString());
                                    if (cus == 1)
                                    {
                                        prd.CusTypeR = "Order tại quán";
                                    }
                                    else
                                    {
                                        prd.CusTypeR = "Delivery";
                                    }
                                    prd.quantityR = Convert.ToInt32(reader["SL"].ToString());
                                    prd.priceR    = Convert.ToInt32(reader["Price"].ToString());
                                    prd.totalR    = Convert.ToInt32(reader["TongTien"].ToString());
                                    listview.Items.Add(prd);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                listview.Items.Clear();
            }
        }
        /// <summary>
        /// Get Current Process Performance Details
        /// </summary>
        public Guid?Pp(Cx CurrCodeType)
        {
            if (C == null || C.Pp != true)
            {
                return(null);
            }

            Prd r = new Prd();

            if (Pr == null)
            {
                Pr = Process.GetCurrentProcess();
            }

            if (Pr != null)
            {
                try
                {
                    Pr.Refresh();
                    r.Ch = Pr.HandleCount;
                    r.Sx = Pr.NonpagedSystemMemorySize64;
                    r.Mx = Pr.PagedMemorySize64;
                    r.Sp = Pr.PagedSystemMemorySize64;
                    r.Px = Pr.PeakPagedMemorySize64;
                    r.Vp = Pr.PeakVirtualMemorySize64;
                    r.Wp = Pr.PeakWorkingSet64;
                    r.Mp = Pr.PrivateMemorySize64;
                    r.Tp = Pr.PrivilegedProcessorTime;
                    r.Ct = Pr.Threads.Count;
                    r.V  = Pr.VirtualMemorySize64;
                    r.W  = Pr.WorkingSet64;
                }
                catch (Exception exc)
                {
                    int ttt = 555;
                }
            }

            L.Pd.Add(r);
            return(r.PrdId);
        }
        static void Main(string[] args)
        {
            double pr = 0;
            DateTime dt = new DateTime();
            bool notValid = true;
            double vo = 0;

            while (notValid)
            {
                Console.WriteLine("Enter your price");
                var p = Console.ReadLine();
                notValid = !double.TryParse(p, out pr);
                if (notValid)
                    ServiceLocator.Instance.Logger.Log(string.Format("The price {0} is not valid !", p));
            }

            notValid = true;
            while (notValid)
            {
                Console.WriteLine("Enter future date");
                var d = Console.ReadLine();
                notValid = !DateTime.TryParse(d, out dt);
                if (notValid)
                    ServiceLocator.Instance.Logger.Log(string.Format("The future date {0} is not valid !", d));
            }

            notValid = true;
            while (notValid)
            {
                Console.WriteLine("Enter volatility");
                var v = Console.ReadLine();
                notValid = !double.TryParse(v, out vo);
                if(notValid)
                    ServiceLocator.Instance.Logger.Log(string.Format("The vloatility {0} is not valid !", v));
            }

            var pro = new Prd() {date = dt, param = vo, price = pr};
            ServiceLocator.Instance.Calc.Calculate(pro);
            Console.WriteLine(pro.price);
        }
 public ProductsController(Prd prd)
 {
     obj = prd;
 }