public ANEventDetailRequestToJoinModel GetEventDetailRequestToJoin(int Id)
        {
            if (!this.ANDBUnitOfWork.ANEventRepository.GetAll().Any(x => x.Id == Id && x.UserId.HasValue && x.UserId.Value == this.CurrentUser.Id))
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }
            var requestEntity = this.ANDBUnitOfWork.ANEventRequestToJoinRepository.GetAll()
                                .Include("User.UserProfiles.Image")
                                .Where(x => x.ANEventId.HasValue && x.ANEventId.Value == Id && x.Status.HasValue && x.Status.Value == (int)Common.ANRequestToJoinStatus.Waiting).ToList();

            var RTJmodels = requestEntity.Select(x =>
            {
                var firstUserProfile = x.User.UserProfiles.FirstOrDefault();
                var anEventRTJModel  = ANEventRequestToJoinMapper.ToModel(x);
                anEventRTJModel.User = UserMapper.ToModel(x.User);

                if (anEventRTJModel.User != null)
                {
                    anEventRTJModel.User.Profile = UserProfileMapper.ToModel(firstUserProfile);
                    if (anEventRTJModel.User.Profile != null)
                    {
                        anEventRTJModel.User.Profile.Avatar = ImageMapper.ToModel(firstUserProfile.Image);
                    }
                }
                return(anEventRTJModel);
            }).ToList();

            return(new ANEventDetailRequestToJoinModel()
            {
                EventId = Id,
                ANEventRequestToJoins = RTJmodels
            });
        }
        public ANEventRequestToJoinModel JoinEvent([FromBody] int eventId)
        {
            var isExistInEventMember = this.ANDBUnitOfWork.ANEventMemberRepository.GetAll().Any(x => x.ANEventId.HasValue && x.ANEventId.Value == eventId && x.UserId.HasValue && x.UserId.Value == this.CurrentUser.Id);

            if (isExistInEventMember)
            {
                return(null);
            }

            var isEventHost = this.ANDBUnitOfWork.ANEventRepository.GetAll().Any(x => x.UserId.HasValue && x.UserId.Value == this.CurrentUser.Id && x.Id == eventId);

            if (isEventHost)
            {
                return(null);
            }

            var entityInRTJ = this.ANDBUnitOfWork.ANEventRequestToJoinRepository.GetAll().FirstOrDefault(x => x.ANEventId.HasValue && x.ANEventId.Value == eventId && x.UserId.HasValue && x.UserId.Value == this.CurrentUser.Id);

            if (entityInRTJ != null && entityInRTJ.Status == (int)Common.ANRequestToJoinStatus.Waiting)
            {
                return(null);
            }
            if (entityInRTJ == null)
            {
                entityInRTJ = new ANEventRequestToJoin()
                {
                    UserId      = this.CurrentUser.Id,
                    ANEventId   = eventId,
                    RequestDate = DateTimeHelper.DateTimeNow,
                };
            }
            entityInRTJ.Status = (int)Common.ANRequestToJoinStatus.Waiting;

            this.ANDBUnitOfWork.ANEventRequestToJoinRepository.Save(entityInRTJ);
            this.ANDBUnitOfWork.Commit();

            return(ANEventRequestToJoinMapper.ToModel(entityInRTJ));
        }