Esempio n. 1
0
        // adds an attendant to a conference
        public IActionResult AddAttendantToConference(Guid conferenceId, AttendantCreateDto attendantCreateDto)
        {
            var attendantExists = _applicationDbContext.Attendant.SingleOrDefault(
                attendant => attendant.ConferenceId == conferenceId && attendant.UserId == attendantCreateDto.UserId);

            if (attendantExists != null)
            {
                return(new BadRequestObjectResult("User is allready assigned to this conference."));
            }

            var newAssignment = _applicationDbContext.Attendant.Add(new Attendant()
            {
                ConferenceId     = conferenceId,
                UserId           = attendantCreateDto.UserId,
                TypeOfAttendance = attendantCreateDto.TypeOfAttendance
            });

            if (newAssignment == null)
            {
                return(new BadRequestResult());
            }

            Save();

            var updatedConference = GetConferernceById(conferenceId);

            return(new OkObjectResult(updatedConference));
        }
Esempio n. 2
0
        public async void AddAllreadyExistingAttendantToConferenceShouldReturnBadRequest()
        {
            var attendantCreateDto = new AttendantCreateDto()
            {
                UserId           = _userId1,
                TypeOfAttendance = TypeOfAttendance.GUEST
            };

            var serializedAttendantCreateDto = JsonConvert.SerializeObject(attendantCreateDto);
            var httpResponse = await _fixture.PostHttpResult($"{UrlPath}{_conferenceId}/attendants/", serializedAttendantCreateDto);

            httpResponse.Should().NotBeNull();
            httpResponse.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
Esempio n. 3
0
        public virtual IActionResult AddAttendantToConference([FromRoute] Guid conferenceId, [FromBody] AttendantCreateDto attendantCreateDto)
        {
            var result = _conferenceRepository.AddAttendantToConference(conferenceId, attendantCreateDto);

            return(result);
        }