Exemplo n.º 1
0
        public async Task IncreaseShiftCountAsync(Guid invitationId, ShiftNumber shiftNumber, int capacityToAdd)
        {
            await using var context = ContextFactory.CreateDataContext(null);
            var items  = context.TestingPersonnelInvitations;
            var entity = await items.AsNoTracking()
                         .FirstAsync(t => t.Id == invitationId)
                         .ConfigureAwait(false);

            if (shiftNumber == ShiftNumber.First)
            {
                entity.RequiredPersonnelCountShift1 += capacityToAdd;
            }
            else
            {
                entity.RequiredPersonnelCountShift2 += capacityToAdd;
            }

            context.Entry(entity).State = EntityState.Modified;
            context.TestingPersonnelInvitations.Update(entity);

            await context.SaveChangesAsync()
            .ConfigureAwait(false);
        }
        public async Task <List <AvailableTemporaryPersonnelDto> > GetAvailableTemporaryPersonnelForDateAndShiftAsync(DateTime testingDate, ShiftNumber shiftNumber)
        {
            await using var context = ContextFactory.CreateDataContext(null);

            return(await context.TestingPersonnels
                   .Where(item => item.Type == TestingPersonnelType.Temporary && !item.TestingPersonnelConfirmationsWithoutInvitations.Any(
                              x => x.Date.Date == testingDate.Date && x.ShiftNumber == shiftNumber))
                   .Select(tp => new AvailableTemporaryPersonnelDto()
            {
                TestingPersonnelId = tp.Id,
                Name = $"{_aesCryptography.Decrypt(tp.FirstName)} {_aesCryptography.Decrypt(tp.LastName)}"
            })
                   .ToListAsync()
                   .ConfigureAwait(false));
        }
 private List <TestingPersonnelTestDataDto> GetConfirmedTestingPersonnelWithoutInvitationForDateAndShift(List <TestingPersonnelConfirmationsWithoutInvitation> confirmationsWithoutInvitation, DateTime date, ShiftNumber shift)
 {
     return(confirmationsWithoutInvitation
            .Where(x => x.Date.Date == date.Date && x.ShiftNumber == shift)
            .Select(x => new TestingPersonnelTestDataDto
     {
         FirstName = _aesCryptography.Decrypt(x.TestingPersonnel.FirstName),
         LastName = _aesCryptography.Decrypt(x.TestingPersonnel.LastName),
         Email = _aesCryptography.Decrypt(x.TestingPersonnel.Email),
         IsCanceled = false,
         ConfirmationWithoutInvitationId = x.Id
     }).ToList());
 }
        public async Task AddConfirmationAsync(Guid testingPersonnelId, DateTime testingDate, ShiftNumber shiftNumber)
        {
            await using var context = ContextFactory.CreateDataContext(null);
            var items = context.TestingPersonnelConfirmationsWithoutInvitation;

            var entity = new TestingPersonnelConfirmationsWithoutInvitation()
            {
                Id = Guid.NewGuid(),
                TestingPersonnelId = testingPersonnelId,
                Date        = testingDate.Date,
                ShiftNumber = shiftNumber
            };

            await items.AddAsync(entity).ConfigureAwait(false);

            await context.SaveChangesAsync().ConfigureAwait(false);
        }
        public async Task <bool> DoesConfirmationExistAsync(Guid testingPersonnelId, DateTime testingDate, ShiftNumber shiftNumber)
        {
            await using var context = ContextFactory.CreateDataContext(null);

            return(await context.TestingPersonnelConfirmationsWithoutInvitation
                   .AnyAsync(item => item.TestingPersonnelId == testingPersonnelId && item.Date.Date == testingDate.Date && item.ShiftNumber == shiftNumber)
                   .ConfigureAwait(false));
        }