예제 #1
0
        public async Task UpadteNextNumber(CurrentQueueNumber next, ServiceType serviceType)
        {
            string service = serviceType.ToString();

            try
            {
                await _tableClient.GetTableReference(_options.NextTable).ExecuteAsync(TableOperation.InsertOrReplace(next));
            }
            catch (Exception e)
            {
                throw new Exception("", e);
            }
        }
        public Task UpadteNextNumber(CurrentQueueNumber next, ServiceType serviceType)
        {
            if (serviceType == ServiceType.Nurse)
            {
                nextNurseNumber++;
            }
            if (serviceType == ServiceType.Pharmacist)
            {
                nextPharmacistNumber++;
            }

            return(Task.CompletedTask);
        }
        public Task <CurrentQueueNumber> GetCurrentNumber(ServiceType serviceType)
        {
            CurrentQueueNumber current = new CurrentQueueNumber();

            if (serviceType == ServiceType.Nurse)
            {
                current.NextNumber = nextNurseNumber;
            }
            if (serviceType == ServiceType.Nurse)
            {
                current.NextNumber = nextPharmacistNumber;
            }

            return(Task.FromResult(current));
        }
        public async Task <EnqueuePositionResult> AddToQueue(EnqueuePosition item)
        {
            if (item is null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            CurrentQueueNumber currentNumber = await _repository.GetCurrentNumber(item.ServiceType);

            currentNumber.NextNumber++;
            await _repository.UpadteNextNumber(currentNumber, item.ServiceType);

            QueueItem newItem = new QueueItem()
            {
                UserID     = item.UserID,
                UserNumber = currentNumber.NextNumber
            };

            await _repository.AddItem(item.ServiceType, newItem);

            return(new EnqueuePositionResult {
                UserNumber = newItem.UserNumber
            });
        }