public ActionResult Deleteorder(int id)
        {
            TempOrderProduct temporderProduct = temporderProductRepository.Get(id);
            TempOrder        torder           = temporderrepo.Get(temporderProductRepository.Get(id).OrderID);

            temporderProductRepository.Delete(temporderProductRepository.Get(id).ProductOrderID);
            temporderrepo.Delete(torder.OrderID);

            return(Json("success"));
        }
        public IHttpActionResult PostdeleteOrder(int id)
        {
            TempOrderProduct temporderProduct = temporderProductRepository.Get(id);
            TempOrder        torder           = temporderrepo.Get(Convert.ToInt32(temporderProductRepository.Get(id).TempOrderId));

            temporderProductRepository.Delete(temporderProductRepository.Get(id).TempOrderProductID);
            temporderrepo.Delete(torder.TempOrderId);

            return(Ok("success"));
        }
        public IHttpActionResult Post(int id)
        {
            TempOrderProduct temporderProduct = temporderProductRepository.Get(id);
            var       pid    = temporderProduct.ProductID;
            TempOrder torder = temporderrepo.Get(Convert.ToInt32(temporderProductRepository.Get(id).TempOrderId));

            temporderProductRepository.Delete(temporderProductRepository.Get(id).TempOrderProductID);
            temporderrepo.Delete(Convert.ToInt32(torder.TempOrderId));


            Order order = new Order();

            order.date          = DateTime.Now;
            order.PayMentMethod = torder.PayMentMethod;
            order.Quantity      = torder.Quantity;
            order.Size          = torder.Size;
            order.totalAmount   = torder.totalAmount;
            orderrepo.Insert(order);


            OrderProduct orderProduct = new OrderProduct();

            orderProduct.ProductHistoryId = producthis.GetByProductNameCategory(productrepo.Get(Convert.ToInt32(pid)).Product_name, productrepo.Get(Convert.ToInt32(pid)).MainCategoryId).ProductHistoryId;
            orderProduct.CustomerID       = temporderProduct.CustomerID;
            orderProduct.OrderID          = order.OrderID;
            productorderrepo.Insert(orderProduct);

            Profit profit = new Profit();

            ProductHistory phis = producthis.Get(orderProduct.ProductHistoryId);

            profit.OrderProductId = orderProduct.OrderProductId;
            if (phis.Sale != null)
            {
                var p  = (double)phis.UnitPrice;
                var v  = Convert.ToDouble(phis.Sale.Amount) / 100;
                var c1 = (p - (p * v));
                profit.ProfitAmount = ((decimal)c1 - phis.Cost) * order.Quantity;
            }
            else
            {
                profit.ProfitAmount = (phis.UnitPrice - phis.Cost) * order.Quantity;
            }


            profitrepo.Insert(profit);

            return(Ok("success"));
        }
        public ActionResult Confirmorder(int id)
        {
            TempOrderProduct temporderProduct = temporderProductRepository.Get(id);
            TempOrder        torder           = temporderrepo.Get(temporderProductRepository.Get(id).OrderID);

            temporderProductRepository.Delete(temporderProductRepository.Get(id).ProductOrderID);
            temporderrepo.Delete(temporderProduct.OrderID);


            Order order = new Order();

            order.date          = DateTime.Now;
            order.PayMentMethod = torder.PayMentMethod;
            order.Quantity      = torder.Quantity;
            order.Size          = torder.Size;
            order.totalAmount   = torder.totalAmount;
            orderrepo.Insert(order);


            OrderProduct orderProduct = new OrderProduct();

            orderProduct.ProductID  = temporderProduct.ProductID;
            orderProduct.CustomerID = temporderProduct.CustomerID;
            orderProduct.OrderID    = order.OrderID;
            productorderrepo.Insert(orderProduct);

            Profit profit = new Profit();

            ProductHistory phis = producthis.Get(orderProduct.ProductID);

            profit.ProductOrderID = orderProduct.ProductOrderID;
            if (phis.Sale != null)
            {
                var p  = (double)phis.UnitPrice;
                var v  = Convert.ToDouble(phis.Sale.Amount) / 100;
                var c1 = (p - (p * v));
                profit.ProfitAmount = ((decimal)c1 - phis.Cost) * order.Quantity;
            }
            else
            {
                profit.ProfitAmount = (phis.UnitPrice - phis.Cost) * order.Quantity;
            }


            profitrepo.Insert(profit);

            return(Json("success"));
        }
