Ejemplo n.º 1
0
        public T Invoke(int restaurantId, int staffTypeId)
        {
            Guard.InstanceNotNull(OnComplete, "OnComplete");

            var viewModel = new ShiftTimeslotViewModel();

            var loadTimeSlotsResponse = shifterSystem.ShiftTimeSlotService.LoadTimeSlots(
                new LoadTimeSlotCollectionRequest {
                RestaurantId = restaurantId, StaffTypeId = staffTypeId
            });

            viewModel.Timeslots = loadTimeSlotsResponse.ShiftTimeslots;

            return(OnComplete.Invoke(viewModel));
        }
Ejemplo n.º 2
0
        public T Invoke(ShiftTimeSlotDto timeslot)
        {
            Guard.InstanceNotNull(OnComplete, "OnComplete");
            Guard.InstanceNotNull(timeslot, "timeslot");

            var viewModel = new ShiftTimeslotViewModel();

            var deleteTimeSlotResponse = shifterSystem.ShiftTimeSlotService.DeleteTimeslot(new DeleteShiftTimeSlotRequest {
                ShiftTimeSlotId = timeslot.Id
            });

            viewModel.Notifications = deleteTimeSlotResponse.NotificationCollection;

            var loadTimeSlotsService = shifterSystem.ShiftTimeSlotService.LoadTimeSlots(new LoadTimeSlotCollectionRequest {
                RestaurantId = timeslot.RestaurantId, StaffTypeId = timeslot.StaffTypeId
            });

            viewModel.Timeslots = loadTimeSlotsService.ShiftTimeslots;

            return(OnComplete.Invoke(viewModel));
        }
Ejemplo n.º 3
0
        public T Invoke(string startTime, string endTime, int restaurantId, int staffTypeId)
        {
            Guard.InstanceNotNull(OnComplete, "OnComplete");
            Guard.InstanceNotNull(startTime, "startTime");
            Guard.InstanceNotNull(endTime, "endTime");

            var viewModel = new ShiftTimeslotViewModel();

            if (startTime.Trim().IsNotNullOrEmpty() && endTime.Trim().IsNotNullOrEmpty())
            {
                var timeslot = new ShiftTimeSlotDto
                {
                    StartTime    = TimeSpan.Parse(startTime),
                    EndTime      = TimeSpan.Parse(endTime),
                    RestaurantId = restaurantId,
                    StaffTypeId  = staffTypeId
                };

                var saveTimeSlotResponse = shifterSystem.ShiftTimeSlotService.SaveTimeslot(new SaveShiftTimeSlotRequest {
                    ShiftTimeSlot = timeslot
                });

                viewModel.Notifications += saveTimeSlotResponse.NotificationCollection;
            }
            else
            {
                viewModel.Notifications.AddError("Times cannot be empty");
            }

            var loadTimeSlotsResponse = shifterSystem.ShiftTimeSlotService.LoadTimeSlots(new LoadTimeSlotCollectionRequest {
                RestaurantId = restaurantId, StaffTypeId = staffTypeId
            });

            viewModel.Timeslots = loadTimeSlotsResponse.ShiftTimeslots;

            return(OnComplete.Invoke(viewModel));
        }