public string Execute(string[] args) { Check.CheckLenght(6, args); AuthenticationManager.Authorize(); var name = args[0]; var description = args[1]; var ifStartParsed = DateTime.TryParseExact($"{args[2]} {args[3]}", "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out DateTime startDate); var ifEndParse = DateTime.TryParseExact($"{args[4]} {args[5]}", Constants.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out DateTime endDate); if (!ifStartParsed || !ifEndParse) { throw new ArgumentException(Constants.ErrorMessages.InvalidDateFormat); } if (startDate > endDate) { throw new ArgumentException(Constants.ErrorMessages.StartDateAfterEndDate); } using (var context = new TeamBuilderContext()) { var currentUser = AuthenticationManager.GetCurrentUser(); var newEvent = new Event { Name = name, Description = description, StartDate = startDate, EndDate = endDate, CreatorId = currentUser.Id }; if (!Check.IsValid(newEvent)) { throw new ArgumentException(Constants.ErrorMessages.EventNotValid); } context.Events.Add(newEvent); context.SaveChanges(); } return(string.Format(Constants.SuccessMessages.Event, name)); }
// CreateEvent <name> <description> <startDate> <endDate> // Date format [dd/MM/yyyy HH:mm] => NB! date split in two arguments public string Execute(string[] inputArgs) { // Validate arguments count Check.CheckLength(6, inputArgs); // NB. 6 arguments as dateTime comes as 2 arguments [date time] // Authorize user AuthenticationManager.Authorize(); // Get arguments string eventName = inputArgs[0]; string description = inputArgs[1]; DateTime startDateTime, endDateTime; bool isValidStartDateTime = DateTime.TryParseExact( inputArgs[2] + " " + inputArgs[3], // [date time] Constants.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out startDateTime); bool isValidEndDateTime = DateTime.TryParseExact( inputArgs[4] + " " + inputArgs[5], // [date time] Constants.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDateTime); // Validate date format if (!isValidStartDateTime || !isValidEndDateTime) { throw new ArgumentException(Constants.ErrorMessages.InvalidDateFormat); } // Validate startDate < endDate if (startDateTime >= endDateTime) { throw new ArgumentException(Constants.ErrorMessages.StartDateBeforeEndDate); } // Create event CreateEvent(eventName, description, startDateTime, endDateTime); return($"Event {eventName} was created successfully!"); }
public string Execute(string[] inputArgs) { string teamName = inputArgs[0]; string username; if (String.IsNullOrWhiteSpace(teamName)) { throw new InvalidOperationException("Invalid data."); } AuthenticationManager.Authorize(); using (var db = new TeamBuilderContext()) { var team = db.Teams .FirstOrDefault(x => x.Name == teamName); var loggedUser = AuthenticationManager.GetCurrentUser(); username = loggedUser.Username; if (team == null) { throw new ArgumentException($"Team {teamName} not found!"); } bool invitationExists = db.Invitations .Any(x => x.InvitedUserId == loggedUser.UserId && x.TeamId == team.TeamId && x.IsActive == true); if (!invitationExists) { throw new InvalidOperationException($"Invite from {teamName} is not found!"); } var invitation = db.Invitations .FirstOrDefault(x => x.TeamId == team.TeamId && x.InvitedUserId == loggedUser.UserId); invitation.IsActive = false; db.SaveChanges(); } return($"Invite from {teamName} declined."); }
// CreateTeam <name> <acronym> <description> public string Execute(string[] commandArgs) { if (commandArgs.Length < 2) { throw new FormatException(Constants.ErrorMessages.InvalidArgumentsCount); } AuthenticationManager.Authorize(); string teamName = commandArgs[0]; if (teamName.Length > 25) { throw new ArgumentException(Constants.ErrorMessages.InvalidTeamName); } if (CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamExists, teamName)); } string acronym = commandArgs[1]; if (acronym.Length != 3) { throw new ArgumentException(Constants.ErrorMessages.InvalidAcronym); } string description = null; if (commandArgs.Length > 2) { description = string.Join(" ", commandArgs.Skip(2)); if (description.Length > 32) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InvalidDescription, 32)); } } CreateTeam(teamName, acronym, description); return($"Team {teamName} successfully created!"); }
public string Execute(string[] args) { Check.CheckLength(6, args); AuthenticationManager.Authorize(); string eventName = args[0]; string description = args[1]; string startDateStr = args[2] + " " + args[3]; string endDateStr = args[4] + " " + args[5]; DateTime startDate = ValidateDateParsing(startDateStr); DateTime endDate = ValidateDateParsing(endDateStr); if (startDate >= endDate) { throw new ArgumentException(Constants.ErrorMessages.StartDateIsAfterEndDate); } var currentUser = AuthenticationManager.GetGurrentUser(); var newEvent = new Event() { Name = eventName, Description = description, StartDate = startDate, EndDate = endDate, CreatorId = currentUser.Id }; if (!IsValid(newEvent)) { throw new ArgumentException(Constants.ErrorMessages.InvalidEventArgs); } using (var ctx = new TeamBuilderContext()) { ctx.Events.Add(newEvent); ctx.SaveChanges(); } return($"Event {eventName} was created successfully!"); }
public string Execute(string[] inputArgs) { Check.CheckLength(0, inputArgs); AuthenticationManager.Authorize(); var currentUser = AuthenticationManager.GetCurrentUser(); using (var context = new TeamBuilderContext()) { var user = context.Users.Single(u => u.Username.Equals(currentUser.Username)); user.IsDeleted = true; context.SaveChanges(); AuthenticationManager.Logout(); } return($"User {currentUser.Username} was deleted successfully!"); }
public string Execute(string[] args) { Check.CheckLength(0, args); AuthenticationManager.Authorize(); User currentUser = AuthenticationManager.GetCurrentUser(); using (TeamBuilderContext context = new TeamBuilderContext()) { currentUser.IsDeleted = true; context.Users.Update(currentUser); context.SaveChanges(); AuthenticationManager.LogOut(); } return($"User {currentUser.Username} was deleted successfully!"); }
public string Execute(string[] inputArgs) { Validator.CheckLength(1, inputArgs); AuthenticationManager.Authorize(); string teamName = inputArgs[0]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } if (!CommandHelper.IsCreatorOfTeam(teamName, AuthenticationManager.GetCurrentUser().Username)) { throw new InvalidOperationException(Constants.ErrorMessages.NotAllowed); } this.DisbandTem(teamName); return($"Team {teamName} was disbaned!"); }
public string Execute(string[] args) { Check.CheckLenght(0, args); AuthenticationManager.Authorize(); var currentUser = AuthenticationManager.GetCurrentUser(); using (var context = new TeamBuilderContext()) { currentUser.IsDeleted = true; context.Users.Update(currentUser); context.SaveChanges(); AuthenticationManager.Logout();; } return(string.Format(Constants.SuccessMessages.Delete, currentUser.UserName)); }
public string Execute(string[] inputArgs) { Check.CheckLength(0, inputArgs); AuthenticationManager.Authorize(); User currentUser = AuthenticationManager.GetCurrentUser(); using (var db = new TeamBuilderContext()) { db.Entry(currentUser).State = EntityState.Unchanged; currentUser.IsDeleted = true; db.SaveChanges(); AuthenticationManager.Logout(); } return($"User {currentUser.Username} was deleted successfully!"); }
public string Execute(string[] inputArgs) { Check.CheckLength(2, inputArgs); AuthenticationManager.Authorize(); string teamName = inputArgs[0]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } string username = inputArgs[1]; if (!CommandHelper.IsUserExisting(username)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.UserNotFound, username)); } if (!CommandHelper.IsMemberOfTeam(teamName, username)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.NotPartOfTeam, username, teamName)); } User currentUser = AuthenticationManager.GetCurrentUser(); if (!CommandHelper.IsUserCreatorOfTeam(teamName, currentUser)) { throw new InvalidOperationException(Constants.ErrorMessages.NotAllowed); } if (currentUser.Username == username) { throw new InvalidOperationException( string.Format(Constants.ErrorMessages.CommandNotAllowed, "DisbandTeam")); } this.KickMember(teamName, username); return($"User {username} was kicked from {teamName}!"); }
public string Execute(string[] inputArgs) { //• AcceptInvite <teamName> Check.CheckLength(1, inputArgs); AuthenticationManager.Authorize(); string teamName = inputArgs[0]; using (var context = new TeamBuilderContext()) { var team = context.Teams.FirstOrDefault(t => t.Name == teamName); if (team == null) { throw new ArgumentException(Constants.ErrorMessages.TeamNotFound, teamName); } var currentUser = AuthenticationManager.GetCurrentUser(); if (!context.Invitations.Any(i => i.InvitedUserId == currentUser.Id && i.TeamId == team.Id)) { throw new ArgumentException(Constants.ErrorMessages.InviteNotFound, teamName); } var invitation = context.Invitations.FirstOrDefault( i => i.InvitedUserId == currentUser.Id && i.Team.Name == teamName); context.Invitations.Remove(invitation); context.UserTeams.Add(new UserTeam { UserId = currentUser.Id, TeamId = team.Id }); context.SaveChanges(); return($"User {currentUser.Username} joined team {teamName}!"); } }
//• CreateEvent <name> <description> <startDate> <startTime> <endDate> <endTime> public string Execute(string[] inputArgs) { Check.CheckLength(6, inputArgs); AuthenticationManager.Authorize(); var name = inputArgs[0]; var description = inputArgs[1]; DateTime startDateTime; bool isStartDateTime = DateTime.TryParseExact( inputArgs[2] + " " + inputArgs[3], Constants.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out startDateTime); DateTime endDateTime; bool isEndDateTime = DateTime.TryParseExact( inputArgs[4] + " " + inputArgs[5], Constants.DateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out endDateTime); if (!isEndDateTime || !isStartDateTime) { throw new ArgumentException(Constants.ErrorMessages.InvalidDateFormat); } if (startDateTime > endDateTime) { throw new ArgumentException(Constants.ErrorMessages.InvalidStartDate); } EventService.CreateEvent(name, description, startDateTime, endDateTime); return($"Event {name} was created successfully!"); }
public string Execute(string[] inputArgs) { // TODO: Check input lenght. Check.CheckLenght(2, inputArgs); // TODO: Authorize for logged in users. AuthenticationManager.Authorize(); var teamName = inputArgs[0]; if (!CommandHelper.IsTeamExists(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } string username = inputArgs[1]; if (!CommandHelper.IsUserExisting(username)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.UserNotFound, username)); } if (!CommandHelper.IsMemberOfTeam(teamName, username)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.NotPartOfTeam, username, teamName)); } if (!CommandHelper.IsUserCreatorOfTeam(teamName, AuthenticationManager.GetCurrentUser().Username)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.NotAllowed)); } if (AuthenticationManager.GetCurrentUser().Username == username) { throw new InvalidOperationException(string.Format(Constants.ErrorMessages.CommandNotAllowed, "DisbandTeam")); } this.KickMemberFromTeam(teamName, username); return($"User {username} was kicked from {teamName}!"); }
public string Execute(string[] inputArgs) { Check.CheckLength(6, inputArgs); AuthenticationManager.Authorize(); string name = inputArgs[0]; string description = inputArgs[1]; string startDateString = $"{inputArgs[2]} {inputArgs[3]}"; DateTime startDate = this.ParseDate(startDateString); string endDateString = $"{inputArgs[4]} {inputArgs[5]}"; DateTime endDate = this.ParseDate(endDateString); if (startDate > endDate) { throw new ArgumentException("Start date should be before end date."); } User currentUser = AuthenticationManager.GetCurrentUser(); var @event = new Event { Name = name, Description = description, StartDate = startDate, EndDate = endDate, CreatorId = currentUser.Id }; using (var context = new TeamBuilderContext()) { context.Events.Add(@event); context.SaveChanges(); } return($"Event {name} was created successfully!"); }
public string Execute(string[] inputArgs) { Check.CheckLength(2, inputArgs); AuthenticationManager.Authorize(); string teamName = inputArgs[0]; string userName = inputArgs[1]; if (!CommandHelper.IsUserExisting(userName) || !CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(Constants.ErrorMessages.TeamOrUserNotExist); } if (this.IsInvitePending(teamName, userName)) { throw new InvalidOperationException(Constants.ErrorMessages.InviteIsAlreadySent); } if (!this.IsCreatorOrPartOfTeam(teamName)) { throw new InvalidOperationException(Constants.ErrorMessages.NotAllowed); } this.SendInvite(teamName, userName); return($"Team {teamName} invited {userName}!"); }
//• Disband <teamName> public string Execute(string[] inputArgs) { Check.CheckLength(1, inputArgs); AuthenticationManager.Authorize(); string teamName = inputArgs[0]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new InvalidOperationException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } Models.User currentUser = AuthenticationManager.GetCurrentUser(); if (!CommandHelper.IsUserCreatorOfTeam(teamName, currentUser)) { throw new InvalidOperationException(Constants.ErrorMessages.NotAllowed); } TeamService.DisbandTeam(teamName); return($"{teamName} has been disbanded!"); }
// CreateTeam <name> <acronym> <description> public string Execute(string[] inputArgs) { if (inputArgs.Length != 2 && inputArgs.Length != 3) { throw new ArgumentOutOfRangeException(nameof(inputArgs)); } AuthenticationManager.Authorize(); string teamName = inputArgs[0]; if (teamName.Length > Constants.MaxTeamNameLength) { throw new ArgumentException(Constants.ErrorMessages.TeamNameOverflow); } if (CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamAlreadyExists, teamName)); } string acronym = inputArgs[1]; if (acronym.Length != 3) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InvalidAcronym, acronym)); } string description = inputArgs.Length == 3 ? inputArgs[2] : null; if (description != null && description.Length > Constants.MaxTeamDescriptionLength) { throw new ArgumentException(Constants.ErrorMessages.TeamDescriptionOverflow); } this.addTeam(teamName, acronym, description); return($"Team {teamName} was successfully created!"); }
public string Execute(string[] args) { Check.CheckLength(4, args); string eventName = args[0]; string description = args[1]; DateTime startDate; DateTime endDate; if (!DateTime.TryParseExact(args[2], "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out startDate) || !DateTime.TryParseExact(args[3], "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out endDate)) { throw new ArgumentException(Constants.ErrorMessages.InvalidDateFormat); } else if (startDate > endDate) { throw new ArgumentException("Start date should be before end date."); } AuthenticationManager.Authorize(); using (var context = new TeamBuilderContext()) { var currentUser = AuthenticationManager.GetCurrentUser(); context.Entry(currentUser).State = EntityState.Modified; context.Events.Add(new Event { Name = eventName, Description = description, StartDate = startDate, EndDate = endDate, Creator = currentUser, CreatorId = currentUser.Id }); context.SaveChanges(); } return($"Event {eventName} was created successfully!"); }
public string Execute(string[] args) { Check.CheckLength(1, args); AuthenticationManager.Authorize(); string teamName = args[0]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } var currentUser = AuthenticationManager.GetGurrentUser(); if (!CommandHelper.IsInviteExisting(teamName, currentUser)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InviteNotFound, teamName)); } using (var ctx = new TeamBuilderContext()) { var invitation = ctx.Invitations.Single(i => i.Team.Name == teamName && i.InvitedUserId == currentUser.Id); invitation.IsActive = false; var team = ctx.Teams.Single(t => t.Name == teamName); var userTeam = new UserTeam() { UserId = currentUser.Id, TeamId = team.Id }; ctx.UserTeams.Add(userTeam); ctx.SaveChanges(); } return($"User {currentUser.Username} joined team {teamName}!"); }
public string Execute(string[] arguments) { Check.CheckLength(2, arguments); AuthenticationManager.Authorize(); string teamName = arguments[0]; string username = arguments[1]; User currentUser = AuthenticationManager.GetCurrentUser(); Team team = this.teamService.GetTeamByName(teamName); User inviteUser = this.userService.GetUserByUsername(username); if (inviteUser == team.Creator) { this.userTeamService.AddUserToTeam(inviteUser, team); return($"Team {team.Name} invited {inviteUser.Username}!"); } this.invitationService.SendInvitation(team, inviteUser, currentUser); return($"Team {teamName} invited {username}!"); }
//• DeclineInvite <teamName> public string Execute(string[] inputArgs) { Check.CheckLength(1, inputArgs); AuthenticationManager.Authorize(); string teamName = inputArgs[0]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } if (!CommandHelper.IsInviteExisting(teamName, AuthenticationManager.GetCurrentUser())) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InviteNotFound, teamName)); } InviteService.DeclineInvite(teamName); return($"User {AuthenticationManager.GetCurrentUser().Username} declined {teamName}'s invitation!"); }
public string Execute(string[] inputArgs) { string teamName = inputArgs[0]; string acronym = inputArgs[1]; if (string.IsNullOrWhiteSpace(teamName) || string.IsNullOrWhiteSpace(acronym)) { throw new InvalidOperationException("Invalid data."); } AuthenticationManager.Authorize(); if (acronym.Length != 3) { throw new ArgumentException($"Acronym {acronym} not valid!"); } using (var db = new TeamBuilderContext()) { if (db.Teams.Any(x => x.Name == teamName)) { throw new ArgumentException($"Team {teamName} exists!"); } var user = AuthenticationManager.GetCurrentUser(); Team team = new Team() { Name = teamName, Acronym = acronym, CreatorId = user.UserId }; db.Teams.Add(team); db.SaveChanges(); } return($"Team {teamName} successfully created!"); }
public string Execute(string[] args) { Check.CheckLenght(1, args); var teamName = args[0]; AuthenticationManager.Authorize(); if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } var currentUser = AuthenticationManager.GetCurrentUser(); if (!CommandHelper.IsInvitationExistingAndIsActive(teamName, currentUser)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InviteNotFound, teamName)); } using (var context = new TeamBuilderContext()) { var invitation = context.Invitations.FirstOrDefault(i => i.Team.Name == teamName && i.InvitedUserId == currentUser.Id); var team = context.Teams.FirstOrDefault(t => t.Name == teamName); invitation.IsActive = false; context.Invitations.Update(invitation); var userTeam = new UserTeam { Team = team, User = currentUser }; team.Memebers.Add(userTeam); context.SaveChanges(); } return(string.Format(Constants.SuccessMessages.Accept, currentUser.UserName, teamName)); }
public string Execute(string[] commandArgs) { Check.CheckLength(1, commandArgs); AuthenticationManager.Authorize(); var user = AuthenticationManager.GetCurrentUser(); var teamName = commandArgs[0]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(String.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } if (!CommandHelper.IsUserCreatorOfTeam(teamName, user)) { throw new InvalidOperationException(Constants.ErrorMessages.NotAllowed); } using (var context = new TeamBuilderContext()) { var team = context.Teams.SingleOrDefault(t => t.Name == teamName); var eventTeams = context.EventTeams.Where(et => et.Team == team); var userTeams = context.UserTeams.Where(ut => ut.Team == team); var invitations = context.Invitations.Where(i => i.Team == team); context.EventTeams.RemoveRange(eventTeams); context.UserTeams.RemoveRange(userTeams); context.Invitations.RemoveRange(invitations); context.Teams.Remove(team); context.SaveChanges(); } return($"{teamName} has disbanded!"); }
public string Execute(string[] inputArgs) { // TODO: Check input lenght. Check.CheckLenght(1, inputArgs); // TODO: Authorize for logged in users. AuthenticationManager.Authorize(); string teamName = inputArgs[0]; if (!CommandHelper.IsTeamExists(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } if (!CommandHelper.IsInviteExisting(teamName, AuthenticationManager.GetCurrentUser())) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InviteNotFound, teamName)); } this.DeclineInvite(teamName); return($"Declined invitation for team {teamName}!"); }
public string Execute(string[] inputArgs) { Check.CheckLength(2, inputArgs); AuthenticationManager.Authorize(); string eventName = inputArgs[0]; if (!CommandHelper.IsEventExisting(eventName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.EventNotFound, eventName)); } string teamName = inputArgs[1]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } if (!CommandHelper.IsUserCreatorOfEvent(eventName, AuthenticationManager.GetCurrentUser())) { throw new ArgumentException(Constants.ErrorMessages.NotAllowed); } this.AddTeamToEvent(teamName, eventName); return($"Team {teamName} added for {eventName}!"); }
public string Execute(string[] inputArgs) { //CreateTeam <name> <acronym> <description> AuthenticationManager.Authorize(); if (inputArgs.Length != 2 && inputArgs.Length != 3) { throw new ArgumentOutOfRangeException(nameof(inputArgs)); } string teamName = inputArgs[0]; if (teamName.Length > 25) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InvalidTeamName, teamName)); } if (CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamExists, teamName)); } string acronym = inputArgs[1]; if (acronym.Length != 3) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InvalidAcronym, acronym)); } string description = inputArgs.Length == 3 ? inputArgs[2] : null; TeamService.AddTeam(teamName, acronym, description); return($"Team {teamName} successfully created!"); }
public string Execute(string[] commandArgs) { Check.CheckLength(1, commandArgs); AuthenticationManager.Authorize(); string teamName = commandArgs[0]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } var currentUser = AuthenticationManager.GetCurrentUser(); if (!CommandHelper.IsInviteExisting(teamName, currentUser)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InviteNotFound, teamName)); } AcceptInvitation(teamName, currentUser); return($"User {currentUser.Username} joined team {teamName}!"); }
public string Execute(string[] inputArgs) { Check.CheckLength(1, inputArgs); AuthenticationManager.Authorize(); string teamName = inputArgs[0]; if (!CommandHelper.IsTeamExisting(teamName)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName)); } User currentUser = AuthenticationManager.GetCurrentUser(); if (!CommandHelper.IsInviteExisting(teamName, currentUser)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.InviteNotFound, teamName)); } this.DeclineInvite(currentUser, teamName); return($"Invite from {teamName} declined."); }