internal async Task <EnqueuePositionResult> GetEnqueuePositionResult(EnqueuePosition requestPosition) { var task = await Task.FromResult(new EnqueuePositionResult() { UserNumber = positionResult.UserNumber }); positionResult.UserNumber++; return(task); }
/* * Generate POST HTTP request to the API and return the queue position of the client. */ public async Task <EnqueuePositionResult> RegisterToQueueAsync(EnqueuePosition requestPosition) { EnqueuePositionResult positionResult = null; HttpResponseMessage response = await client.PostAsJsonAsync($"{ConstantURI.queueServerURI}Queue", requestPosition); response.EnsureSuccessStatusCode(); positionResult = await response.Content.ReadAsAsync <EnqueuePositionResult>(); return(positionResult); }
public async Task <IActionResult> Add([FromBody] EnqueuePosition item) { if (item is null || item.ServiceType == ServiceType.none) { return(BadRequest()); } EnqueuePositionResult result = await _queueService.AddToQueue(item); if (result is null) { return(Conflict()); } return(CreatedAtAction(nameof(Add), result)); }
public async Task QueueServiceTest_AddToQueue() { QueueRepositoryMock repository = CreateQueueRepository(); IQueueStorageService serviceTest = new QueueStorageService(repository); Assert.ThrowsAsync <ArgumentNullException>(async() => { await serviceTest.AddToQueue(null); }); EnqueuePosition testItem = new EnqueuePosition { ServiceType = ServiceType.Nurse, UserID = 1313 }; var result = await serviceTest.AddToQueue(testItem); var queueItem = repository._queueNurse.FirstOrDefault(i => i.UserID == 1313); Assert.AreEqual(queueItem.UserNumber, result.UserNumber); }
/* * Enter the client to the appropriate queue */ private async void EnterToQueueActionsAsync(ServiceType service) { try { EnqueuePosition enqueuePosition = new EnqueuePosition() { ServiceType = service, UserID = Model.CustomerID }; Model.LineNumber = await clientHttp.RegisterToQueueAsync(enqueuePosition); Model.QueueType = service; timer.Stop(); eventAggregator.GetEvent <ChangeViewEvent>().Publish(ViewType.display); // switch the current view to display eventAggregator.GetEvent <SendPatientEvent>().Publish(Model); // send it the current model } catch (HttpRequestException e) { views.ShowErrorDialog(e.Message); timer.Stop(); eventAggregator.GetEvent <ChangeViewEvent>().Publish(ViewType.welcome); // switch the current view to display } }
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 }); }
public async Task <EnqueuePositionResult> RegisterToQueueAsync(EnqueuePosition requestPosition) { return(await repository.GetEnqueuePositionResult(requestPosition)); }