예제 #1
0
        public ActionResult CheckOut(CheckOutViewModel model)
        {
            if (ModelState.IsValid)
            {
                var order            = ProcessCheckOut(model, cartManager.MyCart);
                var orderNo          = orderProvider.CreateOrderFromCart(order);
                var encryptedOrderNo = RijndaelHelper.Encrypt(orderNo,
                                                              ConfigurationInstance[ConfigurationKeys.CryptographyKey]);
                string returnUrl = String.Format("{0}?o={1}", Url.Action("CheckOutSuccess"), encryptedOrderNo);

                return(Json(new
                {
                    Error = false,
                    OrderNo = orderNo,
                    ReturnUrl = returnUrl
                }));
            }

            var allErrors = ModelState.Values.SelectMany(v => v.Errors).Select(o => o.ErrorMessage);

            return(Json(new
            {
                Error = true,
                Errors = allErrors
            }));
        }