Beispiel #1
0
        public async Task <ParticipantDto[]> GetParticipantsAsync(string volteerEventCode)
        {
            var table = await GetTable("EventData");

            var tq = new TableQuery <ParticipantTable>
            {
                FilterString = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, volteerEventCode)
            };

            var results = await table.ExecuteQueryAsync(tq);

            var skipEventInResults = results.Where(x => x.RowKey != "Event").ToList();

            var dtos = new List <ParticipantDto>();

            foreach (var item in skipEventInResults)
            {
                var dto = new ParticipantDto
                {
                    EventCode       = item.PartitionKey,
                    ParticipantCode = item.RowKey,
                };
                MapParticipantTableToParticipantDto(item, dto);
                dtos.Add(dto);
            }

            return(dtos.ToArray());
        }
        public ActionResult Login(LoginDto objloginDto)
        {
            string s = null;

            try
            {
                LoginManager   objLoginManager = new LoginManager();
                ParticipantDto objReturn       = new ParticipantDto();

                objReturn = objLoginManager.CheckLogin(objloginDto);
                if (objReturn.Email != null)
                {
                    Session["Uid"]      = objReturn.UserID;
                    Session["UserName"] = objReturn.FirstName + " " + objReturn.LastName;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Content("Invalid Username/Password"));
                }
            }
            catch (Exception ex)
            {
                s  = ex.Message;
                s += ex.Source;
                s += ex.InnerException.Message;
            }
            return(Content(s));
        }
        public async Task <ActionResult <ParticipantDto> > PostParticipant(ParticipantDto participantDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!participantDTO.ConfirmPassword.Equals(participantDTO.Password))
            {
                return(StatusCode(412));
            }

            string passwordHash = BCrypt.Net.BCrypt.HashPassword(participantDTO.Password);

            var participant = new Participant
            {
                Login            = participantDTO.Login,
                Password         = passwordHash,
                Participant_Type = (ParticipantType)participantDTO.Participant_Type
            };

            try
            {
                await _participant.CreateParticipantsAsync(participant);
            }
            catch (DbUpdateException)
            {
                return(Conflict(new { message = "The login already exist" }));
            }

            var tokenJWT = GenerateJWToken(participant);

            return(Ok(new JwtSecurityTokenHandler().WriteToken(tokenJWT)));
        }
Beispiel #4
0
 public ModeratorDto(ParticipantDto p)
 {
     FirstName = p.FirstName;
     LastName  = p.LastName;
     UserName  = p.UserName;
     Password  = p.Password;
 }
        public ParticipantDto CheckLogin(LoginDto objLoginDto)
        {
            ParticipantDto objCheck = new ParticipantDto();

            try
            {
                LoginDal objLoginDal = new LoginDal();
                User     objLogin    = new User();
                objLogin.Email    = Convert.ToString(objLoginDto.Email);
                objLogin.Password = Convert.ToString(objLoginDto.Password);
                User objNew = new User();
                objNew = objLoginDal.CheckLogin(objLogin);


                objCheck.Education = objNew.Education;
                objCheck.Email     = objNew.Email;
                objCheck.FirstName = objNew.FirstName;
                objCheck.LastName  = objNew.LastName;
                objCheck.Mobile    = objNew.Mobile;
                objCheck.UserID    = objNew.UserID;
            }
            catch (FormatException ex)
            {
                throw ex;
            }
            return(objCheck);
        }
Beispiel #6
0
		public async Task<SuccessMessageDto> UpdateAsync(ParticipantDto dto)
		{
			var model = _mapper.Map<ParticipantModel>(dto);
			await _participantDataService.UpdateAsync(model);

			return new SuccessMessageDto();
		}
Beispiel #7
0
        public async Task Add_ShouldAddParticipant()
        {
            // Arrange
            var options = BuildContextOptions();

            using (var context = new BorrowBuddyContext(options)) {
                // Act
                var service = new ParticipantService(context);
                var dto     = new ParticipantDto {
                    FirstName  = "FirstName",
                    LastName   = "LastName",
                    MiddleName = "MiddleName"
                };
                await service.AddAsync(dto);
            }

            // Assert
            using (var context = new BorrowBuddyContext(options)) {
                var participant = context.Participants.FirstOrDefault();
                Assert.NotNull(participant);
                Assert.Equal("FirstName", participant.FirstName);
                Assert.Equal("LastName", participant.LastName);
                Assert.Equal("MiddleName", participant.MiddleName);
            }
        }
Beispiel #8
0
        public static async Task <ParticipantDto> GetParticipant(int participantId)
        {
            Participant entity = await ParticipantRead.GetParticipant(participantId, a => a.EnrolledMeetings);

            ParticipantDto result = Convert(entity);

            return(result);
        }
