public MoviePlan CreateMoviePlanForWeek(DateTime startDate) { DateTime sundayOfThatWeek = startDate.WeekStartDate(); if (sundayOfThatWeek > DateTime.Now.WeekStartDate()) { throw new BusinessValidationException("Cant create Movie Plan for future weeks"); } MoviePlan result = moviePlans.FirstOrDefault(mp => mp.StartDate == sundayOfThatWeek); if (result == null) { result = new MoviePlan(sundayOfThatWeek); moviePlans.Add(result); } return result; }
public MoviePlan GetMoviePlanForWeek(DateTime startDate) { DateTime sundayOfThatWeek = startDate.WeekStartDate(); return moviePlans.FirstOrDefault(mp => mp.StartDate == sundayOfThatWeek); }
public MoviePlan(DateTime startDate) { this.StartDate = startDate.WeekStartDate(); this.Slots = new List<Slot>(); foreach (TimeSlot eachSlot in Enum.GetValues(typeof(TimeSlot))) { foreach (DayOfWeek eachDay in Enum.GetValues(typeof(DayOfWeek))) { this.Slots.Add(new Slot(eachDay, eachSlot)); } } }