public NormalContextTestValues() { Cereal1 = new NormalFoodCourseEntity() { Name = "Generic cereal with milk", Cost = 2.20M, Type = FoodCourseType.Starter, LastUpdated = DateTime.Now }; Cereal2 = new NormalFoodCourseEntity() { Name = "Generic cereal with soya milk", Cost = 2.20M, Type = FoodCourseType.Starter, LastUpdated = DateTime.Now }; FryUp = new NormalFoodCourseEntity() { Name = "Bacon, eggs, sausage, etc", Cost = 6.00M, Type = FoodCourseType.Main, LastUpdated = DateTime.Now }; CerealAndFryUpBreakfast = new NormalMealEntity() { Name = "Cereal and fry-up breakfast", LastUpdated = DateTime.Now }; CerealAndFryUpBreakfast.Courses.Add(Cereal1); CerealAndFryUpBreakfast.Courses.Add(FryUp); CerealOnlyBreakfast = new NormalMealEntity() { Name = "Cereal only breakfast", LastUpdated = DateTime.Now }; CerealOnlyBreakfast.Courses.Add(Cereal2); Bill = new NormalBillEntity() { LastUpdated = DateTime.Now }; Bill.Meals.Add(CerealAndFryUpBreakfast); Bill.Meals.Add(CerealOnlyBreakfast); CourseCount = Bill.Meals.SelectMany(x => x.Courses).Count(); MealCount = Bill.Meals.Count(); }
public ManualBillEntity ToManualBill(NormalBillEntity normalBill) { if (normalBill == null) { throw new ArgumentNullException("normalBill"); } var manualBill = new ManualBillEntity() { BillId = normalBill.BillId, LastUpdated = normalBill.LastUpdated, Timestamp = normalBill.Timestamp }; if (normalBill.Meals != null) { manualBill.Meals = normalBill.Meals.Select(x => ToManualMeal(x, manualBill)).ToList(); } if (normalBill.Courses != null) { manualBill.Courses = new List <ManualFoodCourseEntity>(); foreach (var course in normalBill.Courses) { ManualFoodCourseEntity manualCourse = null; // Try and find from Meals if (manualBill.Meals != null) { manualCourse = FindFoodCourse(manualBill.Meals.SelectMany(x => x.Courses), course.FoodCourseId); } // If not found then convert if (manualCourse == null) { manualCourse = ToManualFoodCourse(course, manualBill, FindMeal(manualBill.Meals, course.MealId)); } manualBill.Courses.Add(manualCourse); } } return(manualBill); }