private void UpdateGroupsForTransferredItem(Item newItem, Order destinationOrder) { var group = destinationOrder.ServingCourseGroups.FirstOrDefault(s => s.GroupName == newItem.SCourseGroup.GroupName); if (group != null) { newItem.SCourseGroup = group; } else { newItem.SCourseGroup.Order = destinationOrder; newItem.SCourseGroup.OrderKey = destinationOrder.OrderKey; destinationOrder.ServingCourseGroups.Add(newItem.SCourseGroup); } group = destinationOrder.CourseGroups.FirstOrDefault(s => s.GroupName == newItem.CourseGroup.GroupName); if (group != null) { newItem.CourseGroup = group; } else { newItem.CourseGroup.Order = destinationOrder; newItem.CourseGroup.OrderKey = destinationOrder.OrderKey; destinationOrder.CourseGroups.Add(newItem.CourseGroup); } DbOrderItem.UpdateGroupInformation(newItem); destinationOrder.Items.Add(newItem); }
private void ProcessTransferWhenDestinationNotExist(List <Order> existingOrders, Order newOrder) { List <Item> processedItem = new List <Item>(); foreach (var order in existingOrders) { foreach (var newItem in newOrder.Items) { var existingItem = order.Items.FirstOrDefault(s => s.DisplayAttributes.IsOriginalItem && s.Name == newItem.Name && s.Sides.Count == newItem.Sides.Count && s.Options.Count == newItem.Options.Count && !processedItem.Contains(s)); if (existingItem != null) { CopyBasiDetails(existingItem, newItem); processedItem.Add(existingItem); UpdateTransferProperty(existingItem); DbOrderItem.UpdateGroupInformation(newItem); } } order.UpdateOrder(); if (order.Items.Count == 0) { AnalyticalData.TotalOrdersCount--; AnalyticalData.CurrentOrdersCount--; } //order.FilterOrders(CurrentSettings.GroupType, CurrentSettings.OrderInfoDisplay); } newOrder.Items.RemoveAll(s => s.OrderItemKey == 0); }