예제 #1
0
        public IActionResult EditOrder(OrderItemsDTO orderItemDTO)
        {
            if (!ModelState.IsValid)
            {
                // View Bags for Selected Lists
                ViewBag.items = _orderItemsRepository.GetAllItems();
                ViewBag.units = _orderItemsRepository.GetAllUnits();

                return(View(orderItemDTO));
            }


            //var order = _mappingProfile.MappingDTOtoOrder(orderDTO);
            var orderItem = _mappingProfile.MappingDTOtoOrderItem(orderItemDTO);

            try
            {
                _orderItemsRepository.UpdateOrderItem(orderItem);
                return(RedirectToAction("GetOrder", new { orderId = orderItem.Id }));
            }
            catch
            {
                // View Bags for Selected Lists
                ViewBag.items = _orderItemsRepository.GetAllItems();
                ViewBag.units = _orderItemsRepository.GetAllUnits();
                return(View(orderItemDTO));
            }
        }
예제 #2
0
        public OrderItemsDTO DeleteOrder(OrderItemsDTO orderItemsDTO)
        {
            var OrderItems = _repository.GetOrderItems().WithOrderItemsId(orderItemsDTO.OrderId);

            _repository.RemoveOrderItems(OrderItems);

            return(orderItemsDTO);
        }
예제 #3
0
        public OrderItemsDTO ViewOrder(OrderItemsDTO orderItemsDTO)
        {
            var OrderItems = _repository.GetOrderItems().WithOrderItemsId(orderItemsDTO.OrderId);

            orderItemsDTO.Quantity   = OrderItems.Quantity;
            orderItemsDTO.MenuItemId = OrderItems.MenuItemId;

            return(orderItemsDTO);
        }
 public OrderItem MappingDTOtoOrderItem(OrderItemsDTO orderItemDto)
 {
     return(new OrderItem()
     {
         Id = orderItemDto.Id,
         Amount = orderItemDto.Amount,
         UnitId = orderItemDto.UnitId,
         ItemId = orderItemDto.ItemId,
         OrderId = orderItemDto.OrderId
     });
 }
예제 #5
0
 protected bool ValidateOrderItems(OrderItemsDTO orderItemsDTO)
 {
     if (orderItemsDTO.Quantity == 0)
     {
         return(false);
     }
     if (orderItemsDTO.MenuItemId == 0)
     {
         return(false);
     }
     return(true);
 }
예제 #6
0
        public OrderItemsDTO EditOrder(OrderItemsDTO orderItemsDTO)
        {
            var OrderItems = _repository.GetOrderItems().WithOrderItemsId(orderItemsDTO.OrderId);

            if (ValidateOrderItems(orderItemsDTO))
            {
                OrderItems.Quantity   = orderItemsDTO.Quantity;
                OrderItems.MenuItemId = orderItemsDTO.MenuItemId;
                _repository.PostOrderItems(OrderItems);
            }

            return(orderItemsDTO);
        }
예제 #7
0
        public static OrderItems Convert(OrderItemsDTO orderItems)
        {
            if (orderItems == null)
            {
                throw new ArgumentNullException(nameof(orderItems));
            }

            return(new OrderItems
            {
                Product = ProductConverter.Convert(orderItems.Product),
                Quantity = orderItems.Quantity,
                OrderId = orderItems.OrderId,
                ProductId = orderItems.Product.Id,
            });
        }
예제 #8
0
        public OrderItemsDTO CreateOrder(OrderItemsDTO orderItemsDTO)
        {
            if (ValidateOrderItems(orderItemsDTO))
            {
                var orderitem = new Orderitems()
                {
                    Quantity   = orderItemsDTO.Quantity,
                    OrderId    = orderItemsDTO.OrderId,
                    MenuItemId = orderItemsDTO.MenuItemId
                };

                _repository.PostOrderItems(orderitem);
                orderItemsDTO.OrderId = orderitem.OrderId;
            }

            return(orderItemsDTO);
        }
예제 #9
0
        public SarFcrmvhBuilder addItems(string orderId, IEnumerable <OrderItemsDTO> orderItems, OrderShippingDataDTO orderShippingData)
        {
            foreach (var orderItem in orderItems.Select((value, i) => new { i, value }))
            {
                OrderItemsDTO item = orderItem.value;
                Items.Add(new Sar_Fcrmvi()
                {
                    //Sar_Fcrmvi_Identi = orderId,
                    Sar_Fcrmvi_Nroitm = orderItem.i + 1,
                    Sar_Fcrmvi_Tippro = item.refId.Substring(0, 3),
                    Sar_Fcrmvi_Artcod = item.refId.Substring(3, 9),
                    Sar_Fcrmvi_Cantid = item.quantity,
                    Sar_Fcrmvi_Precio = null,
                    Usr_Fcrmvi_Deposi = orderShippingData.logisticsInfo[orderItem.i].deliveryIds[0].warehouseId,
                    Usr_Fcrmvi_Sector = "0",
                    Usr_Fcrmvi_Selsla = orderShippingData.logisticsInfo[orderItem.i].selectedSla,
                    Usr_Fcrmvi_Bonice = 0,
                    Usr_Fcrmvi_Coecar = 0,
                    Usr_Fcrmvi_Prevtx = item.price / 100
                });
            }

            return(this);
        }