public Bookings BookSlot(string customerId, string barberId, DateTimeOffset time, List <BarberServices> bookedServices, out bool result) { Dictionary <DateTimeOffset, Scheduler> schedulers = GetSchedulers(barberId, new List <DateTimeOffset> { time.GetDate() }); int totalTimeInMinute = GetTotalServingTime(bookedServices); if (schedulers.Count == 0) { result = false; return(null); } var slot = new Slot(new TimePoint(time), totalTimeInMinute); var bookResult = schedulers.Values.First().Book(slot); if (bookResult) { PaymentMethods customerPaymentMethod = _paymentMethodRepository.GetDefaultPaymentMethod(customerId); Bookings booking = new Bookings { BarberId = barberId, CustomerId = customerId, BookedTime = time, DurationMinute = totalTimeInMinute, State = BookingConstants.Booked, CustomerPaymentType = customerPaymentMethod.PaymentType }; _bookingRepository.AddBooking(booking); bookedServices.ForEach(service => { var bookedService = new BookingServices { BookingId = booking.Id, ServiceId = service.Id }; _bookingServiceRepository.Add(bookedService); }); result = true; return(booking); } result = false; return(null); }