public async Task <ActionResult <GenericResponse> > PausePost(string botNames, [FromBody] BotPauseRequest request) { if (string.IsNullOrEmpty(botNames)) { throw new ArgumentNullException(nameof(botNames)); } if (request == null) { throw new ArgumentNullException(nameof(request)); } HashSet <Bot>?bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { return(BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)))); } IList <(bool Success, string Message)> results = await Utilities.InParallel(bots.Select(bot => bot.Actions.Pause(request.Permanent, request.ResumeInSeconds))).ConfigureAwait(false); return(Ok(new GenericResponse(results.All(result => result.Success), string.Join(Environment.NewLine, results.Select(result => result.Message))))); }
public async Task <ActionResult <GenericResponse> > PausePost(string botNames, [FromBody] BotPauseRequest request) { if (string.IsNullOrEmpty(botNames) || (request == null)) { ASF.ArchiLogger.LogNullError(nameof(botNames) + " || " + nameof(request)); return(BadRequest(new GenericResponse(false, string.Format(Strings.ErrorIsEmpty, nameof(botNames) + " || " + nameof(request))))); } HashSet <Bot> bots = Bot.GetBots(botNames); if ((bots == null) || (bots.Count == 0)) { return(BadRequest(new GenericResponse(false, string.Format(Strings.BotNotFound, botNames)))); } IList <(bool Success, string Output)> results = await Utilities.InParallel(bots.Select(bot => bot.Actions.Pause(request.Permanent, request.ResumeInSeconds))).ConfigureAwait(false); return(Ok(new GenericResponse(results.All(result => result.Success), string.Join(Environment.NewLine, results.Select(result => result.Output))))); }