Beispiel #9
0
 public static Participant Convert(ParticipantDto item)
 {
     return(new Participant
     {
         GroupId = item.GroupId,
         ParticipantRoleId = item.ParticipantRoleId,
         UserId = item.UserId
     });
 }
        public bool Update(ParticipantDto vote)
        {
            var voteEntity = Find(vote.Id);

            voteEntity.EmailHash    = vote.EmailHash;
            voteEntity.ConsumerId   = vote.ConsumerId;
            voteEntity.ModifiedDate = DateTimeOffset.UtcNow;
            return(Update(voteEntity, true) > 0);
        }
Beispiel #11
0
        public async Task <ParticipantDto> GetParticipantByIdAsync(Guid userId, Guid groupId)
        {
            ParticipantDto participant = ParticipantConverter.Convert(await _participantRepo.GetByIdAsync(userId, groupId));

            participant.GroupName = _groupRepo.GetByIdAsync(participant.GroupId).Result.Name;
            participant.RoleName  = _participantRoleRepo.GetByIdAsync(participant.ParticipantRoleId).Result.Name;
            participant.UserName  = _userRepo.GetByIdAsync(participant.UserId).Result.Name;
            return(participant);
        }
Beispiel #12
0
 public GroupClassAggregate ChangeParticipantRole(IUpdateGroupClass command)
 {
     State.Participants.ForEach(updatedParticipant =>
     {
         ParticipantDto participantDto = command.Participants.First(p => p.Id == updatedParticipant.UserId);
         ParticipantGroupClass participantGroupClass = State.Participants.First(x => x.UserId == updatedParticipant.UserId);
         participantGroupClass.WithRole(participantDto.Role);
     });
     return(this);
 }
        public async Task <Participant> UpdateAsync(Guid id, ParticipantDto dto)
        {
            var participant = await GetAsync(id);

            participant.FirstName  = dto.FirstName;
            participant.MiddleName = dto.MiddleName;
            participant.LastName   = dto.LastName;

            await _context.SaveChangesAsync();

            return(participant);
        }
Beispiel #14
0
        public static Participant Convert(ParticipantDto participantDto)
        {
            Participant result = new Participant()
            {
                Id          = participantDto.Id,
                Name        = participantDto.Name,
                Birthday    = participantDto.Birthday,
                IsOrganizer = participantDto.IsOrganizer,
            };

            return(result);
        }
Beispiel #15
0
        public static ParticipantDto Convert(Participant entity)
        {
            ParticipantDto result = new ParticipantDto()
            {
                Id          = entity.Id,
                Name        = entity.Name,
                Birthday    = entity.Birthday,
                IsOrganizer = entity.IsOrganizer,
            };

            return(result);
        }
        public async Task <Participant> AddAsync(ParticipantDto dto)
        {
            var participant = new Participant {
                FirstName  = dto.FirstName,
                LastName   = dto.LastName,
                MiddleName = dto.MiddleName
            };

            _context.Participants.Add(participant);

            await _context.SaveChangesAsync();

            return(participant);
        }
        public async Task <ParticipantDto> GetParticipant(int participantId)
        {
            try
            {
                ParticipantDto result = await ParticipantService.GetParticipant(participantId);

                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public ActionResult Registration(ParticipantDto objMemberDto)
        {
            ParticipantManager objMemberManager = new ParticipantManager();
            bool status = objMemberManager.AddParticipant(objMemberDto);

            if (status)
            {
                return(RedirectToAction("Login"));
            }
            else
            {
                return(Content("Error"));
            }
        }
Beispiel #19
0
        public async Task <IActionResult> PutParticipantAsync(string id, [FromBody] ParticipantDto participant)
        {
            var result = await _mediator.Send(new UpdateParticipantRequest()
            {
                CustomerId = id, Participant = participant
            });

            if (result.Error != null)
            {
                return(BadRequest(result.Error));
            }

            return(Ok(result.Participant));
        }
Beispiel #20
0
 public async Task <ActionResult <ParticipantDto> > Post([FromBody] ParticipantDto item)
 {
     try
     {
         if (item.UserId == null || item.GroupId == null || item.ParticipantRoleId == null)
         {
             return(BadRequest());
         }
         return(Ok(await _supervisor.CreateParticipantAsync(item)));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex));
     }
 }
Beispiel #21
0
        private async Task AddNewMembers(Command request, GroupClassAggregate groupClassAggregate, List <string> currentIds, List <string> updateMembers,
                                         CancellationToken cancellationToken)
        {
            List <string> newParticipantIds = GetNewIds(currentIds, updateMembers);
            List <User>   newMembers        =
                await _context.Users.Where(x => newParticipantIds.Contains(x.Id)).ToListAsync(cancellationToken);

            newMembers.ForEach(member =>
            {
                PassAggregate passAggregate = PassAggregate.New()
                                              .UpdateByCommand(request)
                                              .WithParticipant(member);
                ParticipantDto participantDto = request.Participants.First(p => p.Id == member.Id);
                groupClassAggregate.AddParticipant(member, participantDto.Role, passAggregate);
            });
        }
