public async Task <IActionResult> Add([FromBody] QueueMemberDTO queueMember) { try { await _queueMemberService.AddAsync(queueMember); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(CreatedAtAction(nameof(Add), new { queueMember.Id }, queueMember)); }
public async Task AddAsync_AddEntity() { // Arrange var expectedCount = await _context.QueueMembers.CountAsync(); // Act await _queueMemberService.AddAsync(new QueueMemberDTO { Id = 3, Priority = 1 }); var resultCount = await _context.QueueMembers.CountAsync(); // Assert resultCount.Should().Be(expectedCount + 1); }
public async Task <IActionResult> Create([Bind("Priority,TimeInterval,IsAbsent,QueueId,StudentId,Id")] QueueMemberDTO queueMember) { var userId = User.FindFirstValue(ClaimTypes.NameIdentifier); queueMember.StudentId = userId; if (ModelState.IsValid) { await _service.AddAsync(queueMember); return(RedirectToAction(nameof(Index))); } var queues = await _queueService.GetAllAsync(); ViewData["QueueId"] = new SelectList(queues, "Id", "Id", queueMember.QueueId); return(View(queueMember)); }