Beispiel #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));
        }
Beispiel #2
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());
        }