Пример #1
0
        public async Task <IActionResult> Edit(int orderId)
        {
            var order = await this.ordersService.GetBaseById(orderId);

            var statuses = await this.orderStatusService.GetAll <AdminOrderStatusViewModel>();

            var orderProducts = this.mapper.Map <List <AdminOrderProductViewModel> >(order.OrderProducts);

            var orderViewModel = new AdminOrderInputModel
            {
                Id                   = order.Id,
                UserId               = order.User.Id,
                UserName             = order.User.UserName,
                OrderAddress         = order.OrderAddress,
                OrderStatusId        = order.OrderStatusId,
                OrderStatuses        = statuses,
                OrderProducts        = orderProducts,
                CouponCodeId         = order.CouponCodeId,
                CouponCode           = order.CouponCode,
                TotalPrice           = order.TotalPrice,
                TotalPriceDiscounted = order.TotalPriceDiscounted,
                OrderNotes           = order.OrderNotes,
            };

            return(this.View(orderViewModel));
        }
Пример #2
0
        public async Task <IActionResult> Edit(AdminOrderInputModel inputModel)
        {
            var order = await this.ordersService.GetBaseById(inputModel.Id);

            var orderStatus = await this.orderStatusService.GetById(inputModel.OrderStatusId);

            order.OrderStatus = orderStatus;

            await this.ordersService.UpdateAsync(order);

            return(this.RedirectToAction("View", new { orderId = order.Id }));
        }