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)); } }
public OrderItemsDTO DeleteOrder(OrderItemsDTO orderItemsDTO) { var OrderItems = _repository.GetOrderItems().WithOrderItemsId(orderItemsDTO.OrderId); _repository.RemoveOrderItems(OrderItems); return(orderItemsDTO); }
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 }); }
protected bool ValidateOrderItems(OrderItemsDTO orderItemsDTO) { if (orderItemsDTO.Quantity == 0) { return(false); } if (orderItemsDTO.MenuItemId == 0) { return(false); } return(true); }
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); }
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, }); }
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); }
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); }