public JsonResult DeleteTimeslot(ShiftTimeSlotDto timeslot) { var action = new DeleteTimeslotAction <JsonResult>(ServiceRegistry) { OnComplete = (model) => new JsonResult() { Data = new { StaffTypeId = timeslot.StaffTypeId, Payload = this.RenderPartialViewToString("ShiftTimeslots", model) } } }; return(action.Invoke(timeslot)); }
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)); }
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)); }