示例#1
0
        public IActionResult AdminView(int id)
        {
            var order = _orderRepository.GetOrderInclById(id);

            // map to dto and return view
            var orderDto = new OrderDTO();

            Object2ObjectMappings.OrderItemListToOrderItemDtoList(order.Items, orderDto.Items);
            Object2ObjectMappings.OrderToOrderDetailsDto(order, orderDto.DeliveryDetails);
            Object2ObjectMappings.OrderMainDataToOrderDto(order, orderDto);

            _breadcrumbNavBuilder.CreateForNode("CPanelOrderView", new { orderId = order.Id, orderName = ("Order #" + order.Id).ToString() }, this);

            return(View("AdminView", orderDto));
        }
示例#2
0
        public IActionResult Edit(int id)
        {
            // retrieve order and related data
            var order = _orderRepository.GetOrderInclById(id);

            var deliveryDetailsDTO = new OrderDetailsDTO();

            // get relevant delivery and payment data
            Object2ObjectMappings.OrderToOrderDetailsDto(order, deliveryDetailsDTO);

            // append to order DTO
            var orderDTO = new OrderDTO()
            {
                DeliveryDetails = deliveryDetailsDTO,
                Id            = order.Id,
                NoUserAccount = (String.IsNullOrEmpty(order.CustomerId))
            };

            _breadcrumbNavBuilder.CreateForNode("CPanelOrderEdit", new { orderId = order.Id, orderName = ("Order #" + order.Id).ToString() }, this);

            return(View(orderDTO));
        }
示例#3
0
        public IActionResult OnGetAsync(int id)
        {
            var userId = _userManager.GetUserId(User);

            if (string.IsNullOrEmpty(userId))
            {
                return(BadRequest("User not found."));
            }

            var order = _orderRepository.GetOrderInclById(id);

            //validate user
            if (order == null || !String.Equals(order.CustomerId, userId))
            {
                return(BadRequest("Order with such ID for current user doesn't exist."));
            }

            OrderDTO = new OrderDTO();
            Object2ObjectMappings.OrderItemListToOrderItemDtoList(order.Items, OrderDTO.Items);
            Object2ObjectMappings.OrderToOrderDetailsDto(order, OrderDTO.DeliveryDetails);
            Object2ObjectMappings.OrderMainDataToOrderDto(order, OrderDTO);

            return(Page());
        }