public IActionResult GetInvitations()
        {
            var userId           = Request.GetUserId();
            var allInv           = _userFacade.GetAllInvitationsForUser(userId);
            var invitationModels = new List <InvitationModel>();

            allInv.ToList().ForEach(i => invitationModels.Add(new InvitationModel(i.Id,
                                                                                  i.FromUser, i.FromUserName, i.ToUser, i.ToUserName, i.ToGroup,
                                                                                  i.ToGroupTitle, i.SuggestedRole)));
            var response = new InvitationsResponse(invitationModels);

            return(Ok(response));
        }
Пример #2
0
        public void AddNewMemberWithSanctionWithInvitation_MemberWasAdded()
        {
            //Arrange
            var createdGroupId = _groupFacade.CreateGroup(_groupCreator.Id, "Some group", new List <string> {
                "c#"
            },
                                                          "You're welcome!", 3, 20, false, GroupType.Lecture);
            var testUserId = _accountFacade.RegUser("Alena", Credentials.FromRawData("some email", "password"), false);

            _sanctionFacade.AddSanction("some rule", testUserId, _groupCreator.Id, SanctionType.NotAllowToJoinGroup);

            _userFacade.Invite(_groupCreator.Id, testUserId, createdGroupId, MemberRole.Member);
            var invitationId = _userFacade.GetAllInvitationsForUser(testUserId).ToList()[0].Id;

            //Act
            _userFacade.ChangeInvitationStatus(testUserId, invitationId, InvitationStatus.Declined);

            //Assert
            Assert.AreEqual(1, _groupFacade.GetGroup(createdGroupId, _groupCreator.Id).GroupMemberInfo.Count());
        }