https://github.com/phjb/proagil
Curso Seja Full-Stack com Asp.NET Core Web API, Angular e EF Core
https://github.com/phjb/proagil
angular9 asp-net-core asp-net-core-mvc csharp vscode
Last synced: about 1 year ago
JSON representation
Curso Seja Full-Stack com Asp.NET Core Web API, Angular e EF Core
- Host: GitHub
- URL: https://github.com/phjb/proagil
- Owner: phjb
- Created: 2020-05-05T16:38:11.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-11T06:42:26.000Z (over 2 years ago)
- Last Synced: 2025-02-05T06:14:34.379Z (over 1 year ago)
- Topics: angular9, asp-net-core, asp-net-core-mvc, csharp, vscode
- Language: C#
- Homepage: https://www.udemy.com/course/angular-dotnetcore-efcore/
- Size: 2.93 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ProAgil
###
## Requests HTTP no Angular
Em **_app.modules.ts_** importe o **HttpClientModule**
`import { HttpClientModule } from '@angular/common/http';`
O arquivo **_eventos.component.ts_** ficará da seguinte forma:
```ts
export class EventosComponent implements OnInit {
eventos: any = [];
url = 'http://localhost:5000/api/eventos/';
constructor(private http: HttpClient) { }
ngOnInit(): void {
this.getEventos();
}
getEventos(): void {
this.http.get(this.url).subscribe(
response => {
this.eventos = response;
},
error => {
console.log(error);
});
}
```
É esperado o erro abaixo:

Para ajustar entre no arquivo **Setup.cs** que está na pasta **ProAgil.API** e use o _Cors_
```c#
public void ConfigureServices (IServiceCollection services)
{
services.AddDbContext (x => x.UseSqlite (Configuration.GetConnectionString ("DefaultConnection")));
services.AddCors ();
services.AddControllers ();
}
public void Configure (IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment ())
{
app.UseDeveloperExceptionPage ();
}
app.UseCors (x =>
x.AllowAnyOrigin () // permito toda origem
.AllowAnyMethod () // permito todos os metodos
.AllowAnyHeader () // permito todos cabeçalho
);
app.UseRouting ();
app.UseAuthorization ();
app.UseEndpoints (endpoints =>
{
endpoints.MapControllers ();
});
}
```
## Entidades

## AutoMapper

#
