Beispiel #1
0
        public string Execute(string[] data)
        {
            if (!Validation.CheckLength(2, data))
            {
                return(InvalidLength);
            }

            if (Session.User == null)
            {
                return(NoUser);
            }

            string username = data[1];
            string teamName = data[0];

            if (!userService.Exist(username) || !teamService.Exists(teamName))
            {
                return(NotExist);
            }


            if (!teamService.IsCreator(teamName, Session.User.Username))
            {
                return(NotAllowed);
            }

            if (invitationService.Exists(username, teamName))
            {
                return(InviteAlreadySent);
            }

            invitationService.InviteUser(teamName, username);

            return(String.Format(SuccessMessage, teamName, username));
        }
        public string Execute(string[] data)
        {
            if (!Validation.CheckLength(1, data))
            {
                return(InvalidLength);
            }

            if (Session.User == null)
            {
                return(NoUser);
            }

            string teamName = data[0];

            if (!teamService.Exists(teamName))
            {
                return(String.Format(TeamNotFound, teamName));
            }

            if (!invitationService.Exists(teamName, Session.User.Username))
            {
                return(String.Format(NoInvite, teamName));
            }

            var invitationId = invitationService.ByTeamAndUserName(teamName, Session.User.Username).Id;

            invitationService.DeclineInvite(invitationId);

            return(String.Format(SuccessMessage, teamName, Session.User.Username));
        }