コード例 #1
0
        public async Task <List <AllShiftsWithEmployees> > HandleAsync(AllShiftsAndEmployeesQuery query, CancellationToken ct)
        {
            var ShiftsWithEmployees = await WorkScheduleRepository.GetAllAsync();

            var AllShifts = await _shiftRepository.GetAllAsync();

            var resultList = new List <AllShiftsWithEmployees>();

            foreach (var shift in AllShifts)
            {
                foreach (var ShiftWithEmployee in ShiftsWithEmployees)
                {
                    if (shift.Id.Equals(ShiftWithEmployee.ShiftId))
                    {
                        resultList.Add(new AllShiftsWithEmployees
                        {
                            StarTime        = shift.ShiftStart,
                            EndTime         = shift.ShiftEnd,
                            EmployeeOnShift = ShiftWithEmployee.Id,
                            Id = shift.Id
                        });

                        goto nextUpper;
                    }
                }

                resultList.Add(new AllShiftsWithEmployees
                {
                    StarTime        = shift.ShiftStart,
                    EndTime         = shift.ShiftEnd,
                    EmployeeOnShift = Guid.Empty,
                    Id = shift.Id
                });

                nextUpper :;
            }

            Console.WriteLine(resultList);
            return(resultList);
        }