Beispiel #22
0
        public async Task <IActionResult> PostParticipant(string roomCode, ParticipantDto participantDto)
        {
            var participant = _mapper.Map <Participant>(participantDto);

            var quizRoom = await _context.QuizRooms.Include(q => q.Participants).SingleAsync(q => q.RoomCode == roomCode);

            if (participant.Name.ToLower() == "admin" || quizRoom.Participants.Any(p => p.Name.ToLower() == participant.Name.ToLower()))
            {
                return(Ok("exists"));
            }

            quizRoom.Participants.Add(participant);
            await _context.SaveChangesAsync();

            return(Ok(participant));
        }
Beispiel #23
0
        public async Task <IActionResult> PutParticipantNameAsync(string id, [FromBody] ParticipantDto participant)
        {
            var result = await _mediator.Send(new UpdateParticipantNameRequest()
            {
                Participant = participant,
                CustomerId  = id,
                UserName    = User.Identity.Name
            });

            if (result.Error != null)
            {
                return(Unauthorized(result.Error));
            }

            return(Ok());
        }
        public async Task <IActionResult> Post([FromBody] ParticipantDto participantObj)
        {
            var participantToAdd = new Participant {
                FirstName = participantObj.FirstName,
                LastName  = participantObj.LastName,
                Email     = participantObj.Email,
                Activity  = participantObj.Activity,
                Comments  = participantObj.Comments
            };
            await _context.Participants.AddAsync(participantToAdd);

            await _context.SaveChangesAsync();

            // Done
            return(StatusCode(201));
        }
Beispiel #25
0
 public static UpdateParticipantRequest MapToParticipantRequest(ParticipantDto participant)
 {
     return(new UpdateParticipantRequest
     {
         Fullname = participant.Fullname,
         FirstName = participant.FirstName,
         LastName = participant.LastName,
         ContactEmail = participant.ContactEmail,
         ContactTelephone = participant.ContactTelephone,
         DisplayName = participant.DisplayName,
         Representee = participant.Representee,
         Username = participant.Username,
         LinkedParticipants = LinkedParticipantToRequestMapper
                              .MapToLinkedParticipantRequestList(participant.LinkedParticipants)
     });
 }
        public bool AddParticipant(ParticipantDto objParticipantDto)
        {
            ParticipantDal objParticipantDal = new ParticipantDal();
            User           objParticipant    = new User();

            objParticipant.FirstName    = objParticipantDto.FirstName;
            objParticipant.Email        = objParticipantDto.Email;
            objParticipant.Mobile       = objParticipantDto.Mobile;
            objParticipant.Password     = objParticipantDto.Password;
            objParticipant.Education    = objParticipantDto.Education;
            objParticipant.LastName     = objParticipantDto.LastName;
            objParticipant.ProfilePhoto = objParticipantDto.ProfilePicture;
            bool status = objParticipantDal.InsertParticipant(objParticipant);

            return(status);
        }
        public bool UpdateParticipant(ParticipantDto participant)
        {
            var participantEntity = GetById(participant.Id);
            var emailHash         = StringHelper.Md5HashEncode(participant.Email.ToLower());

            if (!string.IsNullOrEmpty(participant.ConsumerId))
            {
                var crmConsumerId = _consumerManager.GetOrCreateConsumerId(participant.ConsumerId, participant.Country, emailHash);
                participantEntity.ConsumerCrmId = crmConsumerId;
            }

            participantEntity.LastParticipatedDate = participant.LastParticipatedDate.ToUtc();
            participantEntity.LastWonDate          = participant.LastWonDate.ToUtc();
            participantEntity.Email = participant.Email;

            return(Update(participantEntity));
        }
Beispiel #28
0
        public async Task <ActionResult <ParticipantDto> > Get(Guid userId, Guid groupId)
        {
            try
            {
                ParticipantDto participant = await _supervisor.GetParticipantByIdAsync(userId, groupId);

                if (participant == null)
                {
                    return(NotFound());
                }
                return(Ok(participant));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
        public async Task <HttpResponseMessage> UpdateParticipant([FromBody] ParticipantDto participant)
        {
            HttpResponseMessage result;

            try
            {
                await ParticipantService.UpdateParticipant(participant);

                result = Request.CreateResponse(HttpStatusCode.Created);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                result = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message);
            }
            return(result);
        }
        public async Task <IActionResult> GetParticipantResult(string roomCode, string username)
        {
            var participant = await _context.Participants.FirstOrDefaultAsync(p => p.QuizRoom.RoomCode.ToLower() == roomCode.ToLower() && p.Name.ToLower() == username.ToLower());

            if (participant == null)
            {
                return(NotFound());
            }

            var participantResult = new ParticipantDto()
            {
                Score = participant.Score,
                Rank  = participant.Rank
            };

            return(Ok(participantResult));
        }