Пример #1
0
        public string Execute(params string[] args)
        {
            Check.CheckLength(1, args);

            var teamName = args[0];

            var user = Session.User;

            if (Session.User == null)
            {
                throw new InvalidOperationException(Constants.ErrorMessages.LoginFirst);
            }

            var isTeamExist = CommandHelper.IsTeamExisting(teamName);

            if (!isTeamExist)
            {
                throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName));
            }

            var isInviteExist = CommandHelper.IsInviteExisting(teamName, user);

            if (!isInviteExist)
            {
                throw new ArgumentException(string.Format(Constants.ErrorMessages.InviteNotFound, teamName));
            }

            invitationService.AcceptInvite(teamName, user.Username);

            return($"User {user.Username} joined team {teamName}!");
        }
Пример #2
0
        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));
            }

            invitationService.AcceptInvite(teamName, Session.User.Username);


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