Esempio n. 5
0
        public IHttpActionResult Get(int id, string paymentmethod)
        {
            var x = ProductController.cartviewlist;
            List <CartViewModel> cartlist = ProductController.cartviewlist;

            var date = DateTime.Now;

            foreach (var item in cartlist)
            {
                if (item.product.SizeCategory == "other")
                {
                    Product p1 = new Product();
                    p1         = productrepo.Get(item.product.ProductId);
                    p1.OnHand -= item.count;
                    productrepo.Update(p1);
                }
                else
                {
                    ProductSize psize = new ProductSize();
                    psize       = productsizeModel.Get(item.size.ProductSizeID);
                    psize.Count = (psize.Count - item.count);
                    if (psize.Count == 0)
                    {
                        productsizeModel.Delete(psize.ProductSizeID);
                    }
                    else
                    {
                        productsizeModel.Update(psize);
                    }
                }

                TempOrder order = new TempOrder();
                order.date     = date;
                order.Quantity = item.count;
                if (item.product.Sale != null)
                {
                    var p  = (double)item.product.UnitPrice;
                    var v  = Convert.ToDouble(item.product.Sale.Amount) / 100;
                    var c1 = (p - (p * v));
                    order.totalAmount = (decimal)(item.count * c1);
                }
                else
                {
                    order.totalAmount = (item.count * item.product.UnitPrice);
                }
                if (item.product.SizeCategory != "other")
                {
                    order.Size = item.size.SizeName;
                }

                order.PayMentMethod = paymentmethod;
                temporderrepo.Insert(order);

                TempOrderProduct orderproduct = new TempOrderProduct();
                orderproduct.CustomerID  = id;
                orderproduct.TempOrderId = order.TempOrderId;
                orderproduct.ProductID   = item.product.ProductId;
                temporderproductrepo.Insert(orderproduct);

                /* Profit profit = new Profit();
                 * profit.ProductOrderID = orderproduct.ProductOrderID;
                 * if (item.product.Sale != null)
                 * {
                 *   var p = (double)item.product.UnitPrice;
                 *   var v = Convert.ToDouble(item.product.Sale.Amount) / 100;
                 *   var c1 = (p - (p * v));
                 *   profit.ProfitAmount = ((decimal)c1 - item.product.Cost) * item.count;
                 * }
                 * else
                 * {
                 *   profit.ProfitAmount = (item.product.UnitPrice - item.product.Cost) * item.count;
                 * }
                 *
                 *
                 * profitrepo.Insert(profit);*/
            }


            ProductController.cartviewlist.Clear();

            return(Ok("SuccessView"));
        }
Esempio n. 6
0
        public ActionResult UpdateOrderInformation()
        {
            List <CartViewModel> cartlist = new List <CartViewModel>();

            cartlist = (List <CartViewModel>)Session["cart"];
            var date = DateTime.Now;

            foreach (var item in cartlist)
            {
                if (item.product.SizeCategory == "other")
                {
                    Product p1 = new Product();
                    p1         = productrepo.Get(item.product.Product_id);
                    p1.OnHand -= item.count;
                    productrepo.Update(p1);
                }
                else
                {
                    ProductSize psize = new ProductSize();
                    psize       = productsizeModel.Get(item.size.ProductSizeID);
                    psize.Count = (psize.Count - item.count);
                    if (psize.Count == 0)
                    {
                        productsizeModel.Delete(psize.ProductSizeID);
                    }
                    else
                    {
                        productsizeModel.Update(psize);
                    }
                }

                TempOrder order = new TempOrder();
                order.date     = date;
                order.Quantity = item.count;
                if (item.product.Sale != null)
                {
                    var p  = (double)item.product.UnitPrice;
                    var v  = Convert.ToDouble(item.product.Sale.Amount) / 100;
                    var c1 = (p - (p * v));
                    order.totalAmount = (decimal)(item.count * c1);
                }
                else
                {
                    order.totalAmount = (item.count * item.product.UnitPrice);
                }
                if (item.product.SizeCategory != "other")
                {
                    order.Size = item.size.SizeName;
                }

                order.PayMentMethod = (string)Session["paymentmethod"];
                temporderrepo.Insert(order);

                TempOrderProduct orderproduct = new TempOrderProduct();
                orderproduct.CustomerID = (int)Session["LoginID"];
                orderproduct.OrderID    = order.OrderID;
                orderproduct.ProductID  = productHistory.GetByProductNameCategory(item.product.Product_name, item.product.CategoryID).Product_id;
                temporderproductrepo.Insert(orderproduct);

                /* Profit profit = new Profit();
                 * profit.ProductOrderID = orderproduct.ProductOrderID;
                 * if (item.product.Sale != null)
                 * {
                 *   var p = (double)item.product.UnitPrice;
                 *   var v = Convert.ToDouble(item.product.Sale.Amount) / 100;
                 *   var c1 = (p - (p * v));
                 *   profit.ProfitAmount = ((decimal)c1 - item.product.Cost) * item.count;
                 * }
                 * else
                 * {
                 *   profit.ProfitAmount = (item.product.UnitPrice - item.product.Cost) * item.count;
                 * }
                 *
                 *
                 * profitrepo.Insert(profit);*/
            }
            Session["cart"] = null;

            return(RedirectToAction("SuccessView"));
        }