Beispiel #1
0
        public async Task <IActionResult> AddStaff(List <UserShift> model, int id)
        {
            var shift = await shiftRepository.GetShiftWithVenueAsync(id);

            if (shift == null)
            {
                return(NotFound());
            }

            foreach (var m in model)
            {
                if (availabilityRepository.CanBeScheduled(m.UserID, m.UserStart, m.UserEnd))
                {
                    m.ShiftID = shift.ID;
                    await userShiftRepository.Create(m);
                }
                else
                {
                    TempData["SchedulingError"] = "Availability or Time Off Requests violated for 1 or more users";
                }
            }

            return(RedirectToAction("details", "shift", new { id = id }));
        }