Exemplo n.º 1
0
        public Attendee SignUp(AttendeeDto dto)
        {
            var pupil = dto.Type == AttendeeType.Pupil ? FindPupil(dto) : null;

            if (pupil != null)
            {
                SetAttendeeInfo(pupil, dto);
                SetPupilInfo(pupil, dto);

                using (var tx = session.BeginTransaction())
                {
                    session.Update(pupil);
                    tx.Commit();
                }

                return(pupil);
            }

            var entity = ToEntity(dto);

            using (var tx = session.BeginTransaction())
            {
                session.Save(entity);
                tx.Commit();
            }

            return(entity);
        }
        public IActionResult RemoveAttendee(
            [FromRoute, SwaggerParameter("Id of the hub from which the attendance is removed")]
            int idHub,
            [FromRoute, SwaggerParameter("Id of the attending pupil to be removed")]
            int idPupil,
            [FromBody, SwaggerParameter("Attendee to be removed")]
            AttendeeDto attendeeDto)
        {
            var currentModerator = _authenticationService.GetCurrentModerator();

            if (attendeeDto.IdHub != idHub ||
                attendeeDto.IdPupil != idPupil)
            {
                return(BadRequest());
            }

            try
            {
                _hubService.RemoveAttendance(currentModerator, attendeeDto);
                return(Ok());
            }
            catch (BaseException ex)
            {
                return(Unauthorized(
                           new UnauthorizedError(ex)));
            }
        }
        public async Task <ActionResult <AttendeeResponse> > Post(AttendeeDto input)
        {
            // Check if the attendee already exists
            var existingAttendee = await _db.Attendees
                                   .Where(a => a.UserName == input.UserName)
                                   .FirstOrDefaultAsync();

            if (existingAttendee != null)
            {
                return(Conflict(input));
            }

            var attendee = new Data.Attendee
            {
                FirstName    = input.FirstName,
                LastName     = input.LastName,
                UserName     = input.UserName,
                EmailAddress = input.EmailAddress
            };

            _db.Attendees.Add(attendee);
            await _db.SaveChangesAsync();

            var result = attendee.MapAttendeeResponse();

            return(CreatedAtAction(nameof(Get), new { id = result.UserName }, result));
        }
Exemplo n.º 4
0
        public Task <int> Add(AttendeeDto attendeeDto)
        {
            var entity = ConferenceAdapter.FromAttendeeDtoToAttendee(attendeeDto);

            _dbContext.Attendees.Add(entity);
            return(_dbContext.SaveChangesAsync());
        }
Exemplo n.º 5
0
 public void Update(AttendeeDto attendee)
 {
     using (var repo = new UserRepository())
     {
         repo.UpdateAttendee(attendee);
     }
 }
Exemplo n.º 6
0
 public void Add(AttendeeDto attendee)
 {
     using (var repo = new UserRepository())
     {
         repo.AddAttendee(attendee);
     }
 }
Exemplo n.º 7
0
        private Pupil CreatePupil(AttendeeDto dto)
        {
            var pupil = new Pupil();

            SetPupilInfo(pupil, dto);

            return(pupil);
        }
 public static Attendee FromAttendeeDtoToAttendee(AttendeeDto attendeeDto)
 {
     return(new Attendee
     {
         ConferenceId = attendeeDto.ConferenceId,
         Name = attendeeDto.Name
     });
 }
Exemplo n.º 9
0
 private void SetPupilInfo(Pupil pupil, AttendeeDto dto)
 {
     pupil.School = session.Query <School>().FirstOrDefault(x => x.Id == dto.SchoolId);
     pupil.InterestingPrograms = session.Query <AcademicProgram>()
                                 .Where(x => dto.InterestingProgramIds.Contains(x.Id)).ToList();
     pupil.Sex = dto.Sex;
     pupil.YearOfGraduation = dto.YearOfGraduation;
 }
Exemplo n.º 10
0
        public void AddAttendee(AttendeeDto dto)
        {
            var entity = ToEntity(dto);

            using (var tx = session.BeginTransaction())
            {
                session.Save(entity);
                tx.Commit();
            }
        }
Exemplo n.º 11
0
        private Attendee ToEntity(AttendeeDto dto)
        {
            var entity = dto.Type == AttendeeType.Pupil
                ? CreatePupil(dto)
                : new Attendee();

            SetAttendeeInfo(entity, dto);

            return(entity);
        }
Exemplo n.º 12
0
        public AuthInfo SignUp(AttendeeDto dto)
        {
            var attendee = userRepository.SignUp(dto);

            var role = attendee.Type.ToString();

            return(new AuthInfo()
            {
                Token = GetToken(attendee.User.Login, role, true),
                User = attendee.User
            });
        }
