Beispiel #1
0
        public IActionResult Create([FromBody] CreateOrderViewModel createOrderViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var mappedInput = mapper.Map <CreateOrderInput>(createOrderViewModel);
                    //create new order
                    orderAppService.Create(mappedInput);

                    return(Json(new
                    {
                        success = true,
                        redirectUrl = Url.Action("Index", "Order")
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    errors = new { ex.Message }
                }));
            }

            return(NotFound());
        }
Beispiel #2
0
        public ActionResult Index()
        {
            //_bookAppService.Create(new BookDto
            //{
            //    Name = "张三1",
            //    Price = 200,
            //    PublishDate = DateTime.Now
            //});
            // _bookAppService.GetTedtList();
            //_blogAppService.GetList();
            //_blogAppService.Create(new AppServers.BlogServer.Dto.BlogDto {
            //    CreateTime = DateTime.Now,
            //    Url = "http://"
            //});
            _orderAppService.Create(
                new OrderDto
            {
                Address    = "北京",
                CreateTime = DateTime.Now,
                UserName   = "******",
                Items      = new List <OrderItemDto> {
                    new OrderItemDto {
                        Num       = 2,
                        ProductId = 6,
                    }
                }
            }
                );

            _orderAppService.GetTest(15);

            return(View());
        }
        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();

            TryUpdateModel(order);

            try
            {
                if (string.Equals(values["PromoCode"], PromoCode,
                                  StringComparison.OrdinalIgnoreCase) == false)
                {
                    return(View(order));
                }
                else
                {
                    order.Username  = User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    //Save Order
                    _orderAppService.Create(order);

                    //Process the order
                    var cart = ShoppingCart.GetCart(this.HttpContext);
                    cart.CreateOrder(order);

                    return(RedirectToAction("Complete",
                                            new { id = order.OrderId }));
                }
            }
            catch
            {
                //Invalid - redisplay with errors
                return(View(order));
            }
        }
Beispiel #4
0
        public HttpResponseMessage Post(ValidatableOrder order)
        {
            var request = new CreateOrderRequest()
            {
                User  = UserSession,
                Order = order
            };

            var response = _orderAppService.Create(request);

            return(Request.BuildResponse(HttpStatusCode.Created, response));
        }