Esempio n. 1
0
        public ActionResult orderAjaxchuli(int orderID, decimal yinfu, decimal Daifu, decimal shifu, string zhifufanshi)
        {
            Orderinfo or = db.Orderinfo.Find(orderID);

            or.Payable       = yinfu;
            or.Tobepaid      = Daifu;
            or.Hnrb          = shifu;
            or.Paymentmethod = zhifufanshi;
            or.Oderstate     = 2;//状态改为2 1、未处理2、已处理
            db.SaveChanges();
            return(RedirectToAction("Yichuliorder"));
        }
Esempio n. 2
0
        public ActionResult CreateOrder(Orderinfo order)
        {
            var cookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (cookie == null)
            {
                return(RedirectToAction("Login", "Login"));
            }

            var ticket = FormsAuthentication.Decrypt(cookie.Value);

            var customer_service = new CustomerService();
            var shopping_service = new ShoppingcartDetailsService();

            var user = customer_service.FindByCustomerAccount(ticket.Name);

            var neworder = new Order();

            neworder.Address         = order.Address;
            neworder.Payment         = order.Payment;
            neworder.Transport       = order.Transport;
            neworder.OrderDay        = DateTime.Now;
            neworder.StatusUpdateDay = DateTime.Now;
            neworder.Status          = "處理中";
            neworder.CustomerID      = user.CustomerID;

            var ShoppingcartList = shopping_service.FindByCustomer(user.CustomerID).ToList();

            if (ShoppingcartList.Count == 0)
            {
                return(RedirectToAction("detail"));
            }

            var status = shopping_service.ConfirmOrders(ShoppingcartList, neworder);

            if (status == "OrderSuccess")
            {
                return(RedirectToAction("order"));
            }
            else
            {
                return(RedirectToAction("detail"));
            }
        }
Esempio n. 3
0
        public ActionResult Create(OrderInput dto)

        {
            var apiRep = new APIResponse();
            var userId = string.Empty;

            if (HttpContext.User.Identity is ClaimsIdentity identity)
            {
                userId = identity.FindFirst(ClaimTypes.Name).Value;
            }

            List <Cart> cartss = _cartService.Get();

            if (cartss == null)
            {
                throw new Exception("Can't not find cart");
            }

            foreach (Cart c in cartss)
            {
                if (c.UserId == userId)
                {
                    List <Pro> Pros = new List <Pro>();
                    for (var index = 0; index < c.Products.Length; index++)
                    {
                        Pro     pro     = new Pro();
                        Product product = new Product();
                        product       = _productService.GetId(c.Products[index].ProductId);
                        pro.name      = product.ProductName;
                        pro.provider  = product.Provider;
                        pro.price     = product.Price;
                        pro.Amount    = c.Products[index].Amount;
                        pro.ProductId = c.Products[index].ProductId;
                        Pros.Add(pro);
                    }
                    var oi = new Orderinfo
                    {
                        carts           = Pros.ToArray(),
                        CashType        = dto.CashType,
                        ReceiverAdderss = dto.ReceiverAddress,
                        OrderDate       = dto.OrderDate,
                        Phone           = dto.Phone,
                        Name            = dto.Name,

                        Note   = dto.Note,
                        status = "Unconfimred"
                    };
                    var Order = new Order
                    {
                        AccountId = userId,
                        orderinfo = oi
                    };

                    _orderService.Insert(Order);
                    _cartService.Delete(c);
                    apiRep.Error = false;
                    apiRep.Data  = Order;
                }
            }
            return(Ok(apiRep));
        }