Example #1
0
        public async Task <IActionResult> Compose()
        {
            ComposeMessageModel model = new ComposeMessageModel();

            model.Department = await _departmentsService.GetDepartmentByUserIdAsync(UserId);

            model.User  = _usersService.GetUserById(UserId);
            model.Types = model.MessageType.ToSelectList();

            var shifts = await _shiftsService.GetAllShiftsByDepartmentAsync(DepartmentId);

            model.Shifts = new SelectList(shifts, "ShiftId", "Name");

            model.Message = new Message();

            return(View(await FillComposeMessageModel(model)));
        }
Example #2
0
        public async Task <ActionResult <List <ShiftResult> > > GetShifts()
        {
            var results = new List <ShiftResult>();

            var shifts = await _shiftsService.GetAllShiftsByDepartmentAsync(DepartmentId);

            foreach (var s in shifts)
            {
                var shiftData = await _shiftsService.PopulateShiftData(s, true, true, true, false, false);

                var shift = new ShiftResult();
                shift.Id    = shiftData.ShiftId;
                shift.Name  = shiftData.Name;
                shift.Code  = shiftData.Code;
                shift.Color = shiftData.Color;
                shift.SType = shiftData.ScheduleType;
                shift.AType = shiftData.AssignmentType;

                if (shiftData.Personnel != null)
                {
                    shift.PCount = shiftData.Personnel.Count;
                }

                if (shiftData.Groups != null)
                {
                    shift.GCount = shiftData.Groups.Count;
                }

                var nextDay = shiftData.GetNextShiftDayforDateTime(DateTime.UtcNow);

                if (nextDay != null)
                {
                    shift.NextDay   = nextDay.Day.ToString("O");
                    shift.NextDayId = nextDay.ShiftDayId;
                }

                if (s.Personnel != null && shiftData.Personnel.Any(x => x.UserId == UserId))
                {
                    shift.InShift = true;
                }

                results.Add(shift);
            }

            return(Ok(results));
        }