public static List <MOTCartItem> Search_MealOrderTicketForMOT(DateTime?startDate, DateTime?endDate) { try { using (var cont = new healthychefEntities()) { List <MOTCartItem> motItems = new List <MOTCartItem>(); List <hccCartItem> alcgc = cont.hcc_OrderFulfillSearch_ALCnGC_ByRange(startDate, endDate).Select(x => new hccCartItem { CartItemID = Convert.ToInt32(x.CartItemID), CartID = Convert.ToInt32(x.CartID), UserProfileID = Convert.ToInt32(x.UserProfileID), ItemTypeID = Convert.ToInt32(x.ItemTypeID), ItemName = x.ItemName, ItemDesc = x.ItemDesc, ItemPrice = Convert.ToDecimal(x.ItemPrice), Quantity = Convert.ToInt32(x.Quantity), IsTaxable = Convert.ToBoolean(x.IsTaxable), OrderNumber = x.OrderNumber, DeliveryDate = Convert.ToDateTime(x.DeliveryDate), Gift_RedeemCode = x.Gift_RedeemCode, Gift_IssuedTo = x.Gift_IssuedTo, Gift_IssuedDate = x.Gift_IssuedDate, Gift_RedeemedBy = x.Gift_RedeemedBy, Gift_RedeemedDate = x.Gift_RedeemedDate, Gift_RecipientAddressId = x.Gift_RecipientAddressId, Gift_RecipientEmail = x.Gift_RecipientEmail, Gift_RecipientMessage = x.Gift_RecipientMessage, Meal_MenuItemID = x.Meal_MenuItemID, Meal_MealSizeID = x.Meal_MealSizeID, Meal_ShippingCost = x.Meal_ShippingCost, Plan_PlanID = x.Plan_PlanID, Plan_ProgramOptionID = x.Plan_ProgramOptionID, Plan_IsAutoRenew = x.Plan_IsAutoRenew, CreatedBy = x.CreatedBy, CreatedDate = Convert.ToDateTime(x.CreatedDate), IsCompleted = Convert.ToBoolean(x.IsCompleted), IsCancelled = Convert.ToBoolean(x.IsCancelled), IsFulfilled = Convert.ToBoolean(x.IsFulfilled), DiscountPerEach = Convert.ToDecimal(x.DiscountPerEach), DiscountAdjPrice = Convert.ToDecimal(x.DiscountAdjPrice), SnapBillAddrId = x.SnapBillAddrId, SnapShipAddrId = x.SnapShipAddrId, TaxRate = x.TaxRate, TaxableAmount = x.TaxableAmount, DiscretionaryTaxAmount = x.DiscretionaryTaxAmount, TaxRateAssigned = x.TaxRateAssigned }).ToList(); motItems.AddRange(MOTCartItem.GetFromRange(alcgc)); var progs = cont.hcc_OrderFulfillSearch_Programs_ByRange(startDate, endDate).ToList(); motItems.AddRange(MOTCartItem.GetFromRangeForMOT(progs)); return(motItems.OrderBy(a => a.DeliveryDate) .ThenBy(a => a.ItemName).ThenBy(a => a.OrderNumber.Contains("ALC")).ThenBy(a => a.CustomerName).ToList()); } } catch (Exception ex) { throw ex; } }