public ManualMealEntity ToManualMeal(NormalMealEntity normalMeal, ManualBillEntity bill = null) { if (normalMeal == null) { throw new ArgumentNullException("normalMeal"); } if (bill != null && normalMeal.BillId != bill.BillId) { throw new ArgumentOutOfRangeException("bill"); } var manualMeal = new ManualMealEntity() { Bill = bill, BillId = normalMeal.BillId, LastUpdated = normalMeal.LastUpdated, MealId = normalMeal.MealId, Name = normalMeal.Name, Timestamp = normalMeal.Timestamp }; if (normalMeal.Courses != null) { manualMeal.Courses = normalMeal.Courses.Select(x => ToManualFoodCourse(x, bill, manualMeal)).ToList(); } return(manualMeal); }
public ManualFoodCourseEntity ToManualFoodCourse(NormalFoodCourseEntity normalCourse, ManualBillEntity bill = null, ManualMealEntity meal = null) { if (normalCourse == null) { throw new ArgumentNullException("normalCourse"); } if (bill != null && normalCourse.BillId != bill.BillId) { throw new ArgumentOutOfRangeException("bill"); } if (meal != null && normalCourse.MealId != meal.MealId) { throw new ArgumentOutOfRangeException("meal"); } var manualCourse = new ManualFoodCourseEntity() { Bill = bill, BillId = normalCourse.BillId, Cost = normalCourse.Cost, FoodCourseId = normalCourse.FoodCourseId, LastUpdated = normalCourse.LastUpdated, Meal = meal, MealId = normalCourse.MealId, Name = normalCourse.Name, Timestamp = normalCourse.Timestamp, Type = normalCourse.Type }; return(manualCourse); }