Ejemplo n.º 1
0
 private static T Create <T>(DeskBookingRequest request) where T : DeskBookingBase, new()
 {
     return(new T
     {
         FirstName = request.FirstName,
         LastName = request.LastName,
         Email = request.Email,
         Date = request.Date
     });
 }
Ejemplo n.º 2
0
        public DeskBooking CreateBooking(DeskBookingRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var availableDesks = _deskRepository.GetAvailableDesks(request.Date);

            var deskBooking = Create <DeskBooking>(request);

            deskBooking.DeskId = availableDesks.First().Id;

            _deskBookingRepository.Save(deskBooking);

            return(deskBooking);
        }