Esempio n. 1
0
        public ActionResult OrderClose(int orderID)
        {
            List <AutoPartsOrderWrapper> oa = dbObject.GetAllAutopartsByOrderID(orderID);
            decimal totalPrice = 0;

            if (oa != null && oa.Count() > 0)
            {
                foreach (AutoPartsOrderWrapper apow in oa)
                {
                    totalPrice += CalculatePricePerAutopart(apow.hours, apow.price, apow.quantity);
                }

                int    statusResponse = dbObject.CloseOrderByID(orderID, totalPrice);
                string dateEnded      = Models.Utils.Util.GetSimpleDate(Models.Utils.Util.GetCurrentTime());

                if (statusResponse != 0)
                {
                    var response = new
                    {
                        order_id    = orderID,
                        total_price = totalPrice,
                        date_ended  = dateEnded
                    };

                    return(Json(response, JsonRequestBehavior.AllowGet));
                }
            }

            var errorResponse = new
            {
                message = "An error ocurred while trying to close the order from the database, please try again later"
            };

            return(Json(errorResponse, JsonRequestBehavior.DenyGet));
        }
Esempio n. 2
0
        public ActionResult AutoPartEdit(int orderID)
        {
            List <AutoPartsOrderWrapper> aoList = dbWrapper.GetAllAutopartsByOrderID(orderID);

            var model = new AutopartsOrderInfo
            {
                orderID = orderID,
                apo     = aoList
            };

            return(View(model));
        }