예제 #1
0
        public async Task <IActionResult> Add([FromBody] QueueDTO queue)
        {
            try
            {
                await _queueService.AddAsync(queue);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(CreatedAtAction(nameof(Add), new { queue.Id }, queue));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("IssueCategory,Priority,ConsultationId,Id")] QueueDTO queue)
        {
            if (ModelState.IsValid)
            {
                await _service.AddAsync(queue);

                return(RedirectToAction(nameof(Index)));
            }
            var consultations = await _consultationService.GetAllAsync();

            ViewData["ConsultationId"] = new SelectList(consultations, "Id", "Id", queue.ConsultationId);
            return(View(queue));
        }
        public async Task AddAsync_AddEntity()
        {
            // Arrange
            var expectedCount = await _context.Queues.CountAsync();

            // Act
            await _queueService.AddAsync(new QueueDTO { Id = 3, Priority = 1 });

            var resultCount = await _context.Queues.CountAsync();

            // Assert
            resultCount.Should().Be(expectedCount + 1);
        }