Exemplo n.º 1
0
 public static ANEventMemberModel ToModel(ANEventMember entity)
 {
     return(entity == null ? null : new ANEventMemberModel()
     {
         Id = entity.Id,
         ANEvent = new ANEventModel()
         {
             Id = entity.ANEventId.GetValueOrDefault()
         },
         User = new UserModel()
         {
             Id = entity.UserId.GetValueOrDefault()
         }
     });
 }
Exemplo n.º 2
0
        public bool ApproveJoinEvent([FromBody] int RTJId)
        {
            var firstRTJ = this.ANDBUnitOfWork.ANEventRequestToJoinRepository.GetAll()
                           .Include("ANEvent")
                           .FirstOrDefault(x => x.Id == RTJId);

            if (firstRTJ == null || firstRTJ.ANEvent == null)
            {
                return(false);
            }
            if (firstRTJ.Status != (int)ANRequestToJoinStatus.Waiting)
            {
                return(false);
            }
            if (!firstRTJ.ANEvent.UserId.HasValue || firstRTJ.ANEvent.UserId.Value != this.CurrentUser.Id)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            if (!this.ANDBUnitOfWork.ANEventMemberRepository.GetAll().Any(x => x.UserId == firstRTJ.UserId && x.ANEventId == firstRTJ.ANEventId))
            {
                var entity = new ANEventMember()
                {
                    ANEventId = firstRTJ.ANEventId,
                    UserId    = firstRTJ.UserId,
                    JoinDate  = DateTimeHelper.DateTimeNow,
                };

                this.ANDBUnitOfWork.ANEventMemberRepository.Save(entity);
            }
            firstRTJ.Status = (int)ANRequestToJoinStatus.Approved;
            this.ANDBUnitOfWork.ANEventRequestToJoinRepository.Save(firstRTJ);
            this.ANDBUnitOfWork.Commit();


            return(true);
        }