private Client(string apiKey, string username, string password, HttpClient httpClient, bool disposeClient, StrongGridClientOptions options) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; _options = options ?? GetDefaultOptions(); _fluentClient = new FluentClient(new Uri(SENDGRID_V3_BASE_URI), httpClient) .SetUserAgent(Client.UserAgent) .SetRequestCoordinator(new SendGridRetryStrategy()); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Order is important: DiagnosticHandler must be first. // Also, the list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls)); _fluentClient.Filters.Add(new SendGridErrorHandler()); if (!string.IsNullOrEmpty(apiKey)) { _fluentClient.SetBearerAuthentication(apiKey); } if (!string.IsNullOrEmpty(username)) { _fluentClient.SetBasicAuthentication(username, password); } AccessManagement = new AccessManagement(_fluentClient); Alerts = new Alerts(_fluentClient); ApiKeys = new ApiKeys(_fluentClient); Batches = new Batches(_fluentClient); Blocks = new Blocks(_fluentClient); Bounces = new Bounces(_fluentClient); Campaigns = new Campaigns(_fluentClient); Categories = new Categories(_fluentClient); Contacts = new Contacts(_fluentClient); CustomFields = new CustomFields(_fluentClient); Designs = new Designs(_fluentClient); EmailActivities = new EmailActivities(_fluentClient); EmailValidation = new EmailValidation(_fluentClient); GlobalSuppressions = new GlobalSuppressions(_fluentClient); InvalidEmails = new InvalidEmails(_fluentClient); IpAddresses = new IpAddresses(_fluentClient); IpPools = new IpPools(_fluentClient); Lists = new Lists(_fluentClient); Mail = new Mail(_fluentClient); Segments = new Segments(_fluentClient); SenderIdentities = new SenderIdentities(_fluentClient); Settings = new Settings(_fluentClient); SpamReports = new SpamReports(_fluentClient); Statistics = new Statistics(_fluentClient); Subusers = new Subusers(_fluentClient); Suppressions = new Suppressions(_fluentClient); Teammates = new Teammates(_fluentClient); Templates = new Templates(_fluentClient); UnsubscribeGroups = new UnsubscribeGroups(_fluentClient); User = new User(_fluentClient); WebhookSettings = new WebhookSettings(_fluentClient); WebhookStats = new WebhookStats(_fluentClient); SenderAuthentication = new SenderAuthentication(_fluentClient); }
/// <summary> /// Initializes a new instance of the <see cref="BaseClient" /> class. /// </summary> /// <param name="apiKey">Your api key.</param> /// <param name="httpClient">Allows you to inject your own HttpClient. This is useful, for example, to setup the HtppClient with a proxy.</param> /// <param name="disposeClient">Indicates if the http client should be dispose when this instance of BaseClient is disposed.</param> /// <param name="options">Options for the SendGrid client.</param> /// <param name="logger">Logger.</param> public BaseClient(string apiKey, HttpClient httpClient, bool disposeClient, StrongGridClientOptions options, ILogger logger = null) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; _options = options; _logger = logger ?? NullLogger.Instance; _fluentClient = new FluentClient(new Uri(SENDGRID_V3_BASE_URI), httpClient) .SetUserAgent($"StrongGrid/{Version} (+https://github.com/Jericho/StrongGrid)") .SetRequestCoordinator(new SendGridRetryStrategy()); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Remove all the built-in formatters and replace them with our custom JSON formatter _fluentClient.Formatters.Clear(); _fluentClient.Formatters.Add(new JsonFormatter()); // Order is important: DiagnosticHandler must be first. // Also, the list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls, _logger)); _fluentClient.Filters.Add(new SendGridErrorHandler()); if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentNullException(apiKey); } _fluentClient.SetBearerAuthentication(apiKey); AccessManagement = new AccessManagement(FluentClient); Alerts = new Alerts(FluentClient); ApiKeys = new ApiKeys(FluentClient); Batches = new Batches(FluentClient); Blocks = new Blocks(FluentClient); Bounces = new Bounces(FluentClient); Designs = new Designs(FluentClient); EmailActivities = new EmailActivities(FluentClient); EmailValidation = new EmailValidation(FluentClient); GlobalSuppressions = new GlobalSuppressions(FluentClient); InvalidEmails = new InvalidEmails(FluentClient); IpAddresses = new IpAddresses(FluentClient); IpPools = new IpPools(FluentClient); Mail = new Mail(FluentClient); Settings = new Settings(FluentClient); SpamReports = new SpamReports(FluentClient); Statistics = new Statistics(FluentClient); Subusers = new Subusers(FluentClient); Suppressions = new Suppressions(FluentClient); Teammates = new Teammates(FluentClient); Templates = new Templates(FluentClient); UnsubscribeGroups = new UnsubscribeGroups(FluentClient); User = new User(FluentClient); WebhookSettings = new WebhookSettings(FluentClient); WebhookStats = new WebhookStats(FluentClient); SenderAuthentication = new SenderAuthentication(FluentClient); }
public POI(string id, Types type, Designs design, Shapes shape, List <Vector> shapeCords, bool active = true, bool inverted = false, string poiTypeSpecification = "") { Id = id; Type = type; Design = design; Shape = shape; ShapeCords = shapeCords; Inverted = inverted; TypeSpecification = poiTypeSpecification; Active = active; }
public void SetupDatabase() { RoomDesignOptions.EnsureCreated = true; RoomDesignOptions.Options = new DbContextOptionsBuilder() .UseSqlite(CreateInMemoryDatabase()) .EnableSensitiveDataLogging() .Options; Rooms?.ForEach(m => RoomService.Instance.Add(m)); Products?.ForEach(m => ProductService.Instance.Add(m)); Designs?.ForEach(m => DesignService.Instance.Add(m)); ProductPlacements?.ForEach(m => ProductPlacementService.Instance.Add(m)); //Just calls context save changes RoomService.Instance.SaveChanges(); }
public POI(string id, Types type, Designs design, Shapes shape, List <Vector> shapeCords, bool active = true, bool inverted = false, string poiTypeSpecification = "") { Id = id; Type = type; Design = design; Shape = shape; if (shapeCords.Count == 2) { shapeCords.Add(new Vector(shapeCords[0].X, shapeCords[1].Y)); shapeCords.Add(new Vector(shapeCords[1].X, shapeCords[0].Y)); } ShapeCords = shapeCords; Inverted = inverted; TypeSpecification = poiTypeSpecification; Active = active; }
public async Task DeleteAsync() { // Arrange var designId = "xxxxxxxx"; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Delete, Utils.GetSendGridApiUri(ENDPOINT, designId)).Respond(HttpStatusCode.OK); var client = Utils.GetFluentClient(mockHttp); var designs = new Designs(client); // Act await designs.DeleteAsync(designId, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); }
public async Task GetPrebuiltAsync() { // Arrange var designId = "xxxxxxxx"; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT, "pre-builts", designId)).Respond("application/json", SINGLE_DESIGN_JSON); var client = Utils.GetFluentClient(mockHttp); var designs = new Designs(client); // Act var result = await designs.GetPrebuiltAsync(designId, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); result.ShouldNotBeNull(); }
public async Task CreateAsync() { // Arrange var name = "My new design"; var htmlContent = "<html><body>Testing 123...</body></html>"; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Post, Utils.GetSendGridApiUri(ENDPOINT)).Respond("application/json", SINGLE_DESIGN_JSON); var client = Utils.GetFluentClient(mockHttp); var designs = new Designs(client); // Act var result = await designs.CreateAsync(name, htmlContent, cancellationToken : CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); result.ShouldNotBeNull(); }
public async Task UpdateAsync() { // Arrange var designId = "xxxxxxxx"; var name = "Updated design name"; var htmlContent = "<html><body>Updated content</body></html>";; var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(new HttpMethod("PATCH"), Utils.GetSendGridApiUri(ENDPOINT, designId)).Respond("application/json", SINGLE_DESIGN_JSON); var client = Utils.GetFluentClient(mockHttp); var designs = new Designs(client); // Act var result = await designs.UpdateAsync(designId, name, htmlContent, cancellationToken : CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); result.ShouldNotBeNull(); }
public async Task GetAllPrebuiltAsync() { // Arrange var mockHttp = new MockHttpMessageHandler(); mockHttp.Expect(HttpMethod.Get, Utils.GetSendGridApiUri(ENDPOINT, "pre-builts")).Respond("application/json", MULTIPLE_DESIGNS_JSON); var client = Utils.GetFluentClient(mockHttp); var designs = new Designs(client); // Act var result = await designs.GetAllPrebuiltAsync(100, null, CancellationToken.None).ConfigureAwait(false); // Assert mockHttp.VerifyNoOutstandingExpectation(); mockHttp.VerifyNoOutstandingRequest(); result.ShouldNotBeNull(); result.Records.ShouldNotBeNull(); result.Records.Length.ShouldBe(2); result.PreviousPageToken.ShouldBe("prev_token"); result.CurrentPageToken.ShouldBe("self_token"); result.NextPageToken.ShouldBe("next_token"); result.TotalRecords.ShouldBe(5); }
static void Main(string[] args) { // instanciação da lista e das classes List <Turma> lstTurmas = new List <Turma>(); Turma turma = new Turma(); Designs d = new Designs(); d.MudarBack(); #region "HORA" DateTime tempo = DateTime.Now; tempo.ToString(); Console.WriteLine(""); d.MudarCores2(); if (tempo.Hour >= 6 && tempo.Hour <= 12) { d.WriteLineCenter($" BOM DIA E SEJA BEM VINDO(A) AO SISTEMA, DIA: {DateTime.Now } "); } else if (tempo.Hour > 12 && tempo.Hour < 18) { d.WriteLineCenter($" BOA TARDE E SEJA BEM VINDO(A) AO SISTEMA DIA: {DateTime.Now} "); } else { d.WriteLineCenter($" BOA NOITE E SEJA BEM VINDO(A) AO SISTEMA DIA: {DateTime.Now} "); } Console.WriteLine("------------------------------------------------------------------------------------------------------------------------"); #endregion #region "Lógica" int decisao = 0, i = 0, N = 0; d.MudarCores(); d.WriteLineCenter(" QUANTAS TURMAS DESEJA CADASTRAR? "); Console.WriteLine(""); d.MudarCores1(); //colhendo dados do usuario sobre as turmas while (N <= 0 || N > 5) { try { Console.WriteLine("DIGITE UM NUMERO INTEIRO ENTRE 1 e 5"); N = int.Parse(Console.ReadLine()); Console.WriteLine(""); } catch (Exception) { Console.WriteLine(""); Console.WriteLine(" XXX DIGITE APENAS NUMEROS INTEIROS XXX "); Console.WriteLine(""); } } for (i = 0; i < N; i++) { d.WriteLineCenter(" QUAL TURMA DESEJA CADASTAR ? A,B,C,D OU E ? "); string c = Console.ReadLine().ToUpper(); Console.WriteLine(""); while (c != "A" && c != "B" && c != "C" && c != "D" && c != "E") { Console.WriteLine("OPCAO INVÁLIDA, FAVOR DIGITAR NOVAMENTE!"); c = Console.ReadLine().ToUpper(); } Turma turma1 = new Turma(); if (lstTurmas.Where(t => t.CodTurma == c).ToList().Count == 0) { turma1.CadastrarTurma(c); Console.WriteLine($"TURMA {c} CADASTRADA"); lstTurmas.Add(turma1); } else { Console.WriteLine("TURMA JA CADASTRADA, FAVOR ADICIONAR OUTRA"); i--; } if (lstTurmas.Count > 5) { Console.WriteLine("TURMA JA REGISTADA"); } } // menu de opçoes do sistema inicio: while (decisao != 7) { Console.WriteLine(""); d.MudarCores2(); Console.WriteLine("------------------------------------------------------------------------------------------------------------------------"); Console.WriteLine("------------------------------------------------------------------------------------------------------------------------\n"); d.WriteLineCenter(" DIGITE 1 PARA ALUNO / DIGITE 2 PARA PROFESSOR / 3 PARA CADASDASTRAR TURMA / 4 PARA EXIBIR PROFESSORES \n"); d.WriteLineCenter(" DIGITE 5 PARA EXIBIR ALUNOS / DIGITE 6 PARA EXIBIR TURMAS / 7 PARA SAIR "); d.WriteLineCenter("------------------------------------------------------------------------------------------------------------------------"); d.WriteLineCenter("------------------------------------------------------------------------------------------------------------------------"); Console.WriteLine(""); { do { try { Console.WriteLine("DIGITE UM NUMERO INTEIRO ENTRE 1 e 7"); decisao = int.Parse(Console.ReadLine()); } catch (System.FormatException) { Console.WriteLine("DIGITE UMA OPÇÃO VALIDA DO MENU"); } } while (decisao <= 0 || decisao > 7); if (decisao == 1) { d.MudarCores(); Console.WriteLine("QUANTOS ALUNOS DESEJA CADASTRAR?"); Console.WriteLine(""); d.MudarCores1(); try { N = int.Parse(Console.ReadLine()); } catch (Exception) { Console.WriteLine("ERRO, SERÁ FEITO O CADASTRO DE APENAS UM ALUNO"); } for (i = 0; i < N; i++) { try { Aluno aluno = new Aluno(); aluno.Cadastrar(lstTurmas); turma.AddAlunos(aluno); } catch (Exception) { Console.Clear(); Console.WriteLine("Erro, insira informações validas!"); i--; } } } else if (decisao == 2) { d.MudarCores(); Console.WriteLine("QUANTOS PROFESSORES DESEJA CADASTRAR? "); Console.WriteLine(""); d.MudarCores1(); try { N = int.Parse(Console.ReadLine()); } catch (Exception) { Console.WriteLine("ERRO, SERÁ FEITO O CADASTRO DE APENAS UM PROFESSOR"); } for (i = 0; i < N; i++) { try { Professor professor = new Professor(); professor.Cadastrar(lstTurmas); turma.AddProfessores(professor); } catch (Exception) { Console.Clear(); Console.WriteLine("Erro, insira informações validas!"); i--; } } } else if (decisao == 3) { d.MudarCores(); Console.WriteLine("QUANTAS TURMAS DESEJA CADASTRAR? "); Console.WriteLine(""); d.MudarCores1(); try { N = int.Parse(Console.ReadLine()); } catch (Exception) { Console.WriteLine("ERRO, SERÁ FEITO O CADASTRO DE APENAS UMA TURMA"); } while (N != 1 && N != 2 && N != 3 && N != 4 && N != 5) { Console.WriteLine("OPCAO INVÁLIDA, FAVOR DIGITAR NOVAMENTE!"); N = int.Parse(Console.ReadLine()); } for (i = 0; i < N; i++) { Console.WriteLine("QUAL TURMA DESEJA CADASTAR ? A,B,C,D OU E ?"); string c = Console.ReadLine().ToUpper(); while (c != "A" && c != "B" && c != "C" && c != "D" && c != "E") { Console.WriteLine("OPCAO INVÁLIDA, FAVOR DIGITAR NOVAMENTE!"); c = Console.ReadLine().ToUpper(); } Turma turma1 = new Turma(); if (lstTurmas.Where(t => t.CodTurma == c).ToList().Count == 0) { turma1.CadastrarTurma(c); Console.WriteLine($"TURMA {c} CADASTRADA"); lstTurmas.Add(turma1); } else if (lstTurmas.Count >= 5) { Console.WriteLine("TODAS TURMAS JA FORAM REGISTRADAS,CONSULTE A DIRETORIA PARA ABERTURA DE NVOAS TURMAS !"); Console.WriteLine("DIGITE ENTER PARA VOLTAR AO INICIO"); Console.ReadLine(); Console.Clear(); goto inicio; } else { Console.WriteLine("TURMA JA CADASTRADA, FAVOR ADICIONAR OUTRA"); Console.WriteLine(""); i--; } } } else if (decisao == 4) { turma.MostrarProfessores(); } else if (decisao == 5) { turma.MostrarAlunos(); } else if (decisao == 6) { // para exibir as turmas turma.MostrarTurmas(lstTurmas); } else if (decisao == 7) { Console.WriteLine("ATÉ MAIS!,PRESSIONE ENTER PARA FECHAR O PROGRAMA"); Console.ReadLine(); Environment.Exit(0); } // convertendo e escrevendo o json StreamWriter sw2 = new StreamWriter(@"C:\Users\Treinamento 4\Desktop\Armazenamento\armazenagem"); string g2 = JsonConvert.SerializeObject(lstTurmas); sw2.WriteLine(g2); sw2.Close(); } } #endregion }
public Product(DWProduct product, string color, ICore _core, List <SiteError> errors) : this() { AdditionalInfo = product.CustomerService; CareInstructions = product.CareInstructions; Description = product.ShortDescription; Name = product.Name; Brand = product.Brand; Category = product.PrimaryCategoryId ?? ""; ProductId = product.Id; ProductFlags = LookupCallouts(product.ProductFlags); Promotions = product.Promotions.Where(a => !string.IsNullOrEmpty(a.Callout)).ToList(); IsInStore = product.IsInStore == null || product.IsInStore == true; if (!string.IsNullOrEmpty(product.PrimaryCategoryId)) { BreadCrumb = RecommendedProducts.Load(product.Id, _core).Breadcrumb; } var price = new Price(product.Price.ToString(CultureInfo.InvariantCulture)); if (product.Price == 0 && product.Variants != null) { price = new Price(product.Variants[0].Price.ToString()); } if (product.MaxPrice > 0) { var maxPrice = new Price(product.MaxPrice.ToString()); price.Label = maxPrice.Formatted; } Pricing.Add(price); Image = new Image { Title = product.Brand }; if (!string.IsNullOrEmpty(product.DisplayBrand)) { var cms = new PaylessMadCms(_core); var brandImages = cms.BrandImageLookup(); if (brandImages.ContainsKey(product.DisplayBrand)) { var brandImage = brandImages[product.DisplayBrand]; Image.Src = string.Format(Config.Urls.BrandImageTemplate, brandImage); } } var variants = product.Variants; if (variants != null) { VariantIdsSegments = variants.Select((x, i) => new { x, i }) .GroupBy(x => x.i / 50) .Select(x => string.Join(",", x.Select(y => y.x.ProductId))) .ToList(); AvailableVariations = product.VariationAttributes; var isGiftCard = product.Brand != null && product.Brand == "GIFT CARD"; if (AvailableVariations != null) { var sizeVariations = AvailableVariations.Find(x => x.Id == "size" && x.Values.Any()); var isOneSizeOnly = (sizeVariations != null && sizeVariations.Values.Count.Equals(1) && sizeVariations.Values.First().Name == "One Size") || (sizeVariations == null); if (product.ImageGroups != null) { var imageGroups = product.ImageGroups; var swatchImages = DwSwatchImages(imageGroups); var colorVariations = DWColorVariationAttribute(); SetSelectedColorValue(color, colorVariations, swatchImages, imageGroups, variants, isOneSizeOnly, isGiftCard); var designVariations = DwDesignVariationAttribute(); if (designVariations != null) { DWGetDesignValues(designVariations, imageGroups, variants); if (Designs.Any()) { var firstOrDefault = Designs.FirstOrDefault(); if (firstOrDefault != null) { firstOrDefault.IsSelected = true; } } } } } } DwSetProductRating(_core, product); VideoID = product.InvodoVideoExists ? ProductId : null; }
// metodo de cadastro com diversas validações override public void Cadastrar(List <Turma> lstTurmas) { Designs d = new Designs(); Random rnd = new Random(); inicio: Console.WriteLine(""); Console.WriteLine("DIGITE O NOME DO ALUNO"); Console.WriteLine(""); Nome = Console.ReadLine().ToUpper(); Console.WriteLine(""); d.MudarCores(); Console.WriteLine("DIGITE A IDADE DO ALUNO:"); Console.WriteLine(""); d.MudarCores1(); Idade = int.Parse(Console.ReadLine()); Console.WriteLine(""); while (Idade < 4 || Idade > 21) { Console.WriteLine("PARA CADASTRO DE ALUNOS EM NOSSA ESCOLA É NECESSARIO TER NO MINIMO 4 ANOS ( ENSINO FUNDAMENTAL)"); Console.WriteLine("E O MAXIMO DE 21 ANOS, 3 ANO DO ENSINO MEDIO"); Console.WriteLine(""); Idade = int.Parse(Console.ReadLine()); } do { Console.WriteLine(""); d.MudarCores(); Console.WriteLine("QUAL O SEXO DO ALUNO?\nDIGITE ( F ) PARA FEMININO E ( M ) PARA MASCULINO"); Console.WriteLine(""); d.MudarCores1(); Sexo = Console.ReadLine().ToUpper(); } while (Sexo != "F" && Sexo != "M"); do { Console.WriteLine(""); d.MudarCores(); Console.WriteLine("DIGITE O CPF DO ALUNO, CONTENDO 11 DIGITOS SEM PONTOS (.) OU TRAÇOS (-)"); Console.WriteLine(""); d.MudarCores1(); Cpf = long.Parse(Console.ReadLine()); } while (Cpf < 10000000000 || Cpf > 99999999999); Console.WriteLine(""); d.MudarCores(); Console.WriteLine(""); d.MudarCores1(); Ra = (rnd.Next(1000, 9000)); Console.WriteLine("O RA GERADO PARA ESTE ALUNO É:" + Ra); Console.WriteLine(""); Console.WriteLine("QUAL TURMA ESTÈ ALUNO IRA PERTENCER? "); Console.WriteLine(""); var codigoTurma = Console.ReadLine().ToUpper(); if (lstTurmas.Where(t => t.CodTurma == codigoTurma).ToList().Count > 0) { lstTurmas.Where(t => t.CodTurma == codigoTurma).FirstOrDefault().AddAlunos(this); Console.WriteLine(""); Console.WriteLine($"CADASTRO DO ALUNO {Nome} RA: {Ra} FOI REALIZADO "); } else { d.MudarCores(); Console.WriteLine("ESSA TURMA NAO EXISTE, QUAL TURMA DESEJA CADASTAR ? A,B,C,D OU E ?"); string c = Console.ReadLine().ToUpper(); Turma turma1 = new Turma(); if (lstTurmas.Where(t => t.CodTurma == c).ToList().Count == 0) { while (c != "A" && c != "B" && c != "C" && c != "D" && c != "E") { Console.WriteLine("OPCAO INVÁLIDA, FAVOR DIGITAR NOVAMENTE!"); c = Console.ReadLine().ToUpper(); } turma1.CadastrarTurma(c); Console.WriteLine($"TURMA {c} CADASTRADA"); if (lstTurmas.Contains(turma1)) { Console.WriteLine("NAO É POSSIVEL ADICONAR TURMA, POIS ELA JÁ EXISTE!"); } else { Console.WriteLine("Turma Adicionada"); lstTurmas.Add(turma1); } } else { Console.WriteLine("TURMA JA CADASTRADA, NÂO É POSSIVEL CRIAR ELA NOVAMENTE"); Console.WriteLine(""); } Console.WriteLine("POR GENTILEZA EFETUAR O CADASTRO DO ALUNO NOVAMENTE !"); Console.WriteLine(""); goto inicio; } }
public List <Design> GetDesigns() { return(Designs.ToList()); }
public Design GetDesignByID(int ID) { return(Designs.SingleOrDefault(c => c.ID == ID)); }
// metodo de cadastro com diversas validações #region "CADASTRO INFORMAÇÔES PROFESSORES" override public void Cadastrar(List <Turma> lstTurmas) { Random rnd = new Random(); Designs d = new Designs(); inicio: Console.WriteLine(""); d.MudarCores(); Console.WriteLine("DIGITE O NOME DO PROFESSOR"); Console.WriteLine(""); d.MudarCores1(); Nome = Console.ReadLine(); Console.WriteLine(""); d.MudarCores(); Console.WriteLine("DIGITE A IDADE DO PROFESSOR:"); Console.WriteLine(""); d.MudarCores1(); Idade = int.Parse(Console.ReadLine()); Console.WriteLine(""); while (Idade < 18 || Idade >= 100) { Console.WriteLine("PARA CADASTRO DE PROFESSORES É NECESSARIO SER MAIOR DE IDADE"); Idade = int.Parse(Console.ReadLine()); } do { Console.WriteLine(""); d.MudarCores(); Console.WriteLine("QUAL O SEXO DO PROFESSOR?\n DIGITE ( F ) PARA FEMININO E ( M ) PARA MASCULINO"); Console.WriteLine(""); d.MudarCores1(); Sexo = Console.ReadLine().ToUpper(); } while (Sexo != "F" && Sexo != "M"); do { Console.WriteLine(""); d.MudarCores(); Console.WriteLine("DIGITE O CPF DO PROFESSOR:"); Console.WriteLine(""); d.MudarCores1(); Cpf = long.Parse(Console.ReadLine()); Console.WriteLine(""); } while (Cpf < 10000000000 || Cpf > 99999999999); Console.WriteLine("AGORA DIGITE O SALARIO DO PROFESSOR "); Salario = Convert.ToDouble(Console.ReadLine()); Console.WriteLine(""); d.MudarCores(); Console.WriteLine(""); d.MudarCores1(); Identificacao = (rnd.Next(10000, 90000)); Console.WriteLine("O NUMERO DE IDENTIFICAÇÂO PARA ESTE PROFESSOR É:" + Identificacao); Console.WriteLine(""); d.MudarCores(); Console.WriteLine("CADASTRE AS MATERIAS QUE O PROFESSOR DA AULA: "); Console.WriteLine(""); Console.WriteLine("QUANTAS MATERIAS DESEJA CADASTRAR PARA ESTE PROFESSOR?"); Console.WriteLine(""); d.MudarCores1(); int num = int.Parse(Console.ReadLine()); while (num > 5) { Console.WriteLine("O PROFESSOR PODE DAR AULA APENAS EM 5 MATERIAS DIFERENTES"); num = int.Parse(Console.ReadLine()); } for (i = 0; i < num; i++) { Materias m = new Materias(); Console.WriteLine(""); d.MudarCores(); Console.WriteLine($"DIGITE 1 PARA MATEMATICA\nDIGITE 2 PARA PORTUGUES\nDIGITE 3 PARA BIOLOGIA\nDIGITE 4 PARA GEOGRAFIA\nDIGITE 5 PARA INGLES"); Console.WriteLine(""); d.MudarCores1(); int decisao = int.Parse(Console.ReadLine()); while (decisao < 0 || decisao > 5) { Console.WriteLine("OPCAO INVÁLIDA, DIGITE NOVAMENTE!"); decisao = int.Parse(Console.ReadLine()); } switch (decisao) { case 1: Console.WriteLine(""); d.MudarCores(); if (LstMaterias.Where(t => t.CodMateria == decisao).ToList().Count == 0) { Console.WriteLine("MATERIA MATEMATICA ADICIONADA!"); m.DefinirMateria(decisao); LstMaterias.Add(m); } else { Console.WriteLine("MATERIAS REPETIDAS, FAVOR ADICIONAR OUTRA "); i--; } Console.WriteLine(""); break; case 2: Console.WriteLine(""); d.MudarCores(); if (LstMaterias.Where(t => t.CodMateria == decisao).ToList().Count == 0) { Console.WriteLine("MATERIA PORTUGUES ADICIONADA!"); m.DefinirMateria(decisao); LstMaterias.Add(m); } else { Console.WriteLine("MATERIAS REPETIDAS, FAVOR ADICIONAR OUTRA "); i--; } Console.WriteLine(""); break; case 3: Console.WriteLine(""); d.MudarCores(); if (LstMaterias.Where(t => t.CodMateria == decisao).ToList().Count == 0) { Console.WriteLine("MATERIA BIOLOGIA ADICIONADA!"); m.DefinirMateria(decisao); LstMaterias.Add(m); } else { Console.WriteLine("MATERIAS REPETIDAS, FAVOR ADICIONAR OUTRA "); i--; } Console.WriteLine(""); break; case 4: Console.WriteLine(""); d.MudarCores(); if (LstMaterias.Where(t => t.CodMateria == decisao).ToList().Count == 0) { Console.WriteLine("MATERIA GEOGRAFIA ADICIONADA!"); m.DefinirMateria(decisao); LstMaterias.Add(m); } else { Console.WriteLine("MATERIAS REPETIDAS, FAVOR ADICIONAR OUTRA "); i--; } Console.WriteLine(""); break; case 5: Console.WriteLine(""); d.MudarCores(); if (LstMaterias.Where(t => t.CodMateria == decisao).ToList().Count == 0) { Console.WriteLine("MATERIA INGLES ADICIONADA!"); m.DefinirMateria(decisao); LstMaterias.Add(m); } else { Console.WriteLine("MATERIAS REPETIDAS, FAVOR ADICIONAR OUTRA "); i--; } Console.WriteLine(""); break; default: break; } } Console.Clear(); Console.WriteLine(""); d.MudarCores(); Console.WriteLine("ESSE PROFESSOR DA AULA PARA QUANTAS TURMAS?"); int turm = Convert.ToInt32(Console.ReadLine()); if (turm > 5) { turm = 5; } Console.WriteLine(""); d.MudarCores1(); for (int i = 0; i < turm; i++) { Console.WriteLine("PARA QUAL TURMA ESTE PROFESSOR DARÁ AULA ?"); Console.WriteLine(""); var codigoTurma = Console.ReadLine().ToUpper(); while (codigoTurma != "A" && codigoTurma != "B" && codigoTurma != "C" && codigoTurma != "D" && codigoTurma != "E") { Console.WriteLine("OPCAO INVÁLIDA, FAVOR DIGITAR NOVAMENTE!"); codigoTurma = Console.ReadLine().ToUpper(); } if (lstTurmas.Where(t => t.CodTurma == codigoTurma).ToList().Count > 0) { lstTurmas.Where(t => t.CodTurma == codigoTurma).FirstOrDefault().AddProfessores(this); Console.WriteLine($"CADASTRO DO PROFESSOR {Nome} ID: {Identificacao} NESSA TURMA REALIZADO "); } else { d.MudarCores(); Console.WriteLine("ESSA TURMA NAO EXISTE, QUAL TURMA DESEJA CADASTRAR? A,B,C,D OU E ?"); string c = Console.ReadLine().ToUpper(); Console.WriteLine(""); Turma turma1 = new Turma(); if (lstTurmas.Where(t => t.CodTurma == c).ToList().Count == 0) { while (c != "A" && c != "B" && c != "C" && c != "D" && c != "E") { Console.WriteLine("OPCAO INVÁLIDA, FAVOR DIGITAR NOVAMENTE!"); c = Console.ReadLine().ToUpper(); } turma1.CadastrarTurma(c); Console.WriteLine($"TURMA {c} CADASTRADA"); if (lstTurmas.Contains(turma1)) { Console.WriteLine("NAO É POSSIVEL ADICONAR TURMA, POIS ELA JÁ EXISTE!"); } else { Console.WriteLine("Turma Adicionada"); lstTurmas.Add(turma1); } } else { Console.WriteLine("TURMA JA CADASTRADA, FAVOR ADICIONAR OUTRA"); Console.WriteLine(""); i--; } Console.WriteLine("TURMA CRIADA, APERTE ENTER EFETUAR O CADASTRO DO PROFESSOR NOVAMENTE !"); Console.WriteLine(""); Console.ReadLine(); goto inicio; } #endregion } }
/// <summary> /// Initializes a new instance of the <see cref="BaseClient" /> class. /// </summary> /// <param name="apiKey">Your api key.</param> /// <param name="username">Your username. Ignored if the api key is specified.</param> /// <param name="password">Your password. Ignored if the api key is specified.</param> /// <param name="httpClient">Allows you to inject your own HttpClient. This is useful, for example, to setup the HtppClient with a proxy.</param> /// <param name="disposeClient">Indicates if the http client should be dispose when this instance of BaseClient is disposed.</param> /// <param name="options">Options for the SendGrid client.</param> /// <param name="logger">Logger.</param> public BaseClient(Parameter <string> apiKey, Parameter <string> username, Parameter <string> password, HttpClient httpClient, bool disposeClient, StrongGridClientOptions options, ILogger logger = null) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; _options = options ?? GetDefaultOptions(); _logger = logger ?? NullLogger.Instance; _fluentClient = new FluentClient(new Uri(SENDGRID_V3_BASE_URI), httpClient) .SetUserAgent($"StrongGrid/{Version} (+https://github.com/Jericho/StrongGrid)") .SetRequestCoordinator(new SendGridRetryStrategy()); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Order is important: DiagnosticHandler must be first. // Also, the list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls, _logger)); _fluentClient.Filters.Add(new SendGridErrorHandler()); if (apiKey.HasValue) { if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentNullException(apiKey); } else { _fluentClient.SetBearerAuthentication(apiKey); } } else if (username.HasValue) { if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException(username); } else { _fluentClient.SetBasicAuthentication(username, password); } } else { throw new ArgumentException("You must provide either an API key or a username and a password."); } AccessManagement = new AccessManagement(FluentClient); Alerts = new Alerts(FluentClient); ApiKeys = new ApiKeys(FluentClient); Batches = new Batches(FluentClient); Blocks = new Blocks(FluentClient); Bounces = new Bounces(FluentClient); Designs = new Designs(FluentClient); EmailActivities = new EmailActivities(FluentClient); EmailValidation = new EmailValidation(FluentClient); GlobalSuppressions = new GlobalSuppressions(FluentClient); InvalidEmails = new InvalidEmails(FluentClient); IpAddresses = new IpAddresses(FluentClient); IpPools = new IpPools(FluentClient); Mail = new Mail(FluentClient); Settings = new Settings(FluentClient); SpamReports = new SpamReports(FluentClient); Statistics = new Statistics(FluentClient); Subusers = new Subusers(FluentClient); Suppressions = new Suppressions(FluentClient); Teammates = new Teammates(FluentClient); Templates = new Templates(FluentClient); UnsubscribeGroups = new UnsubscribeGroups(FluentClient); User = new User(FluentClient); WebhookSettings = new WebhookSettings(FluentClient); WebhookStats = new WebhookStats(FluentClient); SenderAuthentication = new SenderAuthentication(FluentClient); }