Пример #1
0
        public async Task <JsonResult> CreateInvProduct(int pid)
        {
            var user    = _authenticationSupport.CurrentUser;
            var invInfo = await _invitationService.Create(user.UserId, pid);

            var model = _mapper.Map <InvitationModel>(invInfo);

            return(SucessResult(model));
        }
Пример #2
0
        public async Task <ActionResult <OperationResult <CreateResponse> > > Create(CreateRequest request)
        {
            if (!await _roomService.CheckUserCanInvite(request.UserId, request.RoomId))
            {
                return(OperationResult <CreateResponse> .Error("Can't invite to room"));
            }

            var room = await _roomService.Get(request.RoomId);

            Invitation invitaion = await _invitationService.Create(request.UserId, room.Id, request.IsPermanent, room.ExpireAt);

            return(OperationResult <CreateResponse> .Ok(new CreateResponse
            {
                InvitationId = invitaion.Id
            }));
        }
Пример #3
0
        public async void Create()
        {
            var mock  = new ServiceMockFacade <IInvitationRepository>();
            var model = new ApiInvitationRequestModel();

            mock.RepositoryMock.Setup(x => x.Create(It.IsAny <Invitation>())).Returns(Task.FromResult(new Invitation()));
            var service = new InvitationService(mock.LoggerMock.Object,
                                                mock.RepositoryMock.Object,
                                                mock.ModelValidatorMockFactory.InvitationModelValidatorMock.Object,
                                                mock.BOLMapperMockFactory.BOLInvitationMapperMock,
                                                mock.DALMapperMockFactory.DALInvitationMapperMock);

            CreateResponse <ApiInvitationResponseModel> response = await service.Create(model);

            response.Should().NotBeNull();
            mock.ModelValidatorMockFactory.InvitationModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiInvitationRequestModel>()));
            mock.RepositoryMock.Verify(x => x.Create(It.IsAny <Invitation>()));
        }
Пример #4
0
        public ActionResult <Invitation> Post([FromBody] InvitationRequest invitationRequest)
        {
            Invitation createdInvitation = _invitationService.Create(new Invitation(invitationRequest));

            if (createdInvitation == null)
            {
                return(Unauthorized("Cet utilisateur a deja ete invite."));
            }
            Event ev = _eventService.GetFromEventId(invitationRequest.EventId);

            if (ev.InvitationList == null)
            {
                ev.InvitationList = new List <string>();
            }
            ev.InvitationList.Add(createdInvitation.Id);
            _eventService.UpdateEvent(ev);
            _notificationService.Create(new Notification(createdInvitation));

            // this._emailService.Send(createdInvitation.To, _emailService.CreateInvitationMailSubject(createdInvitation.From, ev.Name),
            //     _emailService.CreateInviteMailBody(createdInvitation.From, ev.Name, ev.Id));

            return(CreatedAtRoute("Get", new { id = createdInvitation.Id }, createdInvitation));
        }
Пример #5
0
        /// <summary>
        /// 发送加入群组邀请
        /// </summary>
        /// <param name="group"><see cref="GroupEntity"/></param>
        /// <param name="sender">发送人</param>
        /// <param name="userIds">邀请接收人</param>
        /// <param name="remark">附言</param>
        public void SendInvitations(GroupEntity group, IUser sender, string remark, IEnumerable <long> userIds)
        {
            //调用InvitationService的发送请求的方法
            InvitationService invitationService = new InvitationService();

            foreach (var userId in userIds)
            {
                if (!IsMember(group.GroupId, userId))
                {
                    Invitation invitation = Invitation.New();
                    invitation.ApplicationId      = GroupConfig.Instance().ApplicationId;
                    invitation.InvitationTypeKey  = InvitationTypeKeys.Instance().InviteJoinGroup();
                    invitation.UserId             = userId;
                    invitation.SenderUserId       = sender.UserId;
                    invitation.Sender             = sender.DisplayName;
                    invitation.SenderUrl          = SiteUrls.Instance().SpaceHome(sender.UserId);
                    invitation.RelativeObjectId   = group.GroupId;
                    invitation.RelativeObjectName = group.GroupName;
                    invitation.RelativeObjectUrl  = SiteUrls.Instance().GroupHome(group.GroupKey);
                    invitation.Remark             = remark;
                    invitationService.Create(invitation);
                }
            }
        }
        /// <summary>
        /// 通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void TopicMemberApplyNoticeModule_After(TopicMemberApply sender, CommonEventArgs eventArgs)
        {
            TopicService groupService = new TopicService();
            TopicEntity  entity       = groupService.Get(sender.TopicId);

            if (entity == null)
            {
                return;
            }

            User senderUser = DIContainer.Resolve <IUserService>().GetFullUser(sender.UserId);

            if (senderUser == null)
            {
                return;
            }
            InvitationService invitationService = new InvitationService();
            Invitation        invitation;
            NoticeService     noticeService = DIContainer.Resolve <NoticeService>();
            Notice            notice;

            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                if (sender.ApplyStatus == TopicMemberApplyStatus.Pending)
                {
                    List <long> toUserIds = new List <long>();
                    toUserIds.Add(entity.UserId);
                    toUserIds.AddRange(entity.TopicManagers.Select(n => n.UserId));
                    foreach (var toUserId in toUserIds)
                    {
                        //申请加入专题的请求
                        if (!groupService.IsMember(sender.TopicId, sender.UserId))
                        {
                            invitation = Invitation.New();
                            invitation.ApplicationId      = TopicConfig.Instance().ApplicationId;
                            invitation.InvitationTypeKey  = InvitationTypeKeys.Instance().ApplyJoinTopic();
                            invitation.UserId             = toUserId;
                            invitation.SenderUserId       = sender.UserId;
                            invitation.Sender             = senderUser.DisplayName;
                            invitation.SenderUrl          = SiteUrls.Instance().SpaceHome(sender.UserId);
                            invitation.RelativeObjectId   = sender.TopicId;
                            invitation.RelativeObjectName = entity.TopicName;
                            invitation.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().TopicHome(entity.TopicKey));
                            invitation.Remark             = sender.ApplyReason;
                            invitationService.Create(invitation);
                        }
                    }
                }
            }

            string noticeTemplateName = string.Empty;

            if (eventArgs.EventOperationType == EventOperationType.Instance().Approved())
            {
                if (sender.ApplyStatus == TopicMemberApplyStatus.Approved)
                {
                    noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyApproved();
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                if (sender.ApplyStatus == TopicMemberApplyStatus.Disapproved)
                {
                    noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyDisapproved();
                }
            }

            if (string.IsNullOrEmpty(noticeTemplateName))
            {
                return;
            }

            notice = Notice.New();

            notice.UserId        = sender.UserId;
            notice.ApplicationId = TopicConfig.Instance().ApplicationId;
            notice.TypeId        = NoticeTypeIds.Instance().Hint();
            //notice.LeadingActorUserId = UserContext.CurrentUser.UserId;
            //notice.LeadingActor = UserContext.CurrentUser.DisplayName;
            //notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(UserContext.CurrentUser.UserId));
            notice.RelativeObjectId   = sender.TopicId;
            notice.RelativeObjectName = StringUtility.Trim(entity.TopicName, 64);
            notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().TopicHome(entity.TopicKey));
            notice.TemplateName       = noticeTemplateName;
            noticeService.Create(notice);
        }