public async Task<CommandResult> AddRangeAsync(List<Holiday> listOfHolidays, bool validateRepository = true) { CommandResult commandResult; Stopwatch watch = Stopwatch.StartNew(); try { int recordsToSave = Count(listOfHolidays); if (recordsToSave == 0) { commandResult = CommandResult.BadRequest("Nenhum registro salvo, a lista está vazia."); } else { if (!await CanAddAsync(listOfHolidays, validateRepository)) { commandResult = CommandResult.BadRequest("Nenhum registro salvo, existem erros."); } else { await HolidayRepository.AddRangeAsync(listOfHolidays); commandResult = await CommitAsync(_commandName, ActionType.Register); if (commandResult.Success) { commandResult.Message = $"Ação concluída com sucesso. Salvos { recordsToSave } registros de um total de { recordsToSave }"; commandResult.Data = listOfHolidays; } } } } catch (Exception ex) { commandResult = CommandResult.InternalServerError($"Ocorreu um erro ao salvar."); } watch.Stop(); commandResult.ElapsedTime = watch.ElapsedMilliseconds; return commandResult; }