Пример #1
0
        public async Task <IActionResult> Update([FromBody] QueueMemberDTO queueMember)
        {
            if (queueMember is null)
            {
                return(BadRequest());
            }

            await _queueMemberService.UpdateAsync(queueMember);

            return(Ok());
        }
Пример #2
0
        public async Task UpdateAsync_UpdatesEntity()
        {
            // Arrange
            var expected = await _context.QueueMembers.AsNoTracking().FirstOrDefaultAsync(s => s.Id == 1);

            // Act
            await _queueMemberService.UpdateAsync(new QueueMemberDTO { Id = 1, Priority = 2 });

            var result = await _context.QueueMembers.AsNoTracking().FirstOrDefaultAsync(s => s.Id == 1);

            // Assert
            expected.Id.Should().Be(result.Id);
            expected.Priority.Should().NotBe(result.Priority);
        }
Пример #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Priority,TimeInterval,IsAbsent,QueueId,StudentId,Id")] QueueMemberDTO queueMember)
        {
            if (id != queueMember.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _service.UpdateAsync(queueMember);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_service.QueueMemberExists(queueMember.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            var queues = await _queueService.GetAllAsync();

            var query = queues.Select(q => new
            {
                Id          = q.Id,
                DisplayText = String.Format("{0} {1} {2} {3}", q.Consultation.Lecturer.SecondName,
                                            q.Consultation.Subject.Name, q.Consultation.Date, q.IssueCategory.ToString())
            });

            ViewData["QueueId"] = new SelectList(query, "Id", "DisplayText", queueMember.QueueId);

            return(View(queueMember));
        }