├── SmartSchool
├── src
│ ├── assets
│ │ └── .gitkeep
│ ├── app
│ │ ├── app.component.css
│ │ ├── components
│ │ │ ├── alunos
│ │ │ │ ├── alunos.component.css
│ │ │ │ ├── professores-alunos
│ │ │ │ │ ├── professores-alunos.component.css
│ │ │ │ │ ├── professores-alunos.component.html
│ │ │ │ │ ├── professores-alunos.component.spec.ts
│ │ │ │ │ └── professores-alunos.component.ts
│ │ │ │ ├── alunos.component.spec.ts
│ │ │ │ ├── alunos.component.html
│ │ │ │ └── alunos.component.ts
│ │ │ ├── perfil
│ │ │ │ ├── perfil.component.css
│ │ │ │ ├── perfil.component.html
│ │ │ │ ├── perfil.component.ts
│ │ │ │ └── perfil.component.spec.ts
│ │ │ ├── shared
│ │ │ │ ├── nav
│ │ │ │ │ ├── nav.component.css
│ │ │ │ │ ├── nav.component.ts
│ │ │ │ │ ├── nav.component.spec.ts
│ │ │ │ │ └── nav.component.html
│ │ │ │ └── titulo
│ │ │ │ │ ├── titulo.component.css
│ │ │ │ │ ├── titulo.component.html
│ │ │ │ │ ├── titulo.component.ts
│ │ │ │ │ └── titulo.component.spec.ts
│ │ │ ├── dashboard
│ │ │ │ ├── dashboard.component.css
│ │ │ │ ├── dashboard.component.html
│ │ │ │ ├── dashboard.component.ts
│ │ │ │ └── dashboard.component.spec.ts
│ │ │ └── professores
│ │ │ │ ├── professores.component.css
│ │ │ │ ├── professor-detalhe
│ │ │ │ ├── professor-detalhe.component.css
│ │ │ │ ├── professor-detalhe.component.spec.ts
│ │ │ │ ├── professor-detalhe.component.html
│ │ │ │ └── professor-detalhe.component.ts
│ │ │ │ ├── alunos-professores
│ │ │ │ ├── alunos-professores.component.css
│ │ │ │ ├── alunos-professores.component.html
│ │ │ │ ├── alunos-professores.component.ts
│ │ │ │ └── alunos-professores.component.spec.ts
│ │ │ │ ├── professores.component.html
│ │ │ │ ├── professores.component.spec.ts
│ │ │ │ └── professores.component.ts
│ │ ├── models
│ │ │ ├── Disciplina.ts
│ │ │ ├── Aluno.ts
│ │ │ └── Professor.ts
│ │ ├── util
│ │ │ └── util.ts
│ │ ├── app.component.ts
│ │ ├── app.component.html
│ │ ├── services
│ │ │ ├── aluno.service.spec.ts
│ │ │ ├── professor.service.spec.ts
│ │ │ ├── aluno.service.ts
│ │ │ └── professor.service.ts
│ │ ├── app-routing.module.ts
│ │ ├── app.component.spec.ts
│ │ └── app.module.ts
│ ├── favicon.ico
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── styles.css
│ ├── index.html
│ ├── main.ts
│ ├── test.ts
│ └── polyfills.ts
├── e2e
│ ├── tsconfig.json
│ ├── src
│ │ ├── app.po.ts
│ │ └── app.e2e-spec.ts
│ └── protractor.conf.js
├── .editorconfig
├── tsconfig.app.json
├── tsconfig.spec.json
├── browserslist
├── tsconfig.json
├── .gitignore
├── README.md
├── karma.conf.js
├── package.json
├── tslint.json
└── angular.json
├── .DS_Store
├── SmartSchool-WebAPI
├── SmartSchool.db
├── appsettings.Development.json
├── appsettings.json
├── Models
│ ├── Professor.cs
│ ├── AlunoDisciplina.cs
│ ├── Disciplina.cs
│ └── Aluno.cs
├── SmartSchool-WebAPI.csproj
├── Program.cs
├── .gitignore
├── Properties
│ └── launchSettings.json
├── Data
│ ├── IRepository.cs
│ ├── DataContext.cs
│ └── Repository.cs
├── Startup.cs
├── Controllers
│ ├── AlunoController.cs
│ └── ProfessorController.cs
└── Migrations
│ ├── DataContextModelSnapshot.cs
│ ├── 20200308234522_initial.Designer.cs
│ └── 20200308234522_initial.cs
├── README.md
└── .vscode
├── tasks.json
└── launch.json
/SmartSchool/src/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/app.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/alunos/alunos.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/perfil/perfil.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/shared/nav/nav.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/dashboard/dashboard.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/professores.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/shared/titulo/titulo.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vsandrade/Youtube-Angular-NetCoreAPI/HEAD/.DS_Store
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/alunos/professores-alunos/professores-alunos.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/professor-detalhe/professor-detalhe.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/alunos-professores/alunos-professores.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/shared/titulo/titulo.component.html:
--------------------------------------------------------------------------------
1 |
2 | {{titulo}}
3 |
4 |
--------------------------------------------------------------------------------
/SmartSchool/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vsandrade/Youtube-Angular-NetCoreAPI/HEAD/SmartSchool/src/favicon.ico
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/SmartSchool.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vsandrade/Youtube-Angular-NetCoreAPI/HEAD/SmartSchool-WebAPI/SmartSchool.db
--------------------------------------------------------------------------------
/SmartSchool/src/app/models/Disciplina.ts:
--------------------------------------------------------------------------------
1 | export class Disciplina {
2 | id: number;
3 | nome: string;
4 | professorId: number;
5 | }
6 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/perfil/perfil.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | perfil works!
4 |
5 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/dashboard/dashboard.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | dashboard works!
4 |
5 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/models/Aluno.ts:
--------------------------------------------------------------------------------
1 | export class Aluno {
2 | id: number;
3 | nome: string;
4 | sobrenome: string;
5 | telefone: number;
6 | }
7 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/util/util.ts:
--------------------------------------------------------------------------------
1 | export class Util {
2 | static nomeConcat(item: any[]) {
3 | return item.map(x => x.nome).join(',');
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/SmartSchool/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | mainUrlAPI: 'http://localhost:5000/api/'
4 | };
5 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/models/Professor.ts:
--------------------------------------------------------------------------------
1 | import { Disciplina } from './Disciplina';
2 |
3 | export class Professor {
4 | id: number;
5 | nome: string;
6 | disciplinas: Disciplina[];
7 | }
8 |
--------------------------------------------------------------------------------
/SmartSchool/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 | @import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
3 |
4 | #toast-container > div {
5 | opacity:1;
6 | }
7 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'SmartSchool';
10 | }
11 |
--------------------------------------------------------------------------------
/SmartSchool/e2e/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/SmartSchool/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see https://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Loading...
9 |
10 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings" : {
3 | "DefaultConn": "Data Source=SmartSchool.db"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft": "Warning",
9 | "Microsoft.Hosting.Lifetime": "Information"
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SmartSchool/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get(browser.baseUrl) as Promise;
6 | }
7 |
8 | getTitleText() {
9 | return element(by.css('app-root .content span')).getText() as Promise;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings" : {
3 | "DefaultConn": "Data Source=SmartSchool.db"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft": "Warning",
9 | "Microsoft.Hosting.Lifetime": "Information"
10 | }
11 | },
12 | "AllowedHosts": "*"
13 | }
14 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/shared/nav/nav.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-nav',
5 | templateUrl: './nav.component.html',
6 | styleUrls: ['./nav.component.css']
7 | })
8 | export class NavComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/SmartSchool/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SmartSchool
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/SmartSchool/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./out-tsc/app",
5 | "types": []
6 | },
7 | "files": [
8 | "src/main.ts",
9 | "src/polyfills.ts"
10 | ],
11 | "include": [
12 | "src/**/*.ts"
13 | ],
14 | "exclude": [
15 | "src/test.ts",
16 | "src/**/*.spec.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/SmartSchool/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts",
12 | "src/polyfills.ts"
13 | ],
14 | "include": [
15 | "src/**/*.spec.ts",
16 | "src/**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/perfil/perfil.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-perfil',
5 | templateUrl: './perfil.component.html',
6 | styleUrls: ['./perfil.component.css']
7 | })
8 | export class PerfilComponent implements OnInit {
9 |
10 | public titulo = 'Perfil';
11 |
12 | constructor() { }
13 |
14 | ngOnInit() {
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/shared/titulo/titulo.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-titulo',
5 | templateUrl: './titulo.component.html',
6 | styleUrls: ['./titulo.component.css']
7 | })
8 | export class TituloComponent implements OnInit {
9 |
10 | @Input() titulo: string;
11 |
12 | constructor() { }
13 |
14 | ngOnInit() {
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/SmartSchool/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.error(err));
13 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/dashboard/dashboard.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-dashboard',
5 | templateUrl: './dashboard.component.html',
6 | styleUrls: ['./dashboard.component.css']
7 | })
8 | export class DashboardComponent implements OnInit {
9 |
10 | public titulo = 'Principal';
11 |
12 | constructor() { }
13 |
14 | ngOnInit() {
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/SmartSchool/browserslist:
--------------------------------------------------------------------------------
1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 |
5 | # You can see what browsers were selected by your queries by running:
6 | # npx browserslist
7 |
8 | > 0.5%
9 | last 2 versions
10 | Firefox ESR
11 | not dead
12 | not IE 9-11 # For IE 9-11 support, remove 'not'.
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Models/Professor.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace SmartSchool_WebAPI.Models
4 | {
5 | public class Professor
6 | {
7 | public Professor() { }
8 | public Professor(int id, string nome)
9 | {
10 | this.Id = id;
11 | this.Nome = nome;
12 | }
13 | public int Id { get; set; }
14 | public string Nome { get; set; }
15 | public IEnumerable Disciplinas { get; set; }
16 | }
17 | }
--------------------------------------------------------------------------------
/SmartSchool/src/app/services/aluno.service.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 |
3 | import { TestBed, async, inject } from '@angular/core/testing';
4 | import { AlunoService } from './aluno.service';
5 |
6 | describe('Service: Aluno', () => {
7 | beforeEach(() => {
8 | TestBed.configureTestingModule({
9 | providers: [AlunoService]
10 | });
11 | });
12 |
13 | it('should ...', inject([AlunoService], (service: AlunoService) => {
14 | expect(service).toBeTruthy();
15 | }));
16 | });
17 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/services/professor.service.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 |
3 | import { TestBed, async, inject } from '@angular/core/testing';
4 | import { ProfessorService } from './professor.service';
5 |
6 | describe('Service: Professor', () => {
7 | beforeEach(() => {
8 | TestBed.configureTestingModule({
9 | providers: [ProfessorService]
10 | });
11 | });
12 |
13 | it('should ...', inject([ProfessorService], (service: ProfessorService) => {
14 | expect(service).toBeTruthy();
15 | }));
16 | });
17 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Models/AlunoDisciplina.cs:
--------------------------------------------------------------------------------
1 | namespace SmartSchool_WebAPI.Models
2 | {
3 | public class AlunoDisciplina
4 | {
5 | public AlunoDisciplina() { }
6 | public AlunoDisciplina(int alunoId, int disciplinaId)
7 | {
8 | this.AlunoId = alunoId;
9 | this.DisciplinaId = disciplinaId;
10 | }
11 | public int AlunoId { get; set; }
12 | public Aluno Aluno { get; set; }
13 | public int DisciplinaId { get; set; }
14 | public Disciplina Disciplina { get; set; }
15 | }
16 | }
--------------------------------------------------------------------------------
/SmartSchool/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "downlevelIteration": true,
9 | "experimentalDecorators": true,
10 | "module": "esnext",
11 | "moduleResolution": "node",
12 | "importHelpers": true,
13 | "target": "es2015",
14 | "typeRoots": [
15 | "node_modules/@types"
16 | ],
17 | "lib": [
18 | "es2018",
19 | "dom"
20 | ]
21 | },
22 | "angularCompilerOptions": {
23 | "fullTemplateTypeCheck": true,
24 | "strictInjectionParameters": true
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Models/Disciplina.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace SmartSchool_WebAPI.Models
4 | {
5 | public class Disciplina
6 | {
7 | public Disciplina() { }
8 | public Disciplina(int id, string nome, int professorId)
9 | {
10 | this.Id = id;
11 | this.Nome = nome;
12 | this.ProfessorId = professorId;
13 | }
14 | public int Id { get; set; }
15 | public string Nome { get; set; }
16 | public int ProfessorId { get; set; }
17 | public Professor Professor { get; set; }
18 | public IEnumerable AlunosDisciplinas { get; set; }
19 | }
20 | }
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Models/Aluno.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace SmartSchool_WebAPI.Models
4 | {
5 | public class Aluno
6 | {
7 | public Aluno() { }
8 | public Aluno(int id, string nome, string sobrenome, string telefone)
9 | {
10 | this.Id = id;
11 | this.Nome = nome;
12 | this.Sobrenome = sobrenome;
13 | this.Telefone = telefone;
14 | }
15 | public int Id { get; set; }
16 | public string Nome { get; set; }
17 | public string Sobrenome { get; set; }
18 | public string Telefone { get; set; }
19 | public IEnumerable AlunosDisciplinas { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/alunos/professores-alunos/professores-alunos.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | | Visualizar |
5 | # |
6 | Nome |
7 | Disciplina |
8 |
9 |
10 |
11 |
12 | |
13 |
14 | |
15 | {{prof.id}} |
16 | {{prof.nome}} |
17 | {{disciplinaConcat(prof.disciplinas)}} |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/SmartSchool-WebAPI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netcoreapp3.1
4 | SmartSchool_WebAPI
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/SmartSchool/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/SmartSchool/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 | import { browser, logging } from 'protractor';
3 |
4 | describe('workspace-project App', () => {
5 | let page: AppPage;
6 |
7 | beforeEach(() => {
8 | page = new AppPage();
9 | });
10 |
11 | it('should display welcome message', () => {
12 | page.navigateTo();
13 | expect(page.getTitleText()).toEqual('SmartSchool app is running!');
14 | });
15 |
16 | afterEach(async () => {
17 | // Assert that there are no errors emitted from the browser
18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19 | expect(logs).not.toContain(jasmine.objectContaining({
20 | level: logging.Level.SEVERE,
21 | } as logging.Entry));
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/alunos-professores/alunos-professores.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | | Visualizar |
5 | # |
6 | Nome |
7 | Sobrenome |
8 | telefone |
9 |
10 |
11 |
12 |
13 | |
15 | {{aluno.id}} |
16 | {{aluno.nome}} |
17 | {{aluno.sobrenome}} |
18 | {{aluno.telefone}} |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/alunos/alunos.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { AlunosComponent } from './alunos.component';
4 |
5 | describe('AlunosComponent', () => {
6 | let component: AlunosComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ AlunosComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(AlunosComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/SmartSchool/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false,
7 | mainUrlAPI: 'http://localhost:5000/api/'
8 | };
9 |
10 | /*
11 | * For easier debugging in development mode, you can import the following file
12 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
13 | *
14 | * This import should be commented out in production mode because it will have a negative impact
15 | * on performance if an error is thrown.
16 | */
17 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
18 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/professores.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | | Visualizar |
8 | # |
9 | Nome |
10 | Disciplina |
11 |
12 |
13 |
14 |
15 | |
16 | Detalhe
17 | |
18 | {{prof.id}} |
19 | {{prof.nome}} |
20 | {{disciplinaConcat(prof.disciplinas)}} |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.Extensions.Logging;
9 |
10 | namespace SmartSchool_WebAPI
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | CreateHostBuilder(args).Build().Run();
17 | }
18 |
19 | public static IHostBuilder CreateHostBuilder(string[] args) =>
20 | Host.CreateDefaultBuilder(args)
21 | .ConfigureWebHostDefaults(webBuilder =>
22 | {
23 | webBuilder.UseStartup();
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SmartSchool/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 | # Only exists if Bazel was run
8 | /bazel-out
9 |
10 | # dependencies
11 | /node_modules
12 |
13 | # profiling files
14 | chrome-profiler-events*.json
15 | speed-measure-plugin*.json
16 |
17 | # IDEs and editors
18 | /.idea
19 | .project
20 | .classpath
21 | .c9/
22 | *.launch
23 | .settings/
24 | *.sublime-workspace
25 |
26 | # IDE - VSCode
27 | .vscode/*
28 | !.vscode/settings.json
29 | !.vscode/tasks.json
30 | !.vscode/launch.json
31 | !.vscode/extensions.json
32 | .history/*
33 |
34 | # misc
35 | /.sass-cache
36 | /connect.lock
37 | /coverage
38 | /libpeerconnection.log
39 | npm-debug.log
40 | yarn-error.log
41 | testem.log
42 | /typings
43 |
44 | # System Files
45 | .DS_Store
46 | Thumbs.db
47 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/alunos-professores/alunos-professores.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 | import { Aluno } from 'src/app/models/Aluno';
3 | import { Util } from 'src/app/util/util';
4 | import { Router } from '@angular/router';
5 |
6 | @Component({
7 | selector: 'app-alunos-professores',
8 | templateUrl: './alunos-professores.component.html',
9 | styleUrls: ['./alunos-professores.component.css']
10 | })
11 | export class AlunosProfessoresComponent implements OnInit {
12 |
13 | @Input() public alunos: Aluno[];
14 | @Output() closeModal = new EventEmitter();
15 |
16 | constructor(private router: Router) { }
17 |
18 | ngOnInit() {
19 | }
20 |
21 | alunoSelect(id: number) {
22 | this.closeModal.emit(null);
23 | this.router.navigate(['/alunos', id]);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # .NET Core Project
4 | /bin
5 | /obj
6 |
7 | bin
8 | obj
9 |
10 | # compiled output
11 | /dist
12 | /tmp
13 | /out-tsc
14 |
15 | # dependencies
16 | node_modules
17 |
18 | # profiling files
19 | chrome-profiler-events.json
20 | speed-measure-plugin.json
21 |
22 | # IDEs and editors
23 | /.idea
24 | .project
25 | .classpath
26 | .c9/
27 | *.launch
28 | .settings/
29 | *.sublime-workspace
30 |
31 | # IDE - VSCode
32 | .vs
33 | .vscode
34 | .vscode/*
35 | !.vscode/settings.json
36 | !.vscode/tasks.json
37 | !.vscode/launch.json
38 | !.vscode/extensions.json
39 | .history/*
40 |
41 | # misc
42 | /.sass-cache
43 | /connect.lock
44 | /coverage
45 | /libpeerconnection.log
46 | npm-debug.log
47 | yarn-error.log
48 | testem.log
49 | /typings
50 |
51 | # System Files
52 | .DS_Store
53 | Thumbs.db
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/shared/nav/nav.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { NavComponent } from './nav.component';
7 |
8 | describe('NavComponent', () => {
9 | let component: NavComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ NavComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(NavComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/perfil/perfil.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { PerfilComponent } from './perfil.component';
7 |
8 | describe('PerfilComponent', () => {
9 | let component: PerfilComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ PerfilComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(PerfilComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/shared/titulo/titulo.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { TituloComponent } from './titulo.component';
7 |
8 | describe('TituloComponent', () => {
9 | let component: TituloComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ TituloComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(TituloComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/dashboard/dashboard.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { DashboardComponent } from './dashboard.component';
7 |
8 | describe('DashboardComponent', () => {
9 | let component: DashboardComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ DashboardComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(DashboardComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/SmartSchool/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // @ts-check
2 | // Protractor configuration file, see link for more information
3 | // https://github.com/angular/protractor/blob/master/lib/config.ts
4 |
5 | const { SpecReporter } = require('jasmine-spec-reporter');
6 |
7 | /**
8 | * @type { import("protractor").Config }
9 | */
10 | exports.config = {
11 | allScriptsTimeout: 11000,
12 | specs: [
13 | './src/**/*.e2e-spec.ts'
14 | ],
15 | capabilities: {
16 | browserName: 'chrome'
17 | },
18 | directConnect: true,
19 | baseUrl: 'http://localhost:4200/',
20 | framework: 'jasmine',
21 | jasmineNodeOpts: {
22 | showColors: true,
23 | defaultTimeoutInterval: 30000,
24 | print: function() {}
25 | },
26 | onPrepare() {
27 | require('ts-node').register({
28 | project: require('path').join(__dirname, './tsconfig.json')
29 | });
30 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
31 | }
32 | };
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:22642",
8 | "sslPort": 44383
9 | }
10 | },
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "weatherforecast",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "SmartSchool_WebAPI": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "weatherforecast",
24 | "applicationUrl": "http://localhost:5000",
25 | "environmentVariables": {
26 | "ASPNETCORE_ENVIRONMENT": "Development"
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/professores.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { ProfessoresComponent } from './professores.component';
7 |
8 | describe('ProfessoresComponent', () => {
9 | let component: ProfessoresComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ ProfessoresComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(ProfessoresComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Data/IRepository.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using SmartSchool_WebAPI.Models;
3 |
4 | namespace SmartSchool_WebAPI.Data
5 | {
6 | public interface IRepository
7 | {
8 | //GERAL
9 | void Add(T entity) where T : class;
10 | void Update(T entity) where T : class;
11 | void Delete(T entity) where T : class;
12 | Task SaveChangesAsync();
13 |
14 | //ALUNO
15 | Task GetAllAlunosAsync(bool includeProfessor);
16 | Task GetAlunosAsyncByDisciplinaId(int disciplinaId, bool includeDisciplina);
17 | Task GetAlunoAsyncById(int alunoId, bool includeProfessor);
18 |
19 | //PROFESSOR
20 | Task GetAllProfessoresAsync(bool includeAluno);
21 | Task GetProfessorAsyncById(int professorId, bool includeAluno);
22 | Task GetProfessoresAsyncByAlunoId(int alunoId, bool includeDisciplina);
23 | }
24 | }
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/professor-detalhe/professor-detalhe.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { ProfessorDetalheComponent } from './professor-detalhe.component';
7 |
8 | describe('ProfessorDetalheComponent', () => {
9 | let component: ProfessorDetalheComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ ProfessorDetalheComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(ProfessorDetalheComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/alunos/professores-alunos/professores-alunos.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { ProfessoresAlunosComponent } from './professores-alunos.component';
7 |
8 | describe('ProfessoresAlunosComponent', () => {
9 | let component: ProfessoresAlunosComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ ProfessoresAlunosComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(ProfessoresAlunosComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/alunos-professores/alunos-professores.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { AlunosProfessoresComponent } from './alunos-professores.component';
7 |
8 | describe('AlunosProfessoresComponent', () => {
9 | let component: AlunosProfessoresComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ AlunosProfessoresComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(AlunosProfessoresComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/alunos/professores-alunos/professores-alunos.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 | import { Professor } from 'src/app/models/Professor';
3 | import { Util } from '../../../util/util';
4 | import { Disciplina } from 'src/app/models/Disciplina';
5 | import { Router } from '@angular/router';
6 |
7 | @Component({
8 | selector: 'app-professores-alunos',
9 | templateUrl: './professores-alunos.component.html',
10 | styleUrls: ['./professores-alunos.component.css']
11 | })
12 | export class ProfessoresAlunosComponent implements OnInit {
13 |
14 | @Input() public professores: Professor[];
15 | @Output() closeModal = new EventEmitter();
16 |
17 | constructor(private router: Router) { }
18 |
19 | ngOnInit() {
20 | }
21 |
22 | disciplinaConcat(disciplinas: Disciplina[]) {
23 | return Util.nomeConcat(disciplinas);
24 | }
25 |
26 | professorSelect(prof: Professor) {
27 | this.closeModal.emit(null);
28 | this.router.navigate(['/professor', prof.id]);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SmartSchool
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.3.21.
4 |
5 | ## Development server
6 |
7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8 |
9 | ## Code scaffolding
10 |
11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12 |
13 | ## Build
14 |
15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 |
25 | ## Further help
26 |
27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
28 |
--------------------------------------------------------------------------------
/SmartSchool/README.md:
--------------------------------------------------------------------------------
1 | # SmartSchool
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.3.21.
4 |
5 | ## Development server
6 |
7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8 |
9 | ## Code scaffolding
10 |
11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12 |
13 | ## Build
14 |
15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 |
25 | ## Further help
26 |
27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
28 |
--------------------------------------------------------------------------------
/SmartSchool/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, './coverage/SmartSchool'),
20 | reports: ['html', 'lcovonly', 'text-summary'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false,
30 | restartOnFileChange: true
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/services/aluno.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient } from '@angular/common/http';
3 | import { Observable } from 'rxjs';
4 |
5 | import { Aluno } from '../models/Aluno';
6 |
7 | import { environment } from 'src/environments/environment';
8 |
9 | @Injectable({
10 | providedIn: 'root'
11 | })
12 | export class AlunoService {
13 |
14 | baseURL = `${environment.mainUrlAPI}aluno`;
15 |
16 | constructor(private http: HttpClient) { }
17 |
18 | getAll(): Observable {
19 | return this.http.get(this.baseURL);
20 | }
21 |
22 | getById(id: number): Observable {
23 | return this.http.get(`${this.baseURL}/${id}`);
24 | }
25 |
26 | getByDisciplinaId(id: number): Observable {
27 | return this.http.get(`${this.baseURL}/ByDisciplina/${id}`);
28 | }
29 |
30 | post(aluno: Aluno) {
31 | return this.http.post(this.baseURL, aluno);
32 | }
33 |
34 | put(aluno: Aluno) {
35 | return this.http.put(`${this.baseURL}/${aluno.id}`, aluno);
36 | }
37 |
38 | delete(id: number) {
39 | return this.http.delete(`${this.baseURL}/${id}`);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/services/professor.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { HttpClient } from '@angular/common/http';
3 | import { Professor } from '../models/Professor';
4 | import { Observable } from 'rxjs';
5 | import { environment } from 'src/environments/environment';
6 |
7 | @Injectable({
8 | providedIn: 'root'
9 | })
10 | export class ProfessorService {
11 |
12 | baseURL = `${environment.mainUrlAPI}professor`;
13 |
14 | constructor(private http: HttpClient) { }
15 |
16 | getAll(): Observable {
17 | return this.http.get(this.baseURL);
18 | }
19 |
20 | getById(id: number): Observable {
21 | return this.http.get(`${this.baseURL}/${id}`);
22 | }
23 |
24 | getByAlunoId(id: number): Observable {
25 | return this.http.get(`${this.baseURL}/ByAluno/${id}`);
26 | }
27 |
28 | post(professor: Professor) {
29 | return this.http.post(this.baseURL, Professor);
30 | }
31 |
32 | put(professor: Professor) {
33 | return this.http.put(`${this.baseURL}/${professor.id}`, Professor);
34 | }
35 |
36 | delete(id: number) {
37 | return this.http.delete(`${this.baseURL}/${id}`);
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { ProfessoresComponent } from './components/professores/professores.component';
4 | import { ProfessorDetalheComponent } from './components/professores/professor-detalhe/professor-detalhe.component';
5 | import { AlunosComponent } from './components/alunos/alunos.component';
6 | import { DashboardComponent } from './components/dashboard/dashboard.component';
7 | import { PerfilComponent } from './components/perfil/perfil.component';
8 |
9 |
10 | const routes: Routes = [
11 | { path: 'alunos', component: AlunosComponent },
12 | { path: 'alunos/:id', component: AlunosComponent },
13 | { path: 'perfil', component: PerfilComponent },
14 | { path: 'professores', component: ProfessoresComponent },
15 | { path: 'professor/:id', component: ProfessorDetalheComponent },
16 | { path: 'dashboard', component: DashboardComponent },
17 | { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
18 | { path: '**', redirectTo: 'dashboard', pathMatch: 'full' }
19 | ];
20 |
21 | @NgModule({
22 | imports: [RouterModule.forRoot(routes)],
23 | exports: [RouterModule]
24 | })
25 | export class AppRoutingModule { }
26 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { RouterTestingModule } from '@angular/router/testing';
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | imports: [
9 | RouterTestingModule
10 | ],
11 | declarations: [
12 | AppComponent
13 | ],
14 | }).compileComponents();
15 | }));
16 |
17 | it('should create the app', () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.debugElement.componentInstance;
20 | expect(app).toBeTruthy();
21 | });
22 |
23 | it(`should have as title 'SmartSchool'`, () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | const app = fixture.debugElement.componentInstance;
26 | expect(app.title).toEqual('SmartSchool');
27 | });
28 |
29 | it('should render title', () => {
30 | const fixture = TestBed.createComponent(AppComponent);
31 | fixture.detectChanges();
32 | const compiled = fixture.debugElement.nativeElement;
33 | expect(compiled.querySelector('.content span').textContent).toContain('SmartSchool app is running!');
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "2.0.0",
3 | "tasks": [
4 | {
5 | "label": "build",
6 | "command": "dotnet",
7 | "type": "process",
8 | "args": [
9 | "build",
10 | "${workspaceFolder}/SmartSchool-WebAPI/SmartSchool-WebAPI.csproj",
11 | "/property:GenerateFullPaths=true",
12 | "/consoleloggerparameters:NoSummary"
13 | ],
14 | "problemMatcher": "$msCompile"
15 | },
16 | {
17 | "label": "publish",
18 | "command": "dotnet",
19 | "type": "process",
20 | "args": [
21 | "publish",
22 | "${workspaceFolder}/SmartSchool-WebAPI/SmartSchool-WebAPI.csproj",
23 | "/property:GenerateFullPaths=true",
24 | "/consoleloggerparameters:NoSummary"
25 | ],
26 | "problemMatcher": "$msCompile"
27 | },
28 | {
29 | "label": "watch",
30 | "command": "dotnet",
31 | "type": "process",
32 | "args": [
33 | "watch",
34 | "run",
35 | "${workspaceFolder}/SmartSchool-WebAPI/SmartSchool-WebAPI.csproj",
36 | "/property:GenerateFullPaths=true",
37 | "/consoleloggerparameters:NoSummary"
38 | ],
39 | "problemMatcher": "$msCompile"
40 | }
41 | ]
42 | }
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/shared/nav/nav.component.html:
--------------------------------------------------------------------------------
1 |
32 |
--------------------------------------------------------------------------------
/SmartSchool/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "smart-school",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "~8.2.14",
15 | "@angular/common": "~8.2.14",
16 | "@angular/compiler": "~8.2.14",
17 | "@angular/core": "~8.2.14",
18 | "@angular/forms": "~8.2.14",
19 | "@angular/platform-browser": "~8.2.14",
20 | "@angular/platform-browser-dynamic": "~8.2.14",
21 | "@angular/router": "~8.2.14",
22 | "bootstrap": "^4.4.1",
23 | "ngx-bootstrap": "^5.3.2",
24 | "ngx-spinner": "^8.0.1",
25 | "ngx-toastr": "^10.0.4",
26 | "rxjs": "~6.4.0",
27 | "tslib": "^1.10.0",
28 | "zone.js": "~0.9.1"
29 | },
30 | "devDependencies": {
31 | "@angular-devkit/build-angular": "~0.803.21",
32 | "@angular/cli": "~8.3.21",
33 | "@angular/compiler-cli": "~8.2.14",
34 | "@angular/language-service": "~8.2.14",
35 | "@types/node": "~8.9.4",
36 | "@types/jasmine": "~3.3.8",
37 | "@types/jasminewd2": "~2.0.3",
38 | "codelyzer": "^5.0.0",
39 | "jasmine-core": "~3.4.0",
40 | "jasmine-spec-reporter": "~4.2.1",
41 | "karma": "~4.1.0",
42 | "karma-chrome-launcher": "~2.2.0",
43 | "karma-coverage-istanbul-reporter": "~2.0.1",
44 | "karma-jasmine": "~2.0.1",
45 | "karma-jasmine-html-reporter": "^1.4.0",
46 | "protractor": "~5.4.0",
47 | "ts-node": "~7.0.0",
48 | "tslint": "~5.15.0",
49 | "typescript": "~3.5.3"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/professor-detalhe/professor-detalhe.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
10 |
11 |
12 |
13 |
40 |
41 |
42 |
43 |
46 |
52 |
53 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to find out which attributes exist for C# debugging
3 | // Use hover for the description of the existing attributes
4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "type": "chrome",
9 | "request": "launch",
10 | "name": "Launch Chrome",
11 | "url": "http://localhost:4200",
12 | "webRoot": "${workspaceFolder}"
13 | },
14 | {
15 | "name": ".NET Core Launch (web)",
16 | "type": "coreclr",
17 | "request": "launch",
18 | "preLaunchTask": "build",
19 | // If you have changed target frameworks, make sure to update the program path.
20 | "program": "${workspaceFolder}/SmartSchool-WebAPI/bin/Debug/netcoreapp3.1/SmartSchool-WebAPI.dll",
21 | "args": [],
22 | "cwd": "${workspaceFolder}/SmartSchool-WebAPI",
23 | "stopAtEntry": false,
24 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
25 | "serverReadyAction": {
26 | "action": "openExternally",
27 | "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
28 | },
29 | "env": {
30 | "ASPNETCORE_ENVIRONMENT": "Development"
31 | },
32 | "sourceFileMap": {
33 | "/Views": "${workspaceFolder}/Views"
34 | }
35 | },
36 | {
37 | "name": ".NET Core Attach",
38 | "type": "coreclr",
39 | "request": "attach",
40 | "processId": "${command:pickProcess}"
41 | }
42 | ]
43 | }
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.EntityFrameworkCore;
4 | using Microsoft.Extensions.Configuration;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.Hosting;
7 | using SmartSchool_WebAPI.Data;
8 |
9 | namespace SmartSchool_WebAPI
10 | {
11 | public class Startup
12 | {
13 | public Startup(IConfiguration configuration)
14 | {
15 | Configuration = configuration;
16 | }
17 |
18 | public IConfiguration Configuration { get; }
19 |
20 | // This method gets called by the runtime. Use this method to add services to the container.
21 | public void ConfigureServices(IServiceCollection services)
22 | {
23 | services.AddDbContext(
24 | x => x.UseSqlite(Configuration.GetConnectionString("DefaultConn"))
25 | );
26 |
27 | services.AddControllers()
28 | .AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling =
29 | Newtonsoft.Json.ReferenceLoopHandling.Ignore);
30 | services.AddScoped();
31 | services.AddCors();
32 | }
33 |
34 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
35 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
36 | {
37 | if (env.IsDevelopment())
38 | {
39 | app.UseDeveloperExceptionPage();
40 | }
41 |
42 | // app.UseHttpsRedirection();
43 |
44 | app.UseRouting();
45 | app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
46 |
47 | // app.UseAuthorization();
48 |
49 | app.UseEndpoints(endpoints =>
50 | {
51 | endpoints.MapControllers();
52 | });
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/professores.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, TemplateRef, OnDestroy } from '@angular/core';
2 | import { Professor } from '../../models/Professor';
3 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
4 | import { Subject } from 'rxjs';
5 | import { NgxSpinnerService } from 'ngx-spinner';
6 | import { ToastrService } from 'ngx-toastr';
7 | import { ProfessorService } from '../../services/professor.service';
8 | import { takeUntil } from 'rxjs/operators';
9 | import { Util } from '../../util/util';
10 | import { Disciplina } from '../../models/Disciplina';
11 | import { Router } from '@angular/router';
12 | import { Aluno } from '../../models/Aluno';
13 | import { AlunoService } from '../../services/aluno.service';
14 |
15 | @Component({
16 | selector: 'app-professores',
17 | templateUrl: './professores.component.html',
18 | styleUrls: ['./professores.component.css']
19 | })
20 | export class ProfessoresComponent implements OnInit, OnDestroy {
21 |
22 | public titulo = 'Professores';
23 | public professorSelecionado: Professor;
24 | private unsubscriber = new Subject();
25 |
26 | public professores: Professor[];
27 |
28 | constructor(
29 | private router: Router,
30 | private professorService: ProfessorService,
31 | private toastr: ToastrService,
32 | private spinner: NgxSpinnerService) {}
33 |
34 | carregarProfessores() {
35 | this.spinner.show();
36 | this.professorService.getAll()
37 | .pipe(takeUntil(this.unsubscriber))
38 | .subscribe((professores: Professor[]) => {
39 | this.professores = professores;
40 | this.toastr.success('Professores foram carregado com Sucesso!');
41 | }, (error: any) => {
42 | this.toastr.error('Professores não carregados!');
43 | console.log(error);
44 | }, () => this.spinner.hide()
45 | );
46 | }
47 |
48 | ngOnInit() {
49 | this.carregarProfessores();
50 | }
51 |
52 | ngOnDestroy(): void {
53 | this.unsubscriber.next();
54 | this.unsubscriber.complete();
55 | }
56 |
57 | disciplinaConcat(disciplinas: Disciplina[]) {
58 | return Util.nomeConcat(disciplinas);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/SmartSchool/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint:recommended",
3 | "rules": {
4 | "array-type": false,
5 | "arrow-parens": false,
6 | "deprecation": {
7 | "severity": "warning"
8 | },
9 | "component-class-suffix": true,
10 | "contextual-lifecycle": true,
11 | "directive-class-suffix": true,
12 | "directive-selector": [
13 | true,
14 | "attribute",
15 | "app",
16 | "camelCase"
17 | ],
18 | "component-selector": [
19 | true,
20 | "element",
21 | "app",
22 | "kebab-case"
23 | ],
24 | "import-blacklist": [
25 | true,
26 | "rxjs/Rx"
27 | ],
28 | "interface-name": false,
29 | "max-classes-per-file": false,
30 | "max-line-length": [
31 | true,
32 | 140
33 | ],
34 | "member-access": false,
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-consecutive-blank-lines": false,
47 | "no-console": [
48 | true,
49 | "debug",
50 | "info",
51 | "time",
52 | "timeEnd",
53 | "trace"
54 | ],
55 | "no-empty": false,
56 | "no-inferrable-types": [
57 | true,
58 | "ignore-params"
59 | ],
60 | "no-non-null-assertion": true,
61 | "no-redundant-jsdoc": true,
62 | "no-switch-case-fall-through": true,
63 | "no-var-requires": false,
64 | "object-literal-key-quotes": [
65 | true,
66 | "as-needed"
67 | ],
68 | "object-literal-sort-keys": false,
69 | "ordered-imports": false,
70 | "quotemark": [
71 | true,
72 | "single"
73 | ],
74 | "trailing-comma": false,
75 | "no-conflicting-lifecycle": true,
76 | "no-host-metadata-property": true,
77 | "no-input-rename": true,
78 | "no-inputs-metadata-property": true,
79 | "no-output-native": true,
80 | "no-output-on-prefix": true,
81 | "no-output-rename": true,
82 | "no-outputs-metadata-property": true,
83 | "template-banana-in-box": true,
84 | "template-no-negated-async": true,
85 | "use-lifecycle-interface": true,
86 | "use-pipe-transform-interface": true
87 | },
88 | "rulesDirectory": [
89 | "codelyzer"
90 | ]
91 | }
--------------------------------------------------------------------------------
/SmartSchool/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule, ReactiveFormsModule } from '@angular/forms';
4 | import { HttpClientModule } from '@angular/common/http';
5 |
6 | import { AppRoutingModule } from './app-routing.module';
7 | import { AppComponent } from './app.component';
8 | import { AlunosComponent } from './components/alunos/alunos.component';
9 | import { AlunosProfessoresComponent } from './components/professores/alunos-professores/alunos-professores.component';
10 | import { ProfessoresComponent } from './components/professores/professores.component';
11 | import { ProfessoresAlunosComponent } from './components/alunos/professores-alunos/professores-alunos.component';
12 | import { ProfessorDetalheComponent } from './components/professores/professor-detalhe/professor-detalhe.component';
13 | import { PerfilComponent } from './components/perfil/perfil.component';
14 | import { DashboardComponent } from './components/dashboard/dashboard.component';
15 | import { NavComponent } from './components/shared/nav/nav.component';
16 | import { TituloComponent } from './components/shared/titulo/titulo.component';
17 | import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
18 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
19 | import { ModalModule } from 'ngx-bootstrap/modal';
20 |
21 | import { ToastrModule } from 'ngx-toastr';
22 | import { NgxSpinnerModule } from 'ngx-spinner';
23 |
24 | @NgModule({
25 | declarations: [
26 | AppComponent,
27 | AlunosComponent,
28 | AlunosProfessoresComponent,
29 | ProfessoresComponent,
30 | ProfessoresAlunosComponent,
31 | ProfessorDetalheComponent,
32 | PerfilComponent,
33 | DashboardComponent,
34 | NavComponent,
35 | TituloComponent
36 | ],
37 | imports: [
38 | BrowserModule,
39 | AppRoutingModule,
40 | BsDropdownModule.forRoot(),
41 | BrowserAnimationsModule,
42 | FormsModule,
43 | ReactiveFormsModule,
44 | ModalModule.forRoot(),
45 | HttpClientModule,
46 | NgxSpinnerModule,
47 | ToastrModule.forRoot({
48 | timeOut: 3500,
49 | positionClass: 'toast-bottom-right',
50 | preventDuplicates: true,
51 | progressBar: true,
52 | closeButton: true
53 | })
54 | ],
55 | providers: [],
56 | bootstrap: [
57 | AppComponent
58 | ]
59 | })
60 | export class AppModule { }
61 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/alunos/alunos.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
12 |
13 |
14 |
15 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | | Visualizar |
42 | # |
43 | Nome |
44 | Sobrenome |
45 | telefone |
46 | Opções |
47 |
48 |
49 |
50 |
51 | |
53 | {{aluno.id}} |
54 | {{aluno.nome}} |
55 | {{aluno.sobrenome}} |
56 | {{aluno.telefone}} |
57 |
58 |
59 |
60 |
61 |
62 | |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
74 |
80 |
81 |
--------------------------------------------------------------------------------
/SmartSchool/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags.ts';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 |
61 | /***************************************************************************************************
62 | * APPLICATION IMPORTS
63 | */
64 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/professores/professor-detalhe/professor-detalhe.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, OnDestroy, TemplateRef } from '@angular/core';
2 | import { Router, ActivatedRoute } from '@angular/router';
3 | import { ProfessorService } from 'src/app/services/professor.service';
4 | import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
5 | import { ToastrService } from 'ngx-toastr';
6 | import { NgxSpinnerService } from 'ngx-spinner';
7 | import { Subject } from 'rxjs';
8 | import { takeUntil } from 'rxjs/operators';
9 | import { Professor } from 'src/app/models/Professor';
10 | import { AlunoService } from 'src/app/services/aluno.service';
11 | import { Aluno } from 'src/app/models/Aluno';
12 |
13 | @Component({
14 | selector: 'app-professor-detalhe',
15 | templateUrl: './professor-detalhe.component.html',
16 | styleUrls: ['./professor-detalhe.component.css']
17 | })
18 | export class ProfessorDetalheComponent implements OnInit, OnDestroy {
19 |
20 | public modalRef: BsModalRef;
21 | public professorSelecionado: Professor;
22 | public titulo = '';
23 | public alunosProfs: Aluno[];
24 | private unsubscriber = new Subject();
25 |
26 | constructor(
27 | private router: Router,
28 | private route: ActivatedRoute,
29 | private professorService: ProfessorService,
30 | private alunoService: AlunoService,
31 | private modalService: BsModalService,
32 | private toastr: ToastrService,
33 | private spinner: NgxSpinnerService
34 | ) { }
35 |
36 | openModal(template: TemplateRef, alunoId: number) {
37 | this.alunosProfessores(template, alunoId);
38 | }
39 |
40 | closeModal() {
41 | this.modalRef.hide();
42 | }
43 |
44 | alunosProfessores(template: TemplateRef, id: number) {
45 | this.spinner.show();
46 | this.alunoService.getByDisciplinaId(id)
47 | .pipe(takeUntil(this.unsubscriber))
48 | .subscribe((alunos: Aluno[]) => {
49 | this.alunosProfs = alunos;
50 | this.modalRef = this.modalService.show(template);
51 | }, (error: any) => {
52 | this.toastr.error(`erro: ${error}`);
53 | console.log(error);
54 | }, () => this.spinner.hide()
55 | );
56 | }
57 |
58 | ngOnInit() {
59 | this.spinner.show();
60 | this.carregarProfessor();
61 | }
62 |
63 | carregarProfessor() {
64 | const profId = +this.route.snapshot.paramMap.get('id');
65 | this.professorService.getById(profId)
66 | .pipe(takeUntil(this.unsubscriber))
67 | .subscribe((professor: Professor) => {
68 | this.professorSelecionado = professor;
69 | this.titulo = 'Professor: ' + this.professorSelecionado.id;
70 | this.toastr.success('Professor carregado com Sucesso!');
71 | }, (error: any) => {
72 | this.toastr.error('Professor não carregados!');
73 | console.log(error);
74 | }, () => this.spinner.hide()
75 | );
76 | }
77 |
78 | voltar() {
79 | this.router.navigate(['/professores']);
80 | }
81 |
82 | ngOnDestroy(): void {
83 | this.unsubscriber.next();
84 | this.unsubscriber.complete();
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Controllers/AlunoController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Microsoft.AspNetCore.Mvc;
4 | using SmartSchool_WebAPI.Data;
5 | using SmartSchool_WebAPI.Models;
6 |
7 | namespace SmartSchool_WebAPI.Controllers
8 | {
9 | [ApiController]
10 | [Route("api/[controller]")]
11 | public class AlunoController : ControllerBase
12 | {
13 | private readonly IRepository _repo;
14 |
15 | public AlunoController(IRepository repo)
16 | {
17 | _repo = repo;
18 | }
19 |
20 | [HttpGet]
21 | public async Task Get()
22 | {
23 | try
24 | {
25 | var result = await _repo.GetAllAlunosAsync(true);
26 |
27 | return Ok(result);
28 | }
29 | catch (Exception ex)
30 | {
31 | return BadRequest($"Erro: {ex.Message}");
32 | }
33 | }
34 |
35 | [HttpGet("{AlunoId}")]
36 | public async Task GetByAlunoId(int AlunoId)
37 | {
38 | try
39 | {
40 | var result = await _repo.GetAlunoAsyncById(AlunoId, true);
41 |
42 | return Ok(result);
43 | }
44 | catch (Exception ex)
45 | {
46 | return BadRequest($"Erro: {ex.Message}");
47 | }
48 | }
49 |
50 | [HttpGet("ByDisciplina/{disciplinaId}")]
51 | public async Task GetByDisciplinaId(int disciplinaId)
52 | {
53 | try
54 | {
55 | var result = await _repo.GetAlunosAsyncByDisciplinaId(disciplinaId, false);
56 | return Ok(result);
57 | }
58 | catch (Exception ex)
59 | {
60 | return BadRequest($"Erro: {ex.Message}");
61 | }
62 | }
63 |
64 | [HttpPost]
65 | public async Task post(Aluno model)
66 | {
67 | try
68 | {
69 | _repo.Add(model);
70 |
71 | if(await _repo.SaveChangesAsync())
72 | {
73 | return Ok(model);
74 | }
75 | }
76 | catch (Exception ex)
77 | {
78 | return BadRequest($"Erro: {ex.Message}");
79 | }
80 |
81 | return BadRequest();
82 | }
83 |
84 | [HttpPut("{alunoId}")]
85 | public async Task put(int alunoId, Aluno model)
86 | {
87 | try
88 | {
89 | var aluno = await _repo.GetAlunoAsyncById(alunoId, false);
90 | if(aluno == null) return NotFound();
91 |
92 | _repo.Update(model);
93 |
94 | if(await _repo.SaveChangesAsync())
95 | {
96 | return Ok(model);
97 | }
98 | }
99 | catch (Exception ex)
100 | {
101 | return BadRequest($"Erro: {ex.Message}");
102 | }
103 |
104 | return BadRequest();
105 | }
106 |
107 | [HttpDelete("{alunoId}")]
108 | public async Task delete(int alunoId)
109 | {
110 | try
111 | {
112 | var aluno = await _repo.GetAlunoAsyncById(alunoId, false);
113 | if(aluno == null) return NotFound();
114 |
115 | _repo.Delete(aluno);
116 |
117 | if(await _repo.SaveChangesAsync())
118 | {
119 | return Ok("Deletado");
120 | }
121 | }
122 | catch (Exception ex)
123 | {
124 | return BadRequest($"Erro: {ex.Message}");
125 | }
126 |
127 | return BadRequest();
128 | }
129 |
130 | }
131 | }
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Controllers/ProfessorController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using Microsoft.AspNetCore.Mvc;
4 | using SmartSchool_WebAPI.Data;
5 | using SmartSchool_WebAPI.Models;
6 |
7 | namespace SmartSchool_WebAPI.Controllers
8 | {
9 | [ApiController]
10 | [Route("api/[controller]")]
11 | public class ProfessorController : ControllerBase
12 | {
13 | private readonly IRepository _repo;
14 |
15 | public ProfessorController(IRepository repo)
16 | {
17 | _repo = repo;
18 | }
19 |
20 | [HttpGet]
21 | public async Task Get()
22 | {
23 | try
24 | {
25 | var result = await _repo.GetAllProfessoresAsync(true);
26 |
27 | return Ok(result);
28 | }
29 | catch (Exception ex)
30 | {
31 | return BadRequest($"Erro: {ex.Message}");
32 | }
33 | }
34 |
35 | [HttpGet("{ProfessorId}")]
36 | public async Task GetByProfessorId(int ProfessorId)
37 | {
38 | try
39 | {
40 | var result = await _repo.GetProfessorAsyncById(ProfessorId, true);
41 |
42 | return Ok(result);
43 | }
44 | catch (Exception ex)
45 | {
46 | return BadRequest($"Erro: {ex.Message}");
47 | }
48 | }
49 |
50 | [HttpGet("ByAluno/{alunoId}")]
51 | public async Task GetByAlunoId(int alunoId)
52 | {
53 | try
54 | {
55 | var result = await _repo.GetProfessoresAsyncByAlunoId(alunoId, true);
56 | return Ok(result);
57 | }
58 | catch (Exception ex)
59 | {
60 | return BadRequest($"Erro: {ex.Message}");
61 | }
62 | }
63 |
64 | [HttpPost]
65 | public async Task post(Professor model)
66 | {
67 | try
68 | {
69 | _repo.Add(model);
70 |
71 | if(await _repo.SaveChangesAsync())
72 | {
73 | return Ok(model);
74 | }
75 | }
76 | catch (Exception ex)
77 | {
78 | return BadRequest($"Erro: {ex.Message}");
79 | }
80 |
81 | return BadRequest();
82 | }
83 |
84 | [HttpPut("{professorId}")]
85 | public async Task put(int professorId, Professor model)
86 | {
87 | try
88 | {
89 | var Professor = await _repo.GetProfessorAsyncById(professorId, false);
90 | if(Professor == null) return NotFound();
91 |
92 | _repo.Update(model);
93 |
94 | if(await _repo.SaveChangesAsync())
95 | {
96 | return Ok(model);
97 | }
98 | }
99 | catch (Exception ex)
100 | {
101 | return BadRequest($"Erro: {ex.Message}");
102 | }
103 |
104 | return BadRequest();
105 | }
106 |
107 | [HttpDelete("{professorId}")]
108 | public async Task delete(int professorId)
109 | {
110 | try
111 | {
112 | var Professor = await _repo.GetProfessorAsyncById(professorId, false);
113 | if(Professor == null) return NotFound();
114 |
115 | _repo.Delete(Professor);
116 |
117 | if(await _repo.SaveChangesAsync())
118 | {
119 | return Ok("Deletado");
120 | }
121 | }
122 | catch (Exception ex)
123 | {
124 | return BadRequest($"Erro: {ex.Message}");
125 | }
126 |
127 | return BadRequest();
128 | }
129 | }
130 | }
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Data/DataContext.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Microsoft.EntityFrameworkCore;
3 | using SmartSchool_WebAPI.Models;
4 |
5 | namespace SmartSchool_WebAPI.Data
6 | {
7 | public class DataContext : DbContext
8 | {
9 | public DataContext(DbContextOptions options) : base (options) { }
10 | public DbSet Alunos { get; set; }
11 | public DbSet Professores { get; set; }
12 | public DbSet Disciplinas { get; set; }
13 | public DbSet AlunosDisciplinas { get; set; }
14 |
15 | protected override void OnModelCreating(ModelBuilder builder)
16 | {
17 | builder.Entity()
18 | .HasKey(AD => new { AD.AlunoId, AD.DisciplinaId });
19 |
20 | builder.Entity()
21 | .HasData(new List(){
22 | new Professor(1, "Lauro"),
23 | new Professor(2, "Roberto"),
24 | new Professor(3, "Ronaldo"),
25 | new Professor(4, "Rodrigo"),
26 | new Professor(5, "Alexandre"),
27 | });
28 |
29 | builder.Entity()
30 | .HasData(new List{
31 | new Disciplina(1, "Matemática", 1),
32 | new Disciplina(2, "Física", 2),
33 | new Disciplina(3, "Português", 3),
34 | new Disciplina(4, "Inglês", 4),
35 | new Disciplina(5, "Programação", 5)
36 | });
37 |
38 | builder.Entity()
39 | .HasData(new List(){
40 | new Aluno(1, "Marta", "Kent", "33225555"),
41 | new Aluno(2, "Paula", "Isabela", "3354288"),
42 | new Aluno(3, "Laura", "Antonia", "55668899"),
43 | new Aluno(4, "Luiza", "Maria", "6565659"),
44 | new Aluno(5, "Lucas", "Machado", "565685415"),
45 | new Aluno(6, "Pedro", "Alvares", "456454545"),
46 | new Aluno(7, "Paulo", "José", "9874512")
47 | });
48 |
49 | builder.Entity()
50 | .HasData(new List() {
51 | new AlunoDisciplina() {AlunoId = 1, DisciplinaId = 2 },
52 | new AlunoDisciplina() {AlunoId = 1, DisciplinaId = 4 },
53 | new AlunoDisciplina() {AlunoId = 1, DisciplinaId = 5 },
54 | new AlunoDisciplina() {AlunoId = 2, DisciplinaId = 1 },
55 | new AlunoDisciplina() {AlunoId = 2, DisciplinaId = 2 },
56 | new AlunoDisciplina() {AlunoId = 2, DisciplinaId = 5 },
57 | new AlunoDisciplina() {AlunoId = 3, DisciplinaId = 1 },
58 | new AlunoDisciplina() {AlunoId = 3, DisciplinaId = 2 },
59 | new AlunoDisciplina() {AlunoId = 3, DisciplinaId = 3 },
60 | new AlunoDisciplina() {AlunoId = 4, DisciplinaId = 1 },
61 | new AlunoDisciplina() {AlunoId = 4, DisciplinaId = 4 },
62 | new AlunoDisciplina() {AlunoId = 4, DisciplinaId = 5 },
63 | new AlunoDisciplina() {AlunoId = 5, DisciplinaId = 4 },
64 | new AlunoDisciplina() {AlunoId = 5, DisciplinaId = 5 },
65 | new AlunoDisciplina() {AlunoId = 6, DisciplinaId = 1 },
66 | new AlunoDisciplina() {AlunoId = 6, DisciplinaId = 2 },
67 | new AlunoDisciplina() {AlunoId = 6, DisciplinaId = 3 },
68 | new AlunoDisciplina() {AlunoId = 6, DisciplinaId = 4 },
69 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 1 },
70 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 2 },
71 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 3 },
72 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 4 },
73 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 5 }
74 | });
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/SmartSchool/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "SmartSchool": {
7 | "projectType": "application",
8 | "schematics": {},
9 | "root": "",
10 | "sourceRoot": "src",
11 | "prefix": "app",
12 | "architect": {
13 | "build": {
14 | "builder": "@angular-devkit/build-angular:browser",
15 | "options": {
16 | "outputPath": "dist/SmartSchool",
17 | "index": "src/index.html",
18 | "main": "src/main.ts",
19 | "polyfills": "src/polyfills.ts",
20 | "tsConfig": "tsconfig.app.json",
21 | "aot": false,
22 | "assets": [
23 | "src/favicon.ico",
24 | "src/assets"
25 | ],
26 | "styles": [
27 | "src/styles.css",
28 | "node_modules/ngx-toastr/toastr.css"
29 | ],
30 | "scripts": []
31 | },
32 | "configurations": {
33 | "production": {
34 | "fileReplacements": [
35 | {
36 | "replace": "src/environments/environment.ts",
37 | "with": "src/environments/environment.prod.ts"
38 | }
39 | ],
40 | "optimization": true,
41 | "outputHashing": "all",
42 | "sourceMap": false,
43 | "extractCss": true,
44 | "namedChunks": false,
45 | "aot": true,
46 | "extractLicenses": true,
47 | "vendorChunk": false,
48 | "buildOptimizer": true,
49 | "budgets": [
50 | {
51 | "type": "initial",
52 | "maximumWarning": "2mb",
53 | "maximumError": "5mb"
54 | },
55 | {
56 | "type": "anyComponentStyle",
57 | "maximumWarning": "6kb",
58 | "maximumError": "10kb"
59 | }
60 | ]
61 | }
62 | }
63 | },
64 | "serve": {
65 | "builder": "@angular-devkit/build-angular:dev-server",
66 | "options": {
67 | "browserTarget": "SmartSchool:build"
68 | },
69 | "configurations": {
70 | "production": {
71 | "browserTarget": "SmartSchool:build:production"
72 | }
73 | }
74 | },
75 | "extract-i18n": {
76 | "builder": "@angular-devkit/build-angular:extract-i18n",
77 | "options": {
78 | "browserTarget": "SmartSchool:build"
79 | }
80 | },
81 | "test": {
82 | "builder": "@angular-devkit/build-angular:karma",
83 | "options": {
84 | "main": "src/test.ts",
85 | "polyfills": "src/polyfills.ts",
86 | "tsConfig": "tsconfig.spec.json",
87 | "karmaConfig": "karma.conf.js",
88 | "assets": [
89 | "src/favicon.ico",
90 | "src/assets"
91 | ],
92 | "styles": [
93 | "./node_modules/bootstrap/dist/css/bootstrap.min.css",
94 | "src/styles.css"
95 | ],
96 | "scripts": []
97 | }
98 | },
99 | "lint": {
100 | "builder": "@angular-devkit/build-angular:tslint",
101 | "options": {
102 | "tsConfig": [
103 | "tsconfig.app.json",
104 | "tsconfig.spec.json",
105 | "e2e/tsconfig.json"
106 | ],
107 | "exclude": [
108 | "**/node_modules/**"
109 | ]
110 | }
111 | },
112 | "e2e": {
113 | "builder": "@angular-devkit/build-angular:protractor",
114 | "options": {
115 | "protractorConfig": "e2e/protractor.conf.js",
116 | "devServerTarget": "SmartSchool:serve"
117 | },
118 | "configurations": {
119 | "production": {
120 | "devServerTarget": "SmartSchool:serve:production"
121 | }
122 | }
123 | }
124 | }
125 | }
126 | },
127 | "defaultProject": "SmartSchool"
128 | }
129 |
--------------------------------------------------------------------------------
/SmartSchool/src/app/components/alunos/alunos.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, TemplateRef, OnDestroy } from '@angular/core';
2 | import { Aluno } from '../../models/Aluno';
3 | import { FormGroup, FormBuilder, Validators } from '@angular/forms';
4 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
5 | import { ToastrService } from 'ngx-toastr';
6 | import { NgxSpinnerService } from 'ngx-spinner';
7 | import { AlunoService } from '../../services/aluno.service';
8 | import { takeUntil } from 'rxjs/operators';
9 | import { Subject } from 'rxjs';
10 | import { ProfessorService } from '../../services/professor.service';
11 | import { Professor } from '../../models/Professor';
12 | import { ActivatedRoute } from '@angular/router';
13 |
14 | @Component({
15 | selector: 'app-alunos',
16 | templateUrl: './alunos.component.html',
17 | styleUrls: ['./alunos.component.css']
18 | })
19 | export class AlunosComponent implements OnInit, OnDestroy {
20 |
21 | public modalRef: BsModalRef;
22 | public alunoForm: FormGroup;
23 | public titulo = 'Alunos';
24 | public alunoSelecionado: Aluno;
25 | public textSimple: string;
26 | public profsAlunos: Professor[];
27 |
28 | private unsubscriber = new Subject();
29 |
30 | public alunos: Aluno[];
31 | public aluno: Aluno;
32 | public msnDeleteAluno: string;
33 | public modeSave = 'post';
34 |
35 | openModal(template: TemplateRef, alunoId: number) {
36 | this.professoresAlunos(template, alunoId);
37 | }
38 |
39 | closeModal() {
40 | this.modalRef.hide();
41 | }
42 |
43 | professoresAlunos(template: TemplateRef, id: number) {
44 | this.spinner.show();
45 | this.professorService.getByAlunoId(id)
46 | .pipe(takeUntil(this.unsubscriber))
47 | .subscribe((professores: Professor[]) => {
48 | this.profsAlunos = professores;
49 | this.modalRef = this.modalService.show(template);
50 | }, (error: any) => {
51 | this.toastr.error(`erro: ${error}`);
52 | console.log(error);
53 | }, () => this.spinner.hide()
54 | );
55 | }
56 |
57 | constructor(
58 | private alunoService: AlunoService,
59 | private route: ActivatedRoute,
60 | private professorService: ProfessorService,
61 | private fb: FormBuilder,
62 | private modalService: BsModalService,
63 | private toastr: ToastrService,
64 | private spinner: NgxSpinnerService
65 | ) {
66 | this.criarForm();
67 | }
68 |
69 | ngOnInit() {
70 | this.carregarAlunos();
71 | }
72 |
73 | ngOnDestroy(): void {
74 | this.unsubscriber.next();
75 | this.unsubscriber.complete();
76 | }
77 |
78 | criarForm() {
79 | this.alunoForm = this.fb.group({
80 | id: [0],
81 | nome: ['', Validators.required],
82 | sobrenome: ['', Validators.required],
83 | telefone: ['', Validators.required]
84 | });
85 | }
86 |
87 | saveAluno() {
88 | if (this.alunoForm.valid) {
89 | this.spinner.show();
90 |
91 | if (this.modeSave === 'post') {
92 | this.aluno = {...this.alunoForm.value};
93 | } else {
94 | this.aluno = {id: this.alunoSelecionado.id, ...this.alunoForm.value};
95 | }
96 |
97 | this.alunoService[this.modeSave](this.aluno)
98 | .pipe(takeUntil(this.unsubscriber))
99 | .subscribe(
100 | () => {
101 | this.carregarAlunos();
102 | this.toastr.success('Aluno salvo com sucesso!');
103 | }, (error: any) => {
104 | this.toastr.error(`Erro: Aluno não pode ser salvo!`);
105 | console.error(error);
106 | }, () => this.spinner.hide()
107 | );
108 |
109 | }
110 | }
111 |
112 | carregarAlunos() {
113 | const id = +this.route.snapshot.paramMap.get('id');
114 |
115 | this.spinner.show();
116 | this.alunoService.getAll()
117 | .pipe(takeUntil(this.unsubscriber))
118 | .subscribe((alunos: Aluno[]) => {
119 | this.alunos = alunos;
120 |
121 | if (id > 0) {
122 | this.alunoSelect(this.alunos.find(aluno => aluno.id === id));
123 | }
124 |
125 | this.toastr.success('Alunos foram carregado com Sucesso!');
126 | }, (error: any) => {
127 | this.toastr.error('Alunos não carregados!');
128 | console.log(error);
129 | }, () => this.spinner.hide()
130 | );
131 | }
132 |
133 | alunoSelect(aluno: Aluno) {
134 | this.modeSave = 'put';
135 | this.alunoSelecionado = aluno;
136 | this.alunoForm.patchValue(aluno);
137 | }
138 |
139 | voltar() {
140 | this.alunoSelecionado = null;
141 | }
142 |
143 | }
144 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Data/Repository.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Threading.Tasks;
3 | using Microsoft.EntityFrameworkCore;
4 | using SmartSchool_WebAPI.Models;
5 |
6 | namespace SmartSchool_WebAPI.Data
7 | {
8 | public class Repository : IRepository
9 | {
10 | private readonly DataContext _context;
11 |
12 | public Repository(DataContext context)
13 | {
14 | _context = context;
15 | }
16 | public void Add(T entity) where T : class
17 | {
18 | _context.Add(entity);
19 | }
20 | public void Update(T entity) where T : class
21 | {
22 | _context.Update(entity);
23 | }
24 | public void Delete(T entity) where T : class
25 | {
26 | _context.Remove(entity);
27 | }
28 | public async Task SaveChangesAsync()
29 | {
30 | return (await _context.SaveChangesAsync()) > 0;
31 | }
32 |
33 | public async Task GetAllAlunosAsync(bool includeDisciplina = false)
34 | {
35 | IQueryable query = _context.Alunos;
36 |
37 | if (includeDisciplina)
38 | {
39 | query = query.Include(pe => pe.AlunosDisciplinas)
40 | .ThenInclude(ad => ad.Disciplina)
41 | .ThenInclude(d => d.Professor);
42 | }
43 |
44 | query = query.AsNoTracking()
45 | .OrderBy(c => c.Id);
46 |
47 | return await query.ToArrayAsync();
48 | }
49 | public async Task GetAlunoAsyncById(int alunoId, bool includeDisciplina)
50 | {
51 | IQueryable query = _context.Alunos;
52 |
53 | if (includeDisciplina)
54 | {
55 | query = query.Include(a => a.AlunosDisciplinas)
56 | .ThenInclude(ad => ad.Disciplina)
57 | .ThenInclude(d => d.Professor);
58 | }
59 |
60 | query = query.AsNoTracking()
61 | .OrderBy(aluno => aluno.Id)
62 | .Where(aluno => aluno.Id == alunoId);
63 |
64 | return await query.FirstOrDefaultAsync();
65 | }
66 | public async Task GetAlunosAsyncByDisciplinaId(int disciplinaId, bool includeDisciplina)
67 | {
68 | IQueryable query = _context.Alunos;
69 |
70 | if (includeDisciplina)
71 | {
72 | query = query.Include(p => p.AlunosDisciplinas)
73 | .ThenInclude(ad => ad.Disciplina)
74 | .ThenInclude(d => d.Professor);
75 | }
76 |
77 | query = query.AsNoTracking()
78 | .OrderBy(aluno => aluno.Id)
79 | .Where(aluno => aluno.AlunosDisciplinas.Any(ad => ad.DisciplinaId == disciplinaId));
80 |
81 | return await query.ToArrayAsync();
82 | }
83 |
84 | public async Task GetProfessoresAsyncByAlunoId(int alunoId, bool includeDisciplina)
85 | {
86 | IQueryable query = _context.Professores;
87 |
88 | if (includeDisciplina)
89 | {
90 | query = query.Include(p => p.Disciplinas);
91 | }
92 |
93 | query = query.AsNoTracking()
94 | .OrderBy(aluno => aluno.Id)
95 | .Where(aluno => aluno.Disciplinas.Any(d =>
96 | d.AlunosDisciplinas.Any(ad => ad.AlunoId == alunoId)));
97 |
98 | return await query.ToArrayAsync();
99 | }
100 |
101 | public async Task GetAllProfessoresAsync(bool includeDisciplinas = true)
102 | {
103 | IQueryable query = _context.Professores;
104 |
105 | if (includeDisciplinas)
106 | {
107 | query = query.Include(c => c.Disciplinas);
108 | }
109 |
110 | query = query.AsNoTracking()
111 | .OrderBy(professor => professor.Id);
112 |
113 | return await query.ToArrayAsync();
114 | }
115 | public async Task GetProfessorAsyncById(int professorId, bool includeDisciplinas = true)
116 | {
117 | IQueryable query = _context.Professores;
118 |
119 | if (includeDisciplinas)
120 | {
121 | query = query.Include(pe => pe.Disciplinas);
122 | }
123 |
124 | query = query.AsNoTracking()
125 | .OrderBy(professor => professor.Id)
126 | .Where(professor => professor.Id == professorId);
127 |
128 | return await query.FirstOrDefaultAsync();
129 | }
130 | }
131 | }
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Migrations/DataContextModelSnapshot.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
5 | using SmartSchool_WebAPI.Data;
6 |
7 | namespace SmartSchool_WebAPI.Migrations
8 | {
9 | [DbContext(typeof(DataContext))]
10 | partial class DataContextModelSnapshot : ModelSnapshot
11 | {
12 | protected override void BuildModel(ModelBuilder modelBuilder)
13 | {
14 | #pragma warning disable 612, 618
15 | modelBuilder
16 | .HasAnnotation("ProductVersion", "3.1.2");
17 |
18 | modelBuilder.Entity("SmartSchool_WebAPI.Models.Aluno", b =>
19 | {
20 | b.Property("id")
21 | .ValueGeneratedOnAdd()
22 | .HasColumnType("INTEGER");
23 |
24 | b.Property("nome")
25 | .HasColumnType("TEXT");
26 |
27 | b.Property("sobrenome")
28 | .HasColumnType("TEXT");
29 |
30 | b.Property("telefone")
31 | .HasColumnType("TEXT");
32 |
33 | b.HasKey("id");
34 |
35 | b.ToTable("Alunos");
36 |
37 | b.HasData(
38 | new
39 | {
40 | id = 1,
41 | nome = "Marta",
42 | sobrenome = "Kent",
43 | telefone = "33225555"
44 | },
45 | new
46 | {
47 | id = 2,
48 | nome = "Paula",
49 | sobrenome = "Isabela",
50 | telefone = "3354288"
51 | },
52 | new
53 | {
54 | id = 3,
55 | nome = "Laura",
56 | sobrenome = "Antonia",
57 | telefone = "55668899"
58 | },
59 | new
60 | {
61 | id = 4,
62 | nome = "Luiza",
63 | sobrenome = "Maria",
64 | telefone = "6565659"
65 | },
66 | new
67 | {
68 | id = 5,
69 | nome = "Lucas",
70 | sobrenome = "Machado",
71 | telefone = "565685415"
72 | },
73 | new
74 | {
75 | id = 6,
76 | nome = "Pedro",
77 | sobrenome = "Alvares",
78 | telefone = "456454545"
79 | },
80 | new
81 | {
82 | id = 7,
83 | nome = "Paulo",
84 | sobrenome = "José",
85 | telefone = "9874512"
86 | });
87 | });
88 |
89 | modelBuilder.Entity("SmartSchool_WebAPI.Models.AlunoDisciplina", b =>
90 | {
91 | b.Property("AlunoId")
92 | .HasColumnType("INTEGER");
93 |
94 | b.Property("DisciplinaId")
95 | .HasColumnType("INTEGER");
96 |
97 | b.HasKey("AlunoId", "DisciplinaId");
98 |
99 | b.HasIndex("DisciplinaId");
100 |
101 | b.ToTable("AlunosDisciplinas");
102 |
103 | b.HasData(
104 | new
105 | {
106 | AlunoId = 1,
107 | DisciplinaId = 2
108 | },
109 | new
110 | {
111 | AlunoId = 1,
112 | DisciplinaId = 4
113 | },
114 | new
115 | {
116 | AlunoId = 1,
117 | DisciplinaId = 5
118 | },
119 | new
120 | {
121 | AlunoId = 2,
122 | DisciplinaId = 1
123 | },
124 | new
125 | {
126 | AlunoId = 2,
127 | DisciplinaId = 2
128 | },
129 | new
130 | {
131 | AlunoId = 2,
132 | DisciplinaId = 5
133 | },
134 | new
135 | {
136 | AlunoId = 3,
137 | DisciplinaId = 1
138 | },
139 | new
140 | {
141 | AlunoId = 3,
142 | DisciplinaId = 2
143 | },
144 | new
145 | {
146 | AlunoId = 3,
147 | DisciplinaId = 3
148 | },
149 | new
150 | {
151 | AlunoId = 4,
152 | DisciplinaId = 1
153 | },
154 | new
155 | {
156 | AlunoId = 4,
157 | DisciplinaId = 4
158 | },
159 | new
160 | {
161 | AlunoId = 4,
162 | DisciplinaId = 5
163 | },
164 | new
165 | {
166 | AlunoId = 5,
167 | DisciplinaId = 4
168 | },
169 | new
170 | {
171 | AlunoId = 5,
172 | DisciplinaId = 5
173 | },
174 | new
175 | {
176 | AlunoId = 6,
177 | DisciplinaId = 1
178 | },
179 | new
180 | {
181 | AlunoId = 6,
182 | DisciplinaId = 2
183 | },
184 | new
185 | {
186 | AlunoId = 6,
187 | DisciplinaId = 3
188 | },
189 | new
190 | {
191 | AlunoId = 6,
192 | DisciplinaId = 4
193 | },
194 | new
195 | {
196 | AlunoId = 7,
197 | DisciplinaId = 1
198 | },
199 | new
200 | {
201 | AlunoId = 7,
202 | DisciplinaId = 2
203 | },
204 | new
205 | {
206 | AlunoId = 7,
207 | DisciplinaId = 3
208 | },
209 | new
210 | {
211 | AlunoId = 7,
212 | DisciplinaId = 4
213 | },
214 | new
215 | {
216 | AlunoId = 7,
217 | DisciplinaId = 5
218 | });
219 | });
220 |
221 | modelBuilder.Entity("SmartSchool_WebAPI.Models.Disciplina", b =>
222 | {
223 | b.Property("Id")
224 | .ValueGeneratedOnAdd()
225 | .HasColumnType("INTEGER");
226 |
227 | b.Property("Nome")
228 | .HasColumnType("TEXT");
229 |
230 | b.Property("ProfessorId")
231 | .HasColumnType("INTEGER");
232 |
233 | b.HasKey("Id");
234 |
235 | b.HasIndex("ProfessorId");
236 |
237 | b.ToTable("Disciplinas");
238 |
239 | b.HasData(
240 | new
241 | {
242 | Id = 1,
243 | Nome = "Matemática",
244 | ProfessorId = 1
245 | },
246 | new
247 | {
248 | Id = 2,
249 | Nome = "Física",
250 | ProfessorId = 2
251 | },
252 | new
253 | {
254 | Id = 3,
255 | Nome = "Português",
256 | ProfessorId = 3
257 | },
258 | new
259 | {
260 | Id = 4,
261 | Nome = "Inglês",
262 | ProfessorId = 4
263 | },
264 | new
265 | {
266 | Id = 5,
267 | Nome = "Programação",
268 | ProfessorId = 5
269 | });
270 | });
271 |
272 | modelBuilder.Entity("SmartSchool_WebAPI.Models.Professor", b =>
273 | {
274 | b.Property("id")
275 | .ValueGeneratedOnAdd()
276 | .HasColumnType("INTEGER");
277 |
278 | b.Property("nome")
279 | .HasColumnType("TEXT");
280 |
281 | b.HasKey("id");
282 |
283 | b.ToTable("Professores");
284 |
285 | b.HasData(
286 | new
287 | {
288 | id = 1,
289 | nome = "Lauro"
290 | },
291 | new
292 | {
293 | id = 2,
294 | nome = "Roberto"
295 | },
296 | new
297 | {
298 | id = 3,
299 | nome = "Ronaldo"
300 | },
301 | new
302 | {
303 | id = 4,
304 | nome = "Rodrigo"
305 | },
306 | new
307 | {
308 | id = 5,
309 | nome = "Alexandre"
310 | });
311 | });
312 |
313 | modelBuilder.Entity("SmartSchool_WebAPI.Models.AlunoDisciplina", b =>
314 | {
315 | b.HasOne("SmartSchool_WebAPI.Models.Aluno", "Aluno")
316 | .WithMany()
317 | .HasForeignKey("AlunoId")
318 | .OnDelete(DeleteBehavior.Cascade)
319 | .IsRequired();
320 |
321 | b.HasOne("SmartSchool_WebAPI.Models.Disciplina", "Disciplina")
322 | .WithMany()
323 | .HasForeignKey("DisciplinaId")
324 | .OnDelete(DeleteBehavior.Cascade)
325 | .IsRequired();
326 | });
327 |
328 | modelBuilder.Entity("SmartSchool_WebAPI.Models.Disciplina", b =>
329 | {
330 | b.HasOne("SmartSchool_WebAPI.Models.Professor", "Professor")
331 | .WithMany("Disciplinas")
332 | .HasForeignKey("ProfessorId")
333 | .OnDelete(DeleteBehavior.Cascade)
334 | .IsRequired();
335 | });
336 | #pragma warning restore 612, 618
337 | }
338 | }
339 | }
340 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Migrations/20200308234522_initial.Designer.cs:
--------------------------------------------------------------------------------
1 | //
2 | using Microsoft.EntityFrameworkCore;
3 | using Microsoft.EntityFrameworkCore.Infrastructure;
4 | using Microsoft.EntityFrameworkCore.Migrations;
5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
6 | using SmartSchool_WebAPI.Data;
7 |
8 | namespace SmartSchool_WebAPI.Migrations
9 | {
10 | [DbContext(typeof(DataContext))]
11 | [Migration("20200308234522_initial")]
12 | partial class initial
13 | {
14 | protected override void BuildTargetModel(ModelBuilder modelBuilder)
15 | {
16 | #pragma warning disable 612, 618
17 | modelBuilder
18 | .HasAnnotation("ProductVersion", "3.1.2");
19 |
20 | modelBuilder.Entity("SmartSchool_WebAPI.Models.Aluno", b =>
21 | {
22 | b.Property("id")
23 | .ValueGeneratedOnAdd()
24 | .HasColumnType("INTEGER");
25 |
26 | b.Property("nome")
27 | .HasColumnType("TEXT");
28 |
29 | b.Property("sobrenome")
30 | .HasColumnType("TEXT");
31 |
32 | b.Property("telefone")
33 | .HasColumnType("TEXT");
34 |
35 | b.HasKey("id");
36 |
37 | b.ToTable("Alunos");
38 |
39 | b.HasData(
40 | new
41 | {
42 | id = 1,
43 | nome = "Marta",
44 | sobrenome = "Kent",
45 | telefone = "33225555"
46 | },
47 | new
48 | {
49 | id = 2,
50 | nome = "Paula",
51 | sobrenome = "Isabela",
52 | telefone = "3354288"
53 | },
54 | new
55 | {
56 | id = 3,
57 | nome = "Laura",
58 | sobrenome = "Antonia",
59 | telefone = "55668899"
60 | },
61 | new
62 | {
63 | id = 4,
64 | nome = "Luiza",
65 | sobrenome = "Maria",
66 | telefone = "6565659"
67 | },
68 | new
69 | {
70 | id = 5,
71 | nome = "Lucas",
72 | sobrenome = "Machado",
73 | telefone = "565685415"
74 | },
75 | new
76 | {
77 | id = 6,
78 | nome = "Pedro",
79 | sobrenome = "Alvares",
80 | telefone = "456454545"
81 | },
82 | new
83 | {
84 | id = 7,
85 | nome = "Paulo",
86 | sobrenome = "José",
87 | telefone = "9874512"
88 | });
89 | });
90 |
91 | modelBuilder.Entity("SmartSchool_WebAPI.Models.AlunoDisciplina", b =>
92 | {
93 | b.Property("AlunoId")
94 | .HasColumnType("INTEGER");
95 |
96 | b.Property("DisciplinaId")
97 | .HasColumnType("INTEGER");
98 |
99 | b.HasKey("AlunoId", "DisciplinaId");
100 |
101 | b.HasIndex("DisciplinaId");
102 |
103 | b.ToTable("AlunosDisciplinas");
104 |
105 | b.HasData(
106 | new
107 | {
108 | AlunoId = 1,
109 | DisciplinaId = 2
110 | },
111 | new
112 | {
113 | AlunoId = 1,
114 | DisciplinaId = 4
115 | },
116 | new
117 | {
118 | AlunoId = 1,
119 | DisciplinaId = 5
120 | },
121 | new
122 | {
123 | AlunoId = 2,
124 | DisciplinaId = 1
125 | },
126 | new
127 | {
128 | AlunoId = 2,
129 | DisciplinaId = 2
130 | },
131 | new
132 | {
133 | AlunoId = 2,
134 | DisciplinaId = 5
135 | },
136 | new
137 | {
138 | AlunoId = 3,
139 | DisciplinaId = 1
140 | },
141 | new
142 | {
143 | AlunoId = 3,
144 | DisciplinaId = 2
145 | },
146 | new
147 | {
148 | AlunoId = 3,
149 | DisciplinaId = 3
150 | },
151 | new
152 | {
153 | AlunoId = 4,
154 | DisciplinaId = 1
155 | },
156 | new
157 | {
158 | AlunoId = 4,
159 | DisciplinaId = 4
160 | },
161 | new
162 | {
163 | AlunoId = 4,
164 | DisciplinaId = 5
165 | },
166 | new
167 | {
168 | AlunoId = 5,
169 | DisciplinaId = 4
170 | },
171 | new
172 | {
173 | AlunoId = 5,
174 | DisciplinaId = 5
175 | },
176 | new
177 | {
178 | AlunoId = 6,
179 | DisciplinaId = 1
180 | },
181 | new
182 | {
183 | AlunoId = 6,
184 | DisciplinaId = 2
185 | },
186 | new
187 | {
188 | AlunoId = 6,
189 | DisciplinaId = 3
190 | },
191 | new
192 | {
193 | AlunoId = 6,
194 | DisciplinaId = 4
195 | },
196 | new
197 | {
198 | AlunoId = 7,
199 | DisciplinaId = 1
200 | },
201 | new
202 | {
203 | AlunoId = 7,
204 | DisciplinaId = 2
205 | },
206 | new
207 | {
208 | AlunoId = 7,
209 | DisciplinaId = 3
210 | },
211 | new
212 | {
213 | AlunoId = 7,
214 | DisciplinaId = 4
215 | },
216 | new
217 | {
218 | AlunoId = 7,
219 | DisciplinaId = 5
220 | });
221 | });
222 |
223 | modelBuilder.Entity("SmartSchool_WebAPI.Models.Disciplina", b =>
224 | {
225 | b.Property("Id")
226 | .ValueGeneratedOnAdd()
227 | .HasColumnType("INTEGER");
228 |
229 | b.Property("Nome")
230 | .HasColumnType("TEXT");
231 |
232 | b.Property("ProfessorId")
233 | .HasColumnType("INTEGER");
234 |
235 | b.HasKey("Id");
236 |
237 | b.HasIndex("ProfessorId");
238 |
239 | b.ToTable("Disciplinas");
240 |
241 | b.HasData(
242 | new
243 | {
244 | Id = 1,
245 | Nome = "Matemática",
246 | ProfessorId = 1
247 | },
248 | new
249 | {
250 | Id = 2,
251 | Nome = "Física",
252 | ProfessorId = 2
253 | },
254 | new
255 | {
256 | Id = 3,
257 | Nome = "Português",
258 | ProfessorId = 3
259 | },
260 | new
261 | {
262 | Id = 4,
263 | Nome = "Inglês",
264 | ProfessorId = 4
265 | },
266 | new
267 | {
268 | Id = 5,
269 | Nome = "Programação",
270 | ProfessorId = 5
271 | });
272 | });
273 |
274 | modelBuilder.Entity("SmartSchool_WebAPI.Models.Professor", b =>
275 | {
276 | b.Property("id")
277 | .ValueGeneratedOnAdd()
278 | .HasColumnType("INTEGER");
279 |
280 | b.Property("nome")
281 | .HasColumnType("TEXT");
282 |
283 | b.HasKey("id");
284 |
285 | b.ToTable("Professores");
286 |
287 | b.HasData(
288 | new
289 | {
290 | id = 1,
291 | nome = "Lauro"
292 | },
293 | new
294 | {
295 | id = 2,
296 | nome = "Roberto"
297 | },
298 | new
299 | {
300 | id = 3,
301 | nome = "Ronaldo"
302 | },
303 | new
304 | {
305 | id = 4,
306 | nome = "Rodrigo"
307 | },
308 | new
309 | {
310 | id = 5,
311 | nome = "Alexandre"
312 | });
313 | });
314 |
315 | modelBuilder.Entity("SmartSchool_WebAPI.Models.AlunoDisciplina", b =>
316 | {
317 | b.HasOne("SmartSchool_WebAPI.Models.Aluno", "Aluno")
318 | .WithMany()
319 | .HasForeignKey("AlunoId")
320 | .OnDelete(DeleteBehavior.Cascade)
321 | .IsRequired();
322 |
323 | b.HasOne("SmartSchool_WebAPI.Models.Disciplina", "Disciplina")
324 | .WithMany()
325 | .HasForeignKey("DisciplinaId")
326 | .OnDelete(DeleteBehavior.Cascade)
327 | .IsRequired();
328 | });
329 |
330 | modelBuilder.Entity("SmartSchool_WebAPI.Models.Disciplina", b =>
331 | {
332 | b.HasOne("SmartSchool_WebAPI.Models.Professor", "Professor")
333 | .WithMany("Disciplinas")
334 | .HasForeignKey("ProfessorId")
335 | .OnDelete(DeleteBehavior.Cascade)
336 | .IsRequired();
337 | });
338 | #pragma warning restore 612, 618
339 | }
340 | }
341 | }
342 |
--------------------------------------------------------------------------------
/SmartSchool-WebAPI/Migrations/20200308234522_initial.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore.Migrations;
2 |
3 | namespace SmartSchool_WebAPI.Migrations
4 | {
5 | public partial class initial : Migration
6 | {
7 | protected override void Up(MigrationBuilder migrationBuilder)
8 | {
9 | migrationBuilder.CreateTable(
10 | name: "Alunos",
11 | columns: table => new
12 | {
13 | id = table.Column(nullable: false)
14 | .Annotation("Sqlite:Autoincrement", true),
15 | nome = table.Column(nullable: true),
16 | sobrenome = table.Column(nullable: true),
17 | telefone = table.Column(nullable: true)
18 | },
19 | constraints: table =>
20 | {
21 | table.PrimaryKey("PK_Alunos", x => x.id);
22 | });
23 |
24 | migrationBuilder.CreateTable(
25 | name: "Professores",
26 | columns: table => new
27 | {
28 | id = table.Column(nullable: false)
29 | .Annotation("Sqlite:Autoincrement", true),
30 | nome = table.Column(nullable: true)
31 | },
32 | constraints: table =>
33 | {
34 | table.PrimaryKey("PK_Professores", x => x.id);
35 | });
36 |
37 | migrationBuilder.CreateTable(
38 | name: "Disciplinas",
39 | columns: table => new
40 | {
41 | Id = table.Column(nullable: false)
42 | .Annotation("Sqlite:Autoincrement", true),
43 | Nome = table.Column(nullable: true),
44 | ProfessorId = table.Column(nullable: false)
45 | },
46 | constraints: table =>
47 | {
48 | table.PrimaryKey("PK_Disciplinas", x => x.Id);
49 | table.ForeignKey(
50 | name: "FK_Disciplinas_Professores_ProfessorId",
51 | column: x => x.ProfessorId,
52 | principalTable: "Professores",
53 | principalColumn: "id",
54 | onDelete: ReferentialAction.Cascade);
55 | });
56 |
57 | migrationBuilder.CreateTable(
58 | name: "AlunosDisciplinas",
59 | columns: table => new
60 | {
61 | AlunoId = table.Column(nullable: false),
62 | DisciplinaId = table.Column(nullable: false)
63 | },
64 | constraints: table =>
65 | {
66 | table.PrimaryKey("PK_AlunosDisciplinas", x => new { x.AlunoId, x.DisciplinaId });
67 | table.ForeignKey(
68 | name: "FK_AlunosDisciplinas_Alunos_AlunoId",
69 | column: x => x.AlunoId,
70 | principalTable: "Alunos",
71 | principalColumn: "id",
72 | onDelete: ReferentialAction.Cascade);
73 | table.ForeignKey(
74 | name: "FK_AlunosDisciplinas_Disciplinas_DisciplinaId",
75 | column: x => x.DisciplinaId,
76 | principalTable: "Disciplinas",
77 | principalColumn: "Id",
78 | onDelete: ReferentialAction.Cascade);
79 | });
80 |
81 | migrationBuilder.InsertData(
82 | table: "Alunos",
83 | columns: new[] { "id", "nome", "sobrenome", "telefone" },
84 | values: new object[] { 1, "Marta", "Kent", "33225555" });
85 |
86 | migrationBuilder.InsertData(
87 | table: "Alunos",
88 | columns: new[] { "id", "nome", "sobrenome", "telefone" },
89 | values: new object[] { 2, "Paula", "Isabela", "3354288" });
90 |
91 | migrationBuilder.InsertData(
92 | table: "Alunos",
93 | columns: new[] { "id", "nome", "sobrenome", "telefone" },
94 | values: new object[] { 3, "Laura", "Antonia", "55668899" });
95 |
96 | migrationBuilder.InsertData(
97 | table: "Alunos",
98 | columns: new[] { "id", "nome", "sobrenome", "telefone" },
99 | values: new object[] { 4, "Luiza", "Maria", "6565659" });
100 |
101 | migrationBuilder.InsertData(
102 | table: "Alunos",
103 | columns: new[] { "id", "nome", "sobrenome", "telefone" },
104 | values: new object[] { 5, "Lucas", "Machado", "565685415" });
105 |
106 | migrationBuilder.InsertData(
107 | table: "Alunos",
108 | columns: new[] { "id", "nome", "sobrenome", "telefone" },
109 | values: new object[] { 6, "Pedro", "Alvares", "456454545" });
110 |
111 | migrationBuilder.InsertData(
112 | table: "Alunos",
113 | columns: new[] { "id", "nome", "sobrenome", "telefone" },
114 | values: new object[] { 7, "Paulo", "José", "9874512" });
115 |
116 | migrationBuilder.InsertData(
117 | table: "Professores",
118 | columns: new[] { "id", "nome" },
119 | values: new object[] { 1, "Lauro" });
120 |
121 | migrationBuilder.InsertData(
122 | table: "Professores",
123 | columns: new[] { "id", "nome" },
124 | values: new object[] { 2, "Roberto" });
125 |
126 | migrationBuilder.InsertData(
127 | table: "Professores",
128 | columns: new[] { "id", "nome" },
129 | values: new object[] { 3, "Ronaldo" });
130 |
131 | migrationBuilder.InsertData(
132 | table: "Professores",
133 | columns: new[] { "id", "nome" },
134 | values: new object[] { 4, "Rodrigo" });
135 |
136 | migrationBuilder.InsertData(
137 | table: "Professores",
138 | columns: new[] { "id", "nome" },
139 | values: new object[] { 5, "Alexandre" });
140 |
141 | migrationBuilder.InsertData(
142 | table: "Disciplinas",
143 | columns: new[] { "Id", "Nome", "ProfessorId" },
144 | values: new object[] { 1, "Matemática", 1 });
145 |
146 | migrationBuilder.InsertData(
147 | table: "Disciplinas",
148 | columns: new[] { "Id", "Nome", "ProfessorId" },
149 | values: new object[] { 2, "Física", 2 });
150 |
151 | migrationBuilder.InsertData(
152 | table: "Disciplinas",
153 | columns: new[] { "Id", "Nome", "ProfessorId" },
154 | values: new object[] { 3, "Português", 3 });
155 |
156 | migrationBuilder.InsertData(
157 | table: "Disciplinas",
158 | columns: new[] { "Id", "Nome", "ProfessorId" },
159 | values: new object[] { 4, "Inglês", 4 });
160 |
161 | migrationBuilder.InsertData(
162 | table: "Disciplinas",
163 | columns: new[] { "Id", "Nome", "ProfessorId" },
164 | values: new object[] { 5, "Programação", 5 });
165 |
166 | migrationBuilder.InsertData(
167 | table: "AlunosDisciplinas",
168 | columns: new[] { "AlunoId", "DisciplinaId" },
169 | values: new object[] { 2, 1 });
170 |
171 | migrationBuilder.InsertData(
172 | table: "AlunosDisciplinas",
173 | columns: new[] { "AlunoId", "DisciplinaId" },
174 | values: new object[] { 4, 5 });
175 |
176 | migrationBuilder.InsertData(
177 | table: "AlunosDisciplinas",
178 | columns: new[] { "AlunoId", "DisciplinaId" },
179 | values: new object[] { 2, 5 });
180 |
181 | migrationBuilder.InsertData(
182 | table: "AlunosDisciplinas",
183 | columns: new[] { "AlunoId", "DisciplinaId" },
184 | values: new object[] { 1, 5 });
185 |
186 | migrationBuilder.InsertData(
187 | table: "AlunosDisciplinas",
188 | columns: new[] { "AlunoId", "DisciplinaId" },
189 | values: new object[] { 7, 4 });
190 |
191 | migrationBuilder.InsertData(
192 | table: "AlunosDisciplinas",
193 | columns: new[] { "AlunoId", "DisciplinaId" },
194 | values: new object[] { 6, 4 });
195 |
196 | migrationBuilder.InsertData(
197 | table: "AlunosDisciplinas",
198 | columns: new[] { "AlunoId", "DisciplinaId" },
199 | values: new object[] { 5, 4 });
200 |
201 | migrationBuilder.InsertData(
202 | table: "AlunosDisciplinas",
203 | columns: new[] { "AlunoId", "DisciplinaId" },
204 | values: new object[] { 4, 4 });
205 |
206 | migrationBuilder.InsertData(
207 | table: "AlunosDisciplinas",
208 | columns: new[] { "AlunoId", "DisciplinaId" },
209 | values: new object[] { 1, 4 });
210 |
211 | migrationBuilder.InsertData(
212 | table: "AlunosDisciplinas",
213 | columns: new[] { "AlunoId", "DisciplinaId" },
214 | values: new object[] { 7, 3 });
215 |
216 | migrationBuilder.InsertData(
217 | table: "AlunosDisciplinas",
218 | columns: new[] { "AlunoId", "DisciplinaId" },
219 | values: new object[] { 5, 5 });
220 |
221 | migrationBuilder.InsertData(
222 | table: "AlunosDisciplinas",
223 | columns: new[] { "AlunoId", "DisciplinaId" },
224 | values: new object[] { 6, 3 });
225 |
226 | migrationBuilder.InsertData(
227 | table: "AlunosDisciplinas",
228 | columns: new[] { "AlunoId", "DisciplinaId" },
229 | values: new object[] { 7, 2 });
230 |
231 | migrationBuilder.InsertData(
232 | table: "AlunosDisciplinas",
233 | columns: new[] { "AlunoId", "DisciplinaId" },
234 | values: new object[] { 6, 2 });
235 |
236 | migrationBuilder.InsertData(
237 | table: "AlunosDisciplinas",
238 | columns: new[] { "AlunoId", "DisciplinaId" },
239 | values: new object[] { 3, 2 });
240 |
241 | migrationBuilder.InsertData(
242 | table: "AlunosDisciplinas",
243 | columns: new[] { "AlunoId", "DisciplinaId" },
244 | values: new object[] { 2, 2 });
245 |
246 | migrationBuilder.InsertData(
247 | table: "AlunosDisciplinas",
248 | columns: new[] { "AlunoId", "DisciplinaId" },
249 | values: new object[] { 1, 2 });
250 |
251 | migrationBuilder.InsertData(
252 | table: "AlunosDisciplinas",
253 | columns: new[] { "AlunoId", "DisciplinaId" },
254 | values: new object[] { 7, 1 });
255 |
256 | migrationBuilder.InsertData(
257 | table: "AlunosDisciplinas",
258 | columns: new[] { "AlunoId", "DisciplinaId" },
259 | values: new object[] { 6, 1 });
260 |
261 | migrationBuilder.InsertData(
262 | table: "AlunosDisciplinas",
263 | columns: new[] { "AlunoId", "DisciplinaId" },
264 | values: new object[] { 4, 1 });
265 |
266 | migrationBuilder.InsertData(
267 | table: "AlunosDisciplinas",
268 | columns: new[] { "AlunoId", "DisciplinaId" },
269 | values: new object[] { 3, 1 });
270 |
271 | migrationBuilder.InsertData(
272 | table: "AlunosDisciplinas",
273 | columns: new[] { "AlunoId", "DisciplinaId" },
274 | values: new object[] { 3, 3 });
275 |
276 | migrationBuilder.InsertData(
277 | table: "AlunosDisciplinas",
278 | columns: new[] { "AlunoId", "DisciplinaId" },
279 | values: new object[] { 7, 5 });
280 |
281 | migrationBuilder.CreateIndex(
282 | name: "IX_AlunosDisciplinas_DisciplinaId",
283 | table: "AlunosDisciplinas",
284 | column: "DisciplinaId");
285 |
286 | migrationBuilder.CreateIndex(
287 | name: "IX_Disciplinas_ProfessorId",
288 | table: "Disciplinas",
289 | column: "ProfessorId");
290 | }
291 |
292 | protected override void Down(MigrationBuilder migrationBuilder)
293 | {
294 | migrationBuilder.DropTable(
295 | name: "AlunosDisciplinas");
296 |
297 | migrationBuilder.DropTable(
298 | name: "Alunos");
299 |
300 | migrationBuilder.DropTable(
301 | name: "Disciplinas");
302 |
303 | migrationBuilder.DropTable(
304 | name: "Professores");
305 | }
306 | }
307 | }
308 |
--------------------------------------------------------------------------------