Exemplo n.º 13
0
 private void SetAttendeeInfo(Attendee attendee, AttendeeDto dto)
 {
     attendee.Type = dto.Type;
     if (dto.Login.IsNotEmpty())
     {
         attendee.User = new User()
         {
             Login    = dto.Login,
             Password = PasswordHelper.GetHash(dto.Password),
             Type     = UserType.Attendee
         };
     }
     attendee.ContactInfo = new ContactInfo(dto.FullName, dto.PhoneNumber, dto.Email);
 }
Exemplo n.º 14
0
        private AttendeeDto ToDto(Attendee entity)
        {
            var dto = new AttendeeDto()
            {
                Id          = entity.Id,
                FullName    = entity.ContactInfo.FullName,
                PhoneNumber = entity.ContactInfo.PhoneNumber,
                Email       = entity.ContactInfo.Email,
                Type        = entity.Type,
            };

            if (entity.Type == AttendeeType.Pupil)
            {
                var pupil = entity as Pupil;
                dto.YearOfGraduation = pupil.YearOfGraduation;
                dto.Sex      = pupil.Sex;
                dto.SchoolId = pupil.School.Id;
            }


            return(dto);
        }
Exemplo n.º 15
0
        public void UpdateAttendee(AttendeeDto dto)
        {
            var attendee = session.Query <Attendee>().FirstOrDefault(x => x.Id == dto.Id);
            var userInfo = attendee.User;

            if (dto.Type == AttendeeType.Pupil)
            {
                var pupil = attendee as Pupil;
                SetPupilInfo(pupil, dto);

                attendee = pupil;
            }

            SetAttendeeInfo(attendee, dto);
            attendee.User = userInfo;

            using (var tx = session.BeginTransaction())
            {
                session.Update(attendee);
                tx.Commit();
            }
        }
Exemplo n.º 16
0
 public void Update(AttendeeDto attendee)
 {
     attendeeStorage.Update(attendee);
 }
Exemplo n.º 17
0
 public void Add(AttendeeDto attendee)
 {
     attendeeStorage.Add(attendee);
 }
Exemplo n.º 18
0
 public AuthInfo SignUp(AttendeeDto dto)
 {
     return(authService.SignUp(dto));
 }
Exemplo n.º 19
0
        private string AddRegistrant(ConvertServiceRequest request)
        {
            var attendee = CommonUtils.XmlDeserialize<AttendeeV2>(request.Data);

            int occurrenceId;
            if (request.Parameters.ContainsKey("occurrenceId"))
                occurrenceId = int.Parse(request.Parameters["occurrenceId"]);
            else if (request.Parameters.ContainsKey("occurrenceExternalId"))
                occurrenceId = LookupDataEntityMapId("EventOccurrence", request.Parameters["occurrenceExternalId"], false);
            else
                throw new BusinessException("Occurrence Id or External Id is required");

            var attendeeDto = new AttendeeDto
            {
                FirstName = attendee.FirstName,
                LastName = attendee.LastName,
                Address1 = attendee.Address1,
                Address2 = attendee.Address2,
                City = attendee.City,
                StateId = LookupStateId(attendee.StateAbbreviation),
                DidAttend = string.IsNullOrEmpty(attendee.DidAttend) ? new bool?() : bool.Parse(attendee.DidAttend),
                PostalCode = attendee.PostalCode,
                PrimaryPhone = attendee.Phone,
                EmailAddress = attendee.EmailAddress
            };

            // Register attendee
            var registerRequest = new RegisterSingleAttendeeRequestV2
            {
                EventOccurrenceId = occurrenceId,
                AmountPaid = attendee.AmountPaid.HasValue ? attendee.AmountPaid.Value : 0,
                Attendee = attendeeDto,
                DisableConfirmationEmail = true,
                GuestAttendees = new List<AttendeeDto>()
            };

            var response = ProcessRequest<RegisterSingleAttendeeResponseV2>(registerRequest);
            return response.Message;
        }
        public async Task AddAttendeeAsync(AttendeeDto attendee)
        {
            var response = await _httpClient.PostJsonAsync($"/api/attendees", attendee);

            response.EnsureSuccessStatusCode();
        }
Exemplo n.º 21
0
 public void Add(AttendeeDto attendee)
 {
     attendeeService.Add(attendee);
 }
Exemplo n.º 22
0
 private Pupil FindPupil(AttendeeDto dto)
 {
     return(session.Query <Pupil>()
            .FirstOrDefault(x => x.ContactInfo.FullName == dto.FullName &&
                            x.ContactInfo.PhoneNumber == dto.PhoneNumber));
 }
Exemplo n.º 23
0
 public void Update(AttendeeDto attendee)
 {
     attendeeService.Update(attendee);
 }