├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── Readme.md ├── SmartSchool.WebAPI ├── Data │ ├── IRepository.cs │ ├── Repository.cs │ └── SmartContext.cs ├── Dockerfile ├── Helpers │ ├── DateTimeExtensions.cs │ ├── Extensions.cs │ ├── PageList.cs │ ├── PageParams.cs │ └── PaginationHeader.cs ├── Migrations │ ├── 20201005185632_initMySql.Designer.cs │ ├── 20201005185632_initMySql.cs │ └── SmartContextModelSnapshot.cs ├── Models │ ├── Aluno.cs │ ├── AlunoCurso.cs │ ├── AlunoDisciplina.cs │ ├── Curso.cs │ ├── Disciplina.cs │ └── Professor.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── SmartSchool.WebAPI.csproj ├── SmartSchool.WebAPI.xml ├── SmartSchool.db ├── Startup.cs ├── V1 │ ├── Controllers │ │ ├── AlunoController.cs │ │ └── ProfessorController.cs │ ├── Dtos │ │ ├── AlunoDto.cs │ │ ├── AlunoPatchDto.cs │ │ ├── AlunoRegistrarDto.cs │ │ ├── CursoDto.cs │ │ ├── DisciplinaDto.cs │ │ ├── ProfessorDto.cs │ │ ├── ProfessorRegistrarDto.cs │ │ └── TrocaEstadoDto.cs │ └── Profiles │ │ └── SmartSchoolProfile.cs ├── V2 │ ├── Controllers │ │ └── AlunoController.cs │ ├── Dtos │ │ ├── AlunoDto.cs │ │ └── AlunoRegistrarDto.cs │ └── Profiles │ │ └── SmartSchoolProfile.cs ├── appsettings.Development.json ├── appsettings.json └── docker-compose.yml ├── SmartSchool.sln └── SmartSchoolApp ├── .browserslistrc ├── .editorconfig ├── .gitignore ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── components │ │ ├── alunos │ │ │ ├── alunos.component.css │ │ │ ├── alunos.component.html │ │ │ ├── alunos.component.spec.ts │ │ │ ├── alunos.component.ts │ │ │ └── professores-alunos │ │ │ │ ├── professores-alunos.component.css │ │ │ │ ├── professores-alunos.component.html │ │ │ │ ├── professores-alunos.component.spec.ts │ │ │ │ └── professores-alunos.component.ts │ │ ├── dashboard │ │ │ ├── dashboard.component.css │ │ │ ├── dashboard.component.html │ │ │ ├── dashboard.component.spec.ts │ │ │ └── dashboard.component.ts │ │ ├── perfil │ │ │ ├── perfil.component.css │ │ │ ├── perfil.component.html │ │ │ ├── perfil.component.spec.ts │ │ │ └── perfil.component.ts │ │ ├── professores │ │ │ ├── alunos-professores │ │ │ │ ├── alunos-professores.component.css │ │ │ │ ├── alunos-professores.component.html │ │ │ │ ├── alunos-professores.component.spec.ts │ │ │ │ └── alunos-professores.component.ts │ │ │ ├── professor-detalhe │ │ │ │ ├── professor-detalhe.component.css │ │ │ │ ├── professor-detalhe.component.html │ │ │ │ ├── professor-detalhe.component.spec.ts │ │ │ │ └── professor-detalhe.component.ts │ │ │ ├── professores.component.css │ │ │ ├── professores.component.html │ │ │ ├── professores.component.spec.ts │ │ │ └── professores.component.ts │ │ └── shared │ │ │ ├── nav │ │ │ ├── nav.component.css │ │ │ ├── nav.component.html │ │ │ ├── nav.component.spec.ts │ │ │ └── nav.component.ts │ │ │ └── titulo │ │ │ ├── titulo.component.css │ │ │ ├── titulo.component.html │ │ │ ├── titulo.component.spec.ts │ │ │ └── titulo.component.ts │ ├── models │ │ ├── Aluno.ts │ │ ├── Disciplina.ts │ │ ├── Pagination.ts │ │ └── Professor.ts │ ├── services │ │ ├── aluno.service.spec.ts │ │ ├── aluno.service.ts │ │ ├── professor.service.spec.ts │ │ └── professor.service.ts │ └── util │ │ └── util.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── main.ts ├── polyfills.ts ├── styles.css └── test.ts ├── tsconfig.app.json ├── tsconfig.base.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | ## macbook 7 | .DC_Store 8 | 9 | # User-specific files 10 | *.rsuser 11 | *.suo 12 | *.user 13 | *.userosscache 14 | *.sln.docstates 15 | 16 | # User-specific files (MonoDevelop/Xamarin Studio) 17 | *.userprefs 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | 33 | # Visual Studio 2015/2017 cache/options directory 34 | .vs/ 35 | # Uncomment if you have tasks that create the project's static files in wwwroot 36 | #wwwroot/ 37 | 38 | # Visual Studio 2017 auto generated files 39 | Generated\ Files/ 40 | 41 | # MSTest test Results 42 | [Tt]est[Rr]esult*/ 43 | [Bb]uild[Ll]og.* 44 | 45 | # NUNIT 46 | *.VisualState.xml 47 | TestResult.xml 48 | 49 | # Build Results of an ATL Project 50 | [Dd]ebugPS/ 51 | [Rr]eleasePS/ 52 | dlldata.c 53 | 54 | # Benchmark Results 55 | BenchmarkDotNet.Artifacts/ 56 | 57 | # .NET Core 58 | project.lock.json 59 | project.fragment.lock.json 60 | artifacts/ 61 | 62 | # StyleCop 63 | StyleCopReport.xml 64 | 65 | # Files built by Visual Studio 66 | *_i.c 67 | *_p.c 68 | *_h.h 69 | *.ilk 70 | *.meta 71 | *.obj 72 | *.iobj 73 | *.pch 74 | *.pdb 75 | *.ipdb 76 | *.pgc 77 | *.pgd 78 | *.rsp 79 | *.sbr 80 | *.tlb 81 | *.tli 82 | *.tlh 83 | *.tmp 84 | *.tmp_proj 85 | *_wpftmp.csproj 86 | *.log 87 | *.vspscc 88 | *.vssscc 89 | .builds 90 | *.pidb 91 | *.svclog 92 | *.scc 93 | 94 | # Chutzpah Test files 95 | _Chutzpah* 96 | 97 | # Visual C++ cache files 98 | ipch/ 99 | *.aps 100 | *.ncb 101 | *.opendb 102 | *.opensdf 103 | *.sdf 104 | *.cachefile 105 | *.VC.db 106 | *.VC.VC.opendb 107 | 108 | # Visual Studio profiler 109 | *.psess 110 | *.vsp 111 | *.vspx 112 | *.sap 113 | 114 | # Visual Studio Trace Files 115 | *.e2e 116 | 117 | # TFS 2012 Local Workspace 118 | $tf/ 119 | 120 | # Guidance Automation Toolkit 121 | *.gpState 122 | 123 | # ReSharper is a .NET coding add-in 124 | _ReSharper*/ 125 | *.[Rr]e[Ss]harper 126 | *.DotSettings.user 127 | 128 | # JustCode is a .NET coding add-in 129 | .JustCode 130 | 131 | # TeamCity is a build add-in 132 | _TeamCity* 133 | 134 | # DotCover is a Code Coverage Tool 135 | *.dotCover 136 | 137 | # AxoCover is a Code Coverage Tool 138 | .axoCover/* 139 | !.axoCover/settings.json 140 | 141 | # Visual Studio code coverage results 142 | *.coverage 143 | *.coveragexml 144 | 145 | # NCrunch 146 | _NCrunch_* 147 | .*crunch*.local.xml 148 | nCrunchTemp_* 149 | 150 | # MightyMoose 151 | *.mm.* 152 | AutoTest.Net/ 153 | 154 | # Web workbench (sass) 155 | .sass-cache/ 156 | 157 | # Installshield output folder 158 | [Ee]xpress/ 159 | 160 | # DocProject is a documentation generator add-in 161 | DocProject/buildhelp/ 162 | DocProject/Help/*.HxT 163 | DocProject/Help/*.HxC 164 | DocProject/Help/*.hhc 165 | DocProject/Help/*.hhk 166 | DocProject/Help/*.hhp 167 | DocProject/Help/Html2 168 | DocProject/Help/html 169 | 170 | # Click-Once directory 171 | publish/ 172 | 173 | # Publish Web Output 174 | *.[Pp]ublish.xml 175 | *.azurePubxml 176 | # Note: Comment the next line if you want to checkin your web deploy settings, 177 | # but database connection strings (with potential passwords) will be unencrypted 178 | *.pubxml 179 | *.publishproj 180 | 181 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 182 | # checkin your Azure Web App publish settings, but sensitive information contained 183 | # in these scripts will be unencrypted 184 | PublishScripts/ 185 | 186 | # NuGet Packages 187 | *.nupkg 188 | # The packages folder can be ignored because of Package Restore 189 | **/[Pp]ackages/* 190 | # except build/, which is used as an MSBuild target. 191 | !**/[Pp]ackages/build/ 192 | # Uncomment if necessary however generally it will be regenerated when needed 193 | #!**/[Pp]ackages/repositories.config 194 | # NuGet v3's project.json files produces more ignorable files 195 | *.nuget.props 196 | *.nuget.targets 197 | 198 | # Microsoft Azure Build Output 199 | csx/ 200 | *.build.csdef 201 | 202 | # Microsoft Azure Emulator 203 | ecf/ 204 | rcf/ 205 | 206 | # Windows Store app package directories and files 207 | AppPackages/ 208 | BundleArtifacts/ 209 | Package.StoreAssociation.xml 210 | _pkginfo.txt 211 | *.appx 212 | 213 | # Visual Studio cache files 214 | # files ending in .cache can be ignored 215 | *.[Cc]ache 216 | # but keep track of directories ending in .cache 217 | !?*.[Cc]ache/ 218 | 219 | # Others 220 | ClientBin/ 221 | ~$* 222 | *~ 223 | *.dbmdl 224 | *.dbproj.schemaview 225 | *.jfm 226 | *.pfx 227 | *.publishsettings 228 | orleans.codegen.cs 229 | 230 | # Including strong name files can present a security risk 231 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 232 | #*.snk 233 | 234 | # Since there are multiple workflows, uncomment next line to ignore bower_components 235 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 236 | #bower_components/ 237 | 238 | # RIA/Silverlight projects 239 | Generated_Code/ 240 | 241 | # Backup & report files from converting an old project file 242 | # to a newer Visual Studio version. Backup files are not needed, 243 | # because we have git ;-) 244 | _UpgradeReport_Files/ 245 | Backup*/ 246 | UpgradeLog*.XML 247 | UpgradeLog*.htm 248 | ServiceFabricBackup/ 249 | *.rptproj.bak 250 | 251 | # SQL Server files 252 | *.mdf 253 | *.ldf 254 | *.ndf 255 | 256 | # Business Intelligence projects 257 | *.rdl.data 258 | *.bim.layout 259 | *.bim_*.settings 260 | *.rptproj.rsuser 261 | *- Backup*.rdl 262 | 263 | # Microsoft Fakes 264 | FakesAssemblies/ 265 | 266 | # GhostDoc plugin setting file 267 | *.GhostDoc.xml 268 | 269 | # Node.js Tools for Visual Studio 270 | .ntvs_analysis.dat 271 | node_modules/ 272 | 273 | # Visual Studio 6 build log 274 | *.plg 275 | 276 | # Visual Studio 6 workspace options file 277 | *.opt 278 | 279 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 280 | *.vbw 281 | 282 | # Visual Studio LightSwitch build output 283 | **/*.HTMLClient/GeneratedArtifacts 284 | **/*.DesktopClient/GeneratedArtifacts 285 | **/*.DesktopClient/ModelManifest.xml 286 | **/*.Server/GeneratedArtifacts 287 | **/*.Server/ModelManifest.xml 288 | _Pvt_Extensions 289 | 290 | # Paket dependency manager 291 | .paket/paket.exe 292 | paket-files/ 293 | 294 | # FAKE - F# Make 295 | .fake/ 296 | 297 | # JetBrains Rider 298 | .idea/ 299 | *.sln.iml 300 | 301 | # CodeRush personal settings 302 | .cr/personal 303 | 304 | # Python Tools for Visual Studio (PTVS) 305 | __pycache__/ 306 | *.pyc 307 | 308 | # Cake - Uncomment if you are using it 309 | # tools/** 310 | # !tools/packages.config 311 | 312 | # Tabs Studio 313 | *.tss 314 | 315 | # Telerik's JustMock configuration file 316 | *.jmconfig 317 | 318 | # BizTalk build output 319 | *.btp.cs 320 | *.btm.cs 321 | *.odx.cs 322 | *.xsd.cs 323 | 324 | # OpenCover UI analysis results 325 | OpenCover/ 326 | 327 | # Azure Stream Analytics local run output 328 | ASALocalRun/ 329 | 330 | # MSBuild Binary and Structured Log 331 | *.binlog 332 | 333 | # NVidia Nsight GPU debugger configuration file 334 | *.nvuser 335 | 336 | # MFractors (Xamarin productivity tool) working folder 337 | .mfractor/ 338 | 339 | # Local History for Visual Studio 340 | .localhistory/ 341 | 342 | # BeatPulse healthcheck temp database 343 | healthchecksdb -------------------------------------------------------------------------------- /.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 | "name": ".NET Core Launch (web)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/SmartSchool.WebAPI/bin/Debug/netcoreapp3.1/SmartSchool.WebAPI.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/SmartSchool.WebAPI", 16 | "stopAtEntry": false, 17 | // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser 18 | "serverReadyAction": { 19 | "action": "openExternally", 20 | "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)" 21 | }, 22 | "env": { 23 | "ASPNETCORE_ENVIRONMENT": "Development" 24 | }, 25 | "sourceFileMap": { 26 | "/Views": "${workspaceFolder}/Views" 27 | } 28 | }, 29 | { 30 | "name": ".NET Core Attach", 31 | "type": "coreclr", 32 | "request": "attach", 33 | "processId": "${command:pickProcess}" 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 | } -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | ## Udemy Course 2 | 3 | ### Crie uma Web API com Asp.NET Core 3.1 + EF Core 3.1 + Docker [Course](https://www.udemy.com/course/criando-web-api-com-aspnet-core-31-ef-core-31/). 4 | 5 | This is all of the files for our Course about Asp.net Core WebAPI, EF Core, Docker, Angular and More 6 | 7 | The Summary is: 10 Sections • 116 Lessons • Total Duration: 14h 14m 8 | 9 | 01. Ferramentas e Sugestões 10 | 02. HTTP, REST, JSON e MVC 11 | 03. Projeto .NET Core 12 | 04. Introdução a EF Core 13 | 05. Repositório 14 | 06. DTO e AutoMapper 15 | 07. Swagger 16 | 08. Task, Paginação e Filtros 17 | 09. Docker (.NET Core e MySQL) 18 | 10. Angular e .NET Core Web API 19 | 20 | If you want to see this link course, really in action [original site](https://www.programadamente.com). 21 | 22 | ## Basic Setup 23 | 24 | 1. [Install Node.js](https://nodejs.org/) 25 | 1. [Install .NET Core 3.1](https://dotnet.microsoft.com/download/) 26 | 2. Fork the [AspNetCoreWebAPI](https://github.com/vsandrade/AspNetCoreWebAPI/fork) 27 | 3. Clone the repo you just forked. 28 | 29 | ## User Settings 30 | 31 | ``` 32 | # Site settings 33 | title: Vinícius de Andrade - Professor and Senior Software Engineer 34 | description: A Course about [Asp.NET Core, EF Core and Docker + Angular] 35 | 36 | # User settings 37 | There're not settings exactly, only files to guide you understand a little bit more about Angular, WebAPI and More 38 | ``` 39 | 40 | ## Questions 41 | 42 | Having a problem getting something to work or want to know why I setup something in a certain way? Ping me on Twitter [@ozirispc](https://twitter.com/ozirispc) or Message on [Facebook](http://facebook.com/ozirispc) 43 | 44 | 45 | ## Donation 46 | 47 | If you liked my work, [subscribe on Programadamente youtube Channel](https://www.youtube.com/user/ozirispc?sub_confirmation=1) 48 | 49 | ## License 50 | 51 | This theme is free and open source software, distributed under the The MIT License. So feel free to use this files on your site without linking back to me or using a disclaimer. 52 | 53 | If you’d like to give me credit somewhere on your blog or tweet a shout out to [@ozirispc](https://twitter.com/ozirispc), that would be pretty sweet. 54 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Data/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using SmartSchool.WebAPI.Helpers; 4 | using SmartSchool.WebAPI.Models; 5 | 6 | namespace SmartSchool.WebAPI.Data 7 | { 8 | public interface IRepository 9 | { 10 | void Add(T entity) where T : class; 11 | void Update(T entity) where T : class; 12 | void Delete(T entity) where T : class; 13 | bool SaveChanges(); 14 | 15 | // Aluno 16 | Task> GetAllAlunosAsync(PageParams pageParams, bool includeProfessor = false); 17 | Aluno[] GetAllAlunos(bool includeProfessor = false); 18 | Task GetAllAlunosByDisciplinaIdAsync(int disciplinaId, bool includeProfessor = false); 19 | Aluno GetAlunoById(int alunoId, bool includeProfessor = false); 20 | 21 | // professor 22 | Professor[] GetAllProfessores(bool includeAlunos = false); 23 | Professor[] GetAllProfessoresByDisciplinaId(int disciplinaId, bool includeAlunos = false); 24 | Professor GetProfessorById(int professorId, bool includeAlunos = false); 25 | Professor[] GetProfessoresByAlunoId(int alunoId, bool includeAlunos = false); 26 | } 27 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Data/Repository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using Microsoft.EntityFrameworkCore; 5 | using SmartSchool.WebAPI.Helpers; 6 | using SmartSchool.WebAPI.Models; 7 | 8 | namespace SmartSchool.WebAPI.Data 9 | { 10 | public class Repository : IRepository 11 | { 12 | private readonly SmartContext _context; 13 | public Repository(SmartContext context) 14 | { 15 | _context = context; 16 | } 17 | 18 | public void Add(T entity) where T : class 19 | { 20 | _context.Add(entity); 21 | } 22 | 23 | public void Update(T entity) where T : class 24 | { 25 | _context.Update(entity); 26 | } 27 | 28 | public void Delete(T entity) where T : class 29 | { 30 | _context.Remove(entity); 31 | } 32 | 33 | public bool SaveChanges() 34 | { 35 | return (_context.SaveChanges() > 0); 36 | } 37 | 38 | public async Task> GetAllAlunosAsync(PageParams pageParams, bool includeProfessor = false) 39 | { 40 | IQueryable query = _context.Alunos; 41 | 42 | if (includeProfessor) 43 | { 44 | query = query.Include(a => a.AlunosDisciplinas) 45 | .ThenInclude(ad => ad.Disciplina) 46 | .ThenInclude(d => d.Professor); 47 | } 48 | 49 | query = query.AsNoTracking().OrderBy(a => a.Id); 50 | 51 | if (!string.IsNullOrEmpty(pageParams.Nome)) 52 | query = query.Where(aluno => aluno.Nome 53 | .ToUpper() 54 | .Contains(pageParams.Nome.ToUpper()) || 55 | aluno.Sobrenome 56 | .ToUpper() 57 | .Contains(pageParams.Nome.ToUpper())); 58 | 59 | if (pageParams.Matricula > 0) 60 | query = query.Where(aluno => aluno.Matricula == pageParams.Matricula); 61 | 62 | if (pageParams.Ativo != null) 63 | query = query.Where(aluno => aluno.Ativo == (pageParams.Ativo != 0)); 64 | 65 | // return await query.ToListAsync(); 66 | return await PageList.CreateAsync(query, pageParams.PageNumber, pageParams.PageSize); 67 | } 68 | 69 | public Aluno[] GetAllAlunos(bool includeProfessor = false) 70 | { 71 | IQueryable query = _context.Alunos; 72 | 73 | if (includeProfessor) 74 | { 75 | query = query.Include(a => a.AlunosDisciplinas) 76 | .ThenInclude(ad => ad.Disciplina) 77 | .ThenInclude(d => d.Professor); 78 | } 79 | 80 | query = query.AsNoTracking().OrderBy(a => a.Id); 81 | 82 | return query.ToArray(); 83 | } 84 | 85 | public async Task GetAllAlunosByDisciplinaIdAsync(int disciplinaId, bool includeProfessor = false) 86 | { 87 | IQueryable query = _context.Alunos; 88 | 89 | if (includeProfessor) 90 | { 91 | query = query.Include(a => a.AlunosDisciplinas) 92 | .ThenInclude(ad => ad.Disciplina) 93 | .ThenInclude(d => d.Professor); 94 | } 95 | 96 | query = query.AsNoTracking() 97 | .OrderBy(a => a.Id) 98 | .Where(aluno => aluno.AlunosDisciplinas.Any(ad => ad.DisciplinaId == disciplinaId)); 99 | 100 | return await query.ToArrayAsync(); 101 | } 102 | 103 | public Aluno GetAlunoById(int alunoId, bool includeProfessor = false) 104 | { 105 | IQueryable query = _context.Alunos; 106 | 107 | if (includeProfessor) 108 | { 109 | query = query.Include(a => a.AlunosDisciplinas) 110 | .ThenInclude(ad => ad.Disciplina) 111 | .ThenInclude(d => d.Professor); 112 | } 113 | 114 | query = query.AsNoTracking() 115 | .OrderBy(a => a.Id) 116 | .Where(aluno => aluno.Id == alunoId); 117 | 118 | return query.FirstOrDefault(); 119 | } 120 | 121 | public Professor[] GetAllProfessores(bool includeAlunos = false) 122 | { 123 | IQueryable query = _context.Professores; 124 | 125 | if (includeAlunos) 126 | { 127 | query = query.Include(p => p.Disciplinas) 128 | .ThenInclude(d => d.AlunosDisciplinas) 129 | .ThenInclude(ad => ad.Aluno); 130 | } 131 | 132 | query = query.AsNoTracking().OrderBy(p => p.Id); 133 | 134 | return query.ToArray(); 135 | } 136 | 137 | public Professor[] GetAllProfessoresByDisciplinaId(int disciplinaId, bool includeAlunos = false) 138 | { 139 | IQueryable query = _context.Professores; 140 | 141 | if (includeAlunos) 142 | { 143 | query = query.Include(p => p.Disciplinas) 144 | .ThenInclude(d => d.AlunosDisciplinas) 145 | .ThenInclude(ad => ad.Aluno); 146 | } 147 | 148 | query = query.AsNoTracking() 149 | .OrderBy(aluno => aluno.Id) 150 | .Where(aluno => aluno.Disciplinas.Any( 151 | d => d.AlunosDisciplinas.Any(ad => ad.DisciplinaId == disciplinaId) 152 | )); 153 | 154 | return query.ToArray(); 155 | } 156 | 157 | public Professor GetProfessorById(int professorId, bool includeAluno = false) 158 | { 159 | IQueryable query = _context.Professores; 160 | 161 | if (includeAluno) 162 | { 163 | query = query.Include(p => p.Disciplinas) 164 | .ThenInclude(d => d.AlunosDisciplinas) 165 | .ThenInclude(ad => ad.Aluno); 166 | } 167 | 168 | query = query.AsNoTracking() 169 | .OrderBy(a => a.Id) 170 | .Where(professor => professor.Id == professorId); 171 | 172 | return query.FirstOrDefault(); 173 | } 174 | 175 | public Professor[] GetProfessoresByAlunoId(int alunoId, bool includeAlunos = false) 176 | { 177 | IQueryable query = _context.Professores; 178 | 179 | if (includeAlunos) 180 | { 181 | query = query.Include(p => p.Disciplinas) 182 | .ThenInclude(d => d.AlunosDisciplinas) 183 | .ThenInclude(ad => ad.Aluno); 184 | } 185 | 186 | query = query.AsNoTracking() 187 | .OrderBy(a => a.Id) 188 | .Where(aluno => aluno.Disciplinas.Any( 189 | d => d.AlunosDisciplinas.Any(ad => ad.AlunoId == alunoId) 190 | )); 191 | 192 | return query.ToArray(); 193 | } 194 | } 195 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Data/SmartContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Microsoft.EntityFrameworkCore; 4 | using SmartSchool.WebAPI.Models; 5 | 6 | namespace SmartSchool.WebAPI.Data 7 | { 8 | public class SmartContext : DbContext 9 | { 10 | public SmartContext(DbContextOptions options) : base(options) { } 11 | public DbSet Alunos { get; set; } 12 | public DbSet AlunosCursos { get; set; } 13 | public DbSet AlunosDisciplinas { get; set; } 14 | public DbSet Cursos { get; set; } 15 | public DbSet Disciplinas { get; set; } 16 | public DbSet Professores { get; set; } 17 | 18 | 19 | protected override void OnModelCreating(ModelBuilder builder) 20 | { 21 | builder.Entity() 22 | .HasKey(AD => new {AD.AlunoId, AD.DisciplinaId}); 23 | 24 | builder.Entity() 25 | .HasKey(AD => new {AD.AlunoId, AD.CursoId}); 26 | 27 | builder.Entity() 28 | .HasData(new List(){ 29 | new Professor(1, 1, "Lauro", "Oliveira"), 30 | new Professor(2, 2, "Roberto", "Soares"), 31 | new Professor(3, 3, "Ronaldo", "Marconi"), 32 | new Professor(4, 4, "Rodrigo", "Carvalho"), 33 | new Professor(5, 5, "Alexandre", "Montanha"), 34 | }); 35 | 36 | builder.Entity() 37 | .HasData(new List{ 38 | new Curso(1, "Tecnologia da Informação"), 39 | new Curso(2, "Sistemas de Informação"), 40 | new Curso(3, "Ciência da Computação") 41 | }); 42 | 43 | builder.Entity() 44 | .HasData(new List{ 45 | new Disciplina(1, "Matemática", 1, 1), 46 | new Disciplina(2, "Matemática", 1, 3), 47 | new Disciplina(3, "Física", 2, 3), 48 | new Disciplina(4, "Português", 3, 1), 49 | new Disciplina(5, "Inglês", 4, 1), 50 | new Disciplina(6, "Inglês", 4, 2), 51 | new Disciplina(7, "Inglês", 4, 3), 52 | new Disciplina(8, "Programação", 5, 1), 53 | new Disciplina(9, "Programação", 5, 2), 54 | new Disciplina(10, "Programação", 5, 3) 55 | }); 56 | 57 | builder.Entity() 58 | .HasData(new List(){ 59 | new Aluno(1, 1, "Marta", "Kent", "33225555", DateTime.Parse("05/28/2005")), 60 | new Aluno(2, 2, "Paula", "Isabela", "3354288", DateTime.Parse("05/28/2005")), 61 | new Aluno(3, 3, "Laura", "Antonia", "55668899", DateTime.Parse("05/28/2005")), 62 | new Aluno(4, 4, "Luiza", "Maria", "6565659", DateTime.Parse("05/28/2005")), 63 | new Aluno(5, 5, "Lucas", "Machado", "565685415", DateTime.Parse("05/28/2005")), 64 | new Aluno(6, 6, "Pedro", "Alvares", "456454545", DateTime.Parse("05/28/2005")), 65 | new Aluno(7, 7, "Paulo", "José", "9874512", DateTime.Parse("05/28/2005")) 66 | }); 67 | 68 | builder.Entity() 69 | .HasData(new List() { 70 | new AlunoDisciplina() {AlunoId = 1, DisciplinaId = 2 }, 71 | new AlunoDisciplina() {AlunoId = 1, DisciplinaId = 4 }, 72 | new AlunoDisciplina() {AlunoId = 1, DisciplinaId = 5 }, 73 | new AlunoDisciplina() {AlunoId = 2, DisciplinaId = 1 }, 74 | new AlunoDisciplina() {AlunoId = 2, DisciplinaId = 2 }, 75 | new AlunoDisciplina() {AlunoId = 2, DisciplinaId = 5 }, 76 | new AlunoDisciplina() {AlunoId = 3, DisciplinaId = 1 }, 77 | new AlunoDisciplina() {AlunoId = 3, DisciplinaId = 2 }, 78 | new AlunoDisciplina() {AlunoId = 3, DisciplinaId = 3 }, 79 | new AlunoDisciplina() {AlunoId = 4, DisciplinaId = 1 }, 80 | new AlunoDisciplina() {AlunoId = 4, DisciplinaId = 4 }, 81 | new AlunoDisciplina() {AlunoId = 4, DisciplinaId = 5 }, 82 | new AlunoDisciplina() {AlunoId = 5, DisciplinaId = 4 }, 83 | new AlunoDisciplina() {AlunoId = 5, DisciplinaId = 5 }, 84 | new AlunoDisciplina() {AlunoId = 6, DisciplinaId = 1 }, 85 | new AlunoDisciplina() {AlunoId = 6, DisciplinaId = 2 }, 86 | new AlunoDisciplina() {AlunoId = 6, DisciplinaId = 3 }, 87 | new AlunoDisciplina() {AlunoId = 6, DisciplinaId = 4 }, 88 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 1 }, 89 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 2 }, 90 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 3 }, 91 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 4 }, 92 | new AlunoDisciplina() {AlunoId = 7, DisciplinaId = 5 } 93 | }); 94 | } 95 | } 96 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env 2 | WORKDIR /app 3 | 4 | # Copy csproj and restore as distinct layers 5 | COPY *.csproj ./ 6 | RUN dotnet restore 7 | 8 | # Copy everything else and build 9 | COPY . ./ 10 | RUN dotnet publish -c Release -o out 11 | 12 | # Build runtime image 13 | FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 14 | WORKDIR /app 15 | COPY --from=build-env /app/out . 16 | ENTRYPOINT ["dotnet", "SmartSchool.WebAPI.dll"] -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Helpers/DateTimeExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.Helpers 4 | { 5 | public static class DateTimeExtensions 6 | { 7 | public static int GetCurrentAge(this DateTime dateTime) 8 | { 9 | var currentDate = DateTime.UtcNow; 10 | int age = currentDate.Year - dateTime.Year; 11 | 12 | if (currentDate < dateTime.AddYears(age)) 13 | age--; 14 | 15 | return age; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Helpers/Extensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Serialization; 4 | 5 | namespace SmartSchool.WebAPI.Helpers 6 | { 7 | public static class Extensions 8 | { 9 | public static void AddPagination(this HttpResponse response, 10 | int currentPage, int itemsPerPage, int totalItems, int totalPages) 11 | { 12 | var paginationHeader = new PaginationHeader(currentPage, itemsPerPage, totalItems, totalPages); 13 | 14 | var camelCaseFormatter = new JsonSerializerSettings(); 15 | camelCaseFormatter.ContractResolver = new CamelCasePropertyNamesContractResolver(); 16 | 17 | response.Headers.Add("Pagination", JsonConvert.SerializeObject( 18 | paginationHeader, camelCaseFormatter)); 19 | response.Headers.Add("Access-Control-Expose-Headers", "Pagination"); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Helpers/PageList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | 7 | namespace SmartSchool.WebAPI.Helpers 8 | { 9 | public class PageList : List 10 | { 11 | public int CurrentPage { get; set; } 12 | public int TotalPages { get; set; } 13 | public int PageSize { get; set; } 14 | public int TotalCount { get; set; } 15 | 16 | public PageList(List items, int count, int pageNumber, int pageSize) 17 | { 18 | TotalCount = count; 19 | PageSize = pageSize; 20 | CurrentPage = pageNumber; 21 | TotalPages = (int)Math.Ceiling(count / (double)pageSize); 22 | this.AddRange(items); 23 | } 24 | 25 | public static async Task> CreateAsync( 26 | IQueryable source, int pageNumber, int pageSize) 27 | { 28 | var count = await source.CountAsync(); 29 | var items = await source.Skip((pageNumber-1) * pageSize) 30 | .Take(pageSize) 31 | .ToListAsync(); 32 | return new PageList(items, count, pageNumber, pageSize); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Helpers/PageParams.cs: -------------------------------------------------------------------------------- 1 | namespace SmartSchool.WebAPI.Helpers 2 | { 3 | public class PageParams 4 | { 5 | public const int MaxPageSize = 50; 6 | public int PageNumber { get; set; } = 1; 7 | private int pageSize = 10; 8 | public int PageSize 9 | { 10 | get { return pageSize; } 11 | set { pageSize = (value > MaxPageSize) ? MaxPageSize : value; } 12 | } 13 | 14 | public int? Matricula { get; set; } = null; 15 | public string Nome { get; set; } = string.Empty; 16 | public int? Ativo { get; set; } = null; 17 | } 18 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Helpers/PaginationHeader.cs: -------------------------------------------------------------------------------- 1 | namespace SmartSchool.WebAPI.Helpers 2 | { 3 | public class PaginationHeader 4 | { 5 | public int CurrentPage { get; set; } 6 | public int ItemsPerPage { get; set; } 7 | public int TotalItems { get; set; } 8 | public int TotalPages { get; set; } 9 | 10 | public PaginationHeader(int currentPage, int itemsPerPage, int totalItems, int totalPages) 11 | { 12 | this.CurrentPage = currentPage; 13 | this.ItemsPerPage = itemsPerPage; 14 | this.TotalItems = totalItems; 15 | this.TotalPages = totalPages; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Migrations/20201005185632_initMySql.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Metadata; 3 | using Microsoft.EntityFrameworkCore.Migrations; 4 | 5 | namespace SmartSchool.WebAPI.Migrations 6 | { 7 | public partial class initMySql : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.CreateTable( 12 | name: "Alunos", 13 | columns: table => new 14 | { 15 | Id = table.Column(nullable: false) 16 | .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), 17 | Matricula = table.Column(nullable: false), 18 | Nome = table.Column(nullable: true), 19 | Sobrenome = table.Column(nullable: true), 20 | Telefone = table.Column(nullable: true), 21 | DataNasc = table.Column(nullable: false), 22 | DataIni = table.Column(nullable: false), 23 | DataFim = table.Column(nullable: true), 24 | Ativo = table.Column(nullable: false) 25 | }, 26 | constraints: table => 27 | { 28 | table.PrimaryKey("PK_Alunos", x => x.Id); 29 | }); 30 | 31 | migrationBuilder.CreateTable( 32 | name: "Cursos", 33 | columns: table => new 34 | { 35 | Id = table.Column(nullable: false) 36 | .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), 37 | Nome = table.Column(nullable: true) 38 | }, 39 | constraints: table => 40 | { 41 | table.PrimaryKey("PK_Cursos", x => x.Id); 42 | }); 43 | 44 | migrationBuilder.CreateTable( 45 | name: "Professores", 46 | columns: table => new 47 | { 48 | Id = table.Column(nullable: false) 49 | .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), 50 | Registro = table.Column(nullable: false), 51 | Nome = table.Column(nullable: true), 52 | Sobrenome = table.Column(nullable: true), 53 | Telefone = table.Column(nullable: true), 54 | DataIni = table.Column(nullable: false), 55 | DataFim = table.Column(nullable: true), 56 | Ativo = table.Column(nullable: false) 57 | }, 58 | constraints: table => 59 | { 60 | table.PrimaryKey("PK_Professores", x => x.Id); 61 | }); 62 | 63 | migrationBuilder.CreateTable( 64 | name: "AlunosCursos", 65 | columns: table => new 66 | { 67 | AlunoId = table.Column(nullable: false), 68 | CursoId = table.Column(nullable: false), 69 | DataIni = table.Column(nullable: false), 70 | DataFim = table.Column(nullable: true) 71 | }, 72 | constraints: table => 73 | { 74 | table.PrimaryKey("PK_AlunosCursos", x => new { x.AlunoId, x.CursoId }); 75 | table.ForeignKey( 76 | name: "FK_AlunosCursos_Alunos_AlunoId", 77 | column: x => x.AlunoId, 78 | principalTable: "Alunos", 79 | principalColumn: "Id", 80 | onDelete: ReferentialAction.Cascade); 81 | table.ForeignKey( 82 | name: "FK_AlunosCursos_Cursos_CursoId", 83 | column: x => x.CursoId, 84 | principalTable: "Cursos", 85 | principalColumn: "Id", 86 | onDelete: ReferentialAction.Cascade); 87 | }); 88 | 89 | migrationBuilder.CreateTable( 90 | name: "Disciplinas", 91 | columns: table => new 92 | { 93 | Id = table.Column(nullable: false) 94 | .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), 95 | Nome = table.Column(nullable: true), 96 | CargaHoraria = table.Column(nullable: false), 97 | PrerequisitoId = table.Column(nullable: true), 98 | ProfessorId = table.Column(nullable: false), 99 | CursoId = table.Column(nullable: false) 100 | }, 101 | constraints: table => 102 | { 103 | table.PrimaryKey("PK_Disciplinas", x => x.Id); 104 | table.ForeignKey( 105 | name: "FK_Disciplinas_Cursos_CursoId", 106 | column: x => x.CursoId, 107 | principalTable: "Cursos", 108 | principalColumn: "Id", 109 | onDelete: ReferentialAction.Cascade); 110 | table.ForeignKey( 111 | name: "FK_Disciplinas_Disciplinas_PrerequisitoId", 112 | column: x => x.PrerequisitoId, 113 | principalTable: "Disciplinas", 114 | principalColumn: "Id", 115 | onDelete: ReferentialAction.Restrict); 116 | table.ForeignKey( 117 | name: "FK_Disciplinas_Professores_ProfessorId", 118 | column: x => x.ProfessorId, 119 | principalTable: "Professores", 120 | principalColumn: "Id", 121 | onDelete: ReferentialAction.Cascade); 122 | }); 123 | 124 | migrationBuilder.CreateTable( 125 | name: "AlunosDisciplinas", 126 | columns: table => new 127 | { 128 | AlunoId = table.Column(nullable: false), 129 | DisciplinaId = table.Column(nullable: false), 130 | DataIni = table.Column(nullable: false), 131 | DataFim = table.Column(nullable: true), 132 | Nota = table.Column(nullable: true) 133 | }, 134 | constraints: table => 135 | { 136 | table.PrimaryKey("PK_AlunosDisciplinas", x => new { x.AlunoId, x.DisciplinaId }); 137 | table.ForeignKey( 138 | name: "FK_AlunosDisciplinas_Alunos_AlunoId", 139 | column: x => x.AlunoId, 140 | principalTable: "Alunos", 141 | principalColumn: "Id", 142 | onDelete: ReferentialAction.Cascade); 143 | table.ForeignKey( 144 | name: "FK_AlunosDisciplinas_Disciplinas_DisciplinaId", 145 | column: x => x.DisciplinaId, 146 | principalTable: "Disciplinas", 147 | principalColumn: "Id", 148 | onDelete: ReferentialAction.Cascade); 149 | }); 150 | 151 | migrationBuilder.InsertData( 152 | table: "Alunos", 153 | columns: new[] { "Id", "Ativo", "DataFim", "DataIni", "DataNasc", "Matricula", "Nome", "Sobrenome", "Telefone" }, 154 | values: new object[,] 155 | { 156 | { 1, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(4940), new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, "Marta", "Kent", "33225555" }, 157 | { 2, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(7970), new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 2, "Paula", "Isabela", "3354288" }, 158 | { 3, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8040), new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 3, "Laura", "Antonia", "55668899" }, 159 | { 4, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8050), new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 4, "Luiza", "Maria", "6565659" }, 160 | { 5, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8060), new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, "Lucas", "Machado", "565685415" }, 161 | { 6, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8080), new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 6, "Pedro", "Alvares", "456454545" }, 162 | { 7, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8080), new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 7, "Paulo", "José", "9874512" } 163 | }); 164 | 165 | migrationBuilder.InsertData( 166 | table: "Cursos", 167 | columns: new[] { "Id", "Nome" }, 168 | values: new object[,] 169 | { 170 | { 1, "Tecnologia da Informação" }, 171 | { 2, "Sistemas de Informação" }, 172 | { 3, "Ciência da Computação" } 173 | }); 174 | 175 | migrationBuilder.InsertData( 176 | table: "Professores", 177 | columns: new[] { "Id", "Ativo", "DataFim", "DataIni", "Nome", "Registro", "Sobrenome", "Telefone" }, 178 | values: new object[,] 179 | { 180 | { 1, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 849, DateTimeKind.Local).AddTicks(2120), "Lauro", 1, "Oliveira", null }, 181 | { 2, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 868, DateTimeKind.Local).AddTicks(6310), "Roberto", 2, "Soares", null }, 182 | { 3, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 868, DateTimeKind.Local).AddTicks(6390), "Ronaldo", 3, "Marconi", null }, 183 | { 4, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 868, DateTimeKind.Local).AddTicks(6390), "Rodrigo", 4, "Carvalho", null }, 184 | { 5, true, null, new DateTime(2020, 10, 5, 15, 56, 31, 868, DateTimeKind.Local).AddTicks(6390), "Alexandre", 5, "Montanha", null } 185 | }); 186 | 187 | migrationBuilder.InsertData( 188 | table: "Disciplinas", 189 | columns: new[] { "Id", "CargaHoraria", "CursoId", "Nome", "PrerequisitoId", "ProfessorId" }, 190 | values: new object[,] 191 | { 192 | { 1, 0, 1, "Matemática", null, 1 }, 193 | { 2, 0, 3, "Matemática", null, 1 }, 194 | { 3, 0, 3, "Física", null, 2 }, 195 | { 4, 0, 1, "Português", null, 3 }, 196 | { 5, 0, 1, "Inglês", null, 4 }, 197 | { 6, 0, 2, "Inglês", null, 4 }, 198 | { 7, 0, 3, "Inglês", null, 4 }, 199 | { 8, 0, 1, "Programação", null, 5 }, 200 | { 9, 0, 2, "Programação", null, 5 }, 201 | { 10, 0, 3, "Programação", null, 5 } 202 | }); 203 | 204 | migrationBuilder.InsertData( 205 | table: "AlunosDisciplinas", 206 | columns: new[] { "AlunoId", "DisciplinaId", "DataFim", "DataIni", "Nota" }, 207 | values: new object[,] 208 | { 209 | { 2, 1, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(710), null }, 210 | { 4, 5, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(730), null }, 211 | { 2, 5, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(720), null }, 212 | { 1, 5, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(700), null }, 213 | { 7, 4, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(760), null }, 214 | { 6, 4, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(750), null }, 215 | { 5, 4, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(740), null }, 216 | { 4, 4, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(730), null }, 217 | { 1, 4, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(670), null }, 218 | { 7, 3, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(760), null }, 219 | { 5, 5, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(740), null }, 220 | { 6, 3, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(750), null }, 221 | { 7, 2, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(750), null }, 222 | { 6, 2, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(740), null }, 223 | { 3, 2, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(720), null }, 224 | { 2, 2, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(710), null }, 225 | { 1, 2, null, new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(9800), null }, 226 | { 7, 1, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(750), null }, 227 | { 6, 1, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(740), null }, 228 | { 4, 1, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(730), null }, 229 | { 3, 1, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(720), null }, 230 | { 3, 3, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(730), null }, 231 | { 7, 5, null, new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(760), null } 232 | }); 233 | 234 | migrationBuilder.CreateIndex( 235 | name: "IX_AlunosCursos_CursoId", 236 | table: "AlunosCursos", 237 | column: "CursoId"); 238 | 239 | migrationBuilder.CreateIndex( 240 | name: "IX_AlunosDisciplinas_DisciplinaId", 241 | table: "AlunosDisciplinas", 242 | column: "DisciplinaId"); 243 | 244 | migrationBuilder.CreateIndex( 245 | name: "IX_Disciplinas_CursoId", 246 | table: "Disciplinas", 247 | column: "CursoId"); 248 | 249 | migrationBuilder.CreateIndex( 250 | name: "IX_Disciplinas_PrerequisitoId", 251 | table: "Disciplinas", 252 | column: "PrerequisitoId"); 253 | 254 | migrationBuilder.CreateIndex( 255 | name: "IX_Disciplinas_ProfessorId", 256 | table: "Disciplinas", 257 | column: "ProfessorId"); 258 | } 259 | 260 | protected override void Down(MigrationBuilder migrationBuilder) 261 | { 262 | migrationBuilder.DropTable( 263 | name: "AlunosCursos"); 264 | 265 | migrationBuilder.DropTable( 266 | name: "AlunosDisciplinas"); 267 | 268 | migrationBuilder.DropTable( 269 | name: "Alunos"); 270 | 271 | migrationBuilder.DropTable( 272 | name: "Disciplinas"); 273 | 274 | migrationBuilder.DropTable( 275 | name: "Cursos"); 276 | 277 | migrationBuilder.DropTable( 278 | name: "Professores"); 279 | } 280 | } 281 | } 282 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Migrations/SmartContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 6 | using SmartSchool.WebAPI.Data; 7 | 8 | namespace SmartSchool.WebAPI.Migrations 9 | { 10 | [DbContext(typeof(SmartContext))] 11 | partial class SmartContextModelSnapshot : ModelSnapshot 12 | { 13 | protected override void BuildModel(ModelBuilder modelBuilder) 14 | { 15 | #pragma warning disable 612, 618 16 | modelBuilder 17 | .HasAnnotation("ProductVersion", "3.1.0") 18 | .HasAnnotation("Relational:MaxIdentifierLength", 64); 19 | 20 | modelBuilder.Entity("SmartSchool.WebAPI.Models.Aluno", b => 21 | { 22 | b.Property("Id") 23 | .ValueGeneratedOnAdd() 24 | .HasColumnType("int"); 25 | 26 | b.Property("Ativo") 27 | .HasColumnType("tinyint(1)"); 28 | 29 | b.Property("DataFim") 30 | .HasColumnType("datetime(6)"); 31 | 32 | b.Property("DataIni") 33 | .HasColumnType("datetime(6)"); 34 | 35 | b.Property("DataNasc") 36 | .HasColumnType("datetime(6)"); 37 | 38 | b.Property("Matricula") 39 | .HasColumnType("int"); 40 | 41 | b.Property("Nome") 42 | .HasColumnType("longtext CHARACTER SET utf8mb4"); 43 | 44 | b.Property("Sobrenome") 45 | .HasColumnType("longtext CHARACTER SET utf8mb4"); 46 | 47 | b.Property("Telefone") 48 | .HasColumnType("longtext CHARACTER SET utf8mb4"); 49 | 50 | b.HasKey("Id"); 51 | 52 | b.ToTable("Alunos"); 53 | 54 | b.HasData( 55 | new 56 | { 57 | Id = 1, 58 | Ativo = true, 59 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(4940), 60 | DataNasc = new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 61 | Matricula = 1, 62 | Nome = "Marta", 63 | Sobrenome = "Kent", 64 | Telefone = "33225555" 65 | }, 66 | new 67 | { 68 | Id = 2, 69 | Ativo = true, 70 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(7970), 71 | DataNasc = new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 72 | Matricula = 2, 73 | Nome = "Paula", 74 | Sobrenome = "Isabela", 75 | Telefone = "3354288" 76 | }, 77 | new 78 | { 79 | Id = 3, 80 | Ativo = true, 81 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8040), 82 | DataNasc = new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 83 | Matricula = 3, 84 | Nome = "Laura", 85 | Sobrenome = "Antonia", 86 | Telefone = "55668899" 87 | }, 88 | new 89 | { 90 | Id = 4, 91 | Ativo = true, 92 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8050), 93 | DataNasc = new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 94 | Matricula = 4, 95 | Nome = "Luiza", 96 | Sobrenome = "Maria", 97 | Telefone = "6565659" 98 | }, 99 | new 100 | { 101 | Id = 5, 102 | Ativo = true, 103 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8060), 104 | DataNasc = new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 105 | Matricula = 5, 106 | Nome = "Lucas", 107 | Sobrenome = "Machado", 108 | Telefone = "565685415" 109 | }, 110 | new 111 | { 112 | Id = 6, 113 | Ativo = true, 114 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8080), 115 | DataNasc = new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 116 | Matricula = 6, 117 | Nome = "Pedro", 118 | Sobrenome = "Alvares", 119 | Telefone = "456454545" 120 | }, 121 | new 122 | { 123 | Id = 7, 124 | Ativo = true, 125 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(8080), 126 | DataNasc = new DateTime(2005, 5, 28, 0, 0, 0, 0, DateTimeKind.Unspecified), 127 | Matricula = 7, 128 | Nome = "Paulo", 129 | Sobrenome = "José", 130 | Telefone = "9874512" 131 | }); 132 | }); 133 | 134 | modelBuilder.Entity("SmartSchool.WebAPI.Models.AlunoCurso", b => 135 | { 136 | b.Property("AlunoId") 137 | .HasColumnType("int"); 138 | 139 | b.Property("CursoId") 140 | .HasColumnType("int"); 141 | 142 | b.Property("DataFim") 143 | .HasColumnType("datetime(6)"); 144 | 145 | b.Property("DataIni") 146 | .HasColumnType("datetime(6)"); 147 | 148 | b.HasKey("AlunoId", "CursoId"); 149 | 150 | b.HasIndex("CursoId"); 151 | 152 | b.ToTable("AlunosCursos"); 153 | }); 154 | 155 | modelBuilder.Entity("SmartSchool.WebAPI.Models.AlunoDisciplina", b => 156 | { 157 | b.Property("AlunoId") 158 | .HasColumnType("int"); 159 | 160 | b.Property("DisciplinaId") 161 | .HasColumnType("int"); 162 | 163 | b.Property("DataFim") 164 | .HasColumnType("datetime(6)"); 165 | 166 | b.Property("DataIni") 167 | .HasColumnType("datetime(6)"); 168 | 169 | b.Property("Nota") 170 | .HasColumnType("int"); 171 | 172 | b.HasKey("AlunoId", "DisciplinaId"); 173 | 174 | b.HasIndex("DisciplinaId"); 175 | 176 | b.ToTable("AlunosDisciplinas"); 177 | 178 | b.HasData( 179 | new 180 | { 181 | AlunoId = 1, 182 | DisciplinaId = 2, 183 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 871, DateTimeKind.Local).AddTicks(9800) 184 | }, 185 | new 186 | { 187 | AlunoId = 1, 188 | DisciplinaId = 4, 189 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(670) 190 | }, 191 | new 192 | { 193 | AlunoId = 1, 194 | DisciplinaId = 5, 195 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(700) 196 | }, 197 | new 198 | { 199 | AlunoId = 2, 200 | DisciplinaId = 1, 201 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(710) 202 | }, 203 | new 204 | { 205 | AlunoId = 2, 206 | DisciplinaId = 2, 207 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(710) 208 | }, 209 | new 210 | { 211 | AlunoId = 2, 212 | DisciplinaId = 5, 213 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(720) 214 | }, 215 | new 216 | { 217 | AlunoId = 3, 218 | DisciplinaId = 1, 219 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(720) 220 | }, 221 | new 222 | { 223 | AlunoId = 3, 224 | DisciplinaId = 2, 225 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(720) 226 | }, 227 | new 228 | { 229 | AlunoId = 3, 230 | DisciplinaId = 3, 231 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(730) 232 | }, 233 | new 234 | { 235 | AlunoId = 4, 236 | DisciplinaId = 1, 237 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(730) 238 | }, 239 | new 240 | { 241 | AlunoId = 4, 242 | DisciplinaId = 4, 243 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(730) 244 | }, 245 | new 246 | { 247 | AlunoId = 4, 248 | DisciplinaId = 5, 249 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(730) 250 | }, 251 | new 252 | { 253 | AlunoId = 5, 254 | DisciplinaId = 4, 255 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(740) 256 | }, 257 | new 258 | { 259 | AlunoId = 5, 260 | DisciplinaId = 5, 261 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(740) 262 | }, 263 | new 264 | { 265 | AlunoId = 6, 266 | DisciplinaId = 1, 267 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(740) 268 | }, 269 | new 270 | { 271 | AlunoId = 6, 272 | DisciplinaId = 2, 273 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(740) 274 | }, 275 | new 276 | { 277 | AlunoId = 6, 278 | DisciplinaId = 3, 279 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(750) 280 | }, 281 | new 282 | { 283 | AlunoId = 6, 284 | DisciplinaId = 4, 285 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(750) 286 | }, 287 | new 288 | { 289 | AlunoId = 7, 290 | DisciplinaId = 1, 291 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(750) 292 | }, 293 | new 294 | { 295 | AlunoId = 7, 296 | DisciplinaId = 2, 297 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(750) 298 | }, 299 | new 300 | { 301 | AlunoId = 7, 302 | DisciplinaId = 3, 303 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(760) 304 | }, 305 | new 306 | { 307 | AlunoId = 7, 308 | DisciplinaId = 4, 309 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(760) 310 | }, 311 | new 312 | { 313 | AlunoId = 7, 314 | DisciplinaId = 5, 315 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 872, DateTimeKind.Local).AddTicks(760) 316 | }); 317 | }); 318 | 319 | modelBuilder.Entity("SmartSchool.WebAPI.Models.Curso", b => 320 | { 321 | b.Property("Id") 322 | .ValueGeneratedOnAdd() 323 | .HasColumnType("int"); 324 | 325 | b.Property("Nome") 326 | .HasColumnType("longtext CHARACTER SET utf8mb4"); 327 | 328 | b.HasKey("Id"); 329 | 330 | b.ToTable("Cursos"); 331 | 332 | b.HasData( 333 | new 334 | { 335 | Id = 1, 336 | Nome = "Tecnologia da Informação" 337 | }, 338 | new 339 | { 340 | Id = 2, 341 | Nome = "Sistemas de Informação" 342 | }, 343 | new 344 | { 345 | Id = 3, 346 | Nome = "Ciência da Computação" 347 | }); 348 | }); 349 | 350 | modelBuilder.Entity("SmartSchool.WebAPI.Models.Disciplina", b => 351 | { 352 | b.Property("Id") 353 | .ValueGeneratedOnAdd() 354 | .HasColumnType("int"); 355 | 356 | b.Property("CargaHoraria") 357 | .HasColumnType("int"); 358 | 359 | b.Property("CursoId") 360 | .HasColumnType("int"); 361 | 362 | b.Property("Nome") 363 | .HasColumnType("longtext CHARACTER SET utf8mb4"); 364 | 365 | b.Property("PrerequisitoId") 366 | .HasColumnType("int"); 367 | 368 | b.Property("ProfessorId") 369 | .HasColumnType("int"); 370 | 371 | b.HasKey("Id"); 372 | 373 | b.HasIndex("CursoId"); 374 | 375 | b.HasIndex("PrerequisitoId"); 376 | 377 | b.HasIndex("ProfessorId"); 378 | 379 | b.ToTable("Disciplinas"); 380 | 381 | b.HasData( 382 | new 383 | { 384 | Id = 1, 385 | CargaHoraria = 0, 386 | CursoId = 1, 387 | Nome = "Matemática", 388 | ProfessorId = 1 389 | }, 390 | new 391 | { 392 | Id = 2, 393 | CargaHoraria = 0, 394 | CursoId = 3, 395 | Nome = "Matemática", 396 | ProfessorId = 1 397 | }, 398 | new 399 | { 400 | Id = 3, 401 | CargaHoraria = 0, 402 | CursoId = 3, 403 | Nome = "Física", 404 | ProfessorId = 2 405 | }, 406 | new 407 | { 408 | Id = 4, 409 | CargaHoraria = 0, 410 | CursoId = 1, 411 | Nome = "Português", 412 | ProfessorId = 3 413 | }, 414 | new 415 | { 416 | Id = 5, 417 | CargaHoraria = 0, 418 | CursoId = 1, 419 | Nome = "Inglês", 420 | ProfessorId = 4 421 | }, 422 | new 423 | { 424 | Id = 6, 425 | CargaHoraria = 0, 426 | CursoId = 2, 427 | Nome = "Inglês", 428 | ProfessorId = 4 429 | }, 430 | new 431 | { 432 | Id = 7, 433 | CargaHoraria = 0, 434 | CursoId = 3, 435 | Nome = "Inglês", 436 | ProfessorId = 4 437 | }, 438 | new 439 | { 440 | Id = 8, 441 | CargaHoraria = 0, 442 | CursoId = 1, 443 | Nome = "Programação", 444 | ProfessorId = 5 445 | }, 446 | new 447 | { 448 | Id = 9, 449 | CargaHoraria = 0, 450 | CursoId = 2, 451 | Nome = "Programação", 452 | ProfessorId = 5 453 | }, 454 | new 455 | { 456 | Id = 10, 457 | CargaHoraria = 0, 458 | CursoId = 3, 459 | Nome = "Programação", 460 | ProfessorId = 5 461 | }); 462 | }); 463 | 464 | modelBuilder.Entity("SmartSchool.WebAPI.Models.Professor", b => 465 | { 466 | b.Property("Id") 467 | .ValueGeneratedOnAdd() 468 | .HasColumnType("int"); 469 | 470 | b.Property("Ativo") 471 | .HasColumnType("tinyint(1)"); 472 | 473 | b.Property("DataFim") 474 | .HasColumnType("datetime(6)"); 475 | 476 | b.Property("DataIni") 477 | .HasColumnType("datetime(6)"); 478 | 479 | b.Property("Nome") 480 | .HasColumnType("longtext CHARACTER SET utf8mb4"); 481 | 482 | b.Property("Registro") 483 | .HasColumnType("int"); 484 | 485 | b.Property("Sobrenome") 486 | .HasColumnType("longtext CHARACTER SET utf8mb4"); 487 | 488 | b.Property("Telefone") 489 | .HasColumnType("longtext CHARACTER SET utf8mb4"); 490 | 491 | b.HasKey("Id"); 492 | 493 | b.ToTable("Professores"); 494 | 495 | b.HasData( 496 | new 497 | { 498 | Id = 1, 499 | Ativo = true, 500 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 849, DateTimeKind.Local).AddTicks(2120), 501 | Nome = "Lauro", 502 | Registro = 1, 503 | Sobrenome = "Oliveira" 504 | }, 505 | new 506 | { 507 | Id = 2, 508 | Ativo = true, 509 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 868, DateTimeKind.Local).AddTicks(6310), 510 | Nome = "Roberto", 511 | Registro = 2, 512 | Sobrenome = "Soares" 513 | }, 514 | new 515 | { 516 | Id = 3, 517 | Ativo = true, 518 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 868, DateTimeKind.Local).AddTicks(6390), 519 | Nome = "Ronaldo", 520 | Registro = 3, 521 | Sobrenome = "Marconi" 522 | }, 523 | new 524 | { 525 | Id = 4, 526 | Ativo = true, 527 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 868, DateTimeKind.Local).AddTicks(6390), 528 | Nome = "Rodrigo", 529 | Registro = 4, 530 | Sobrenome = "Carvalho" 531 | }, 532 | new 533 | { 534 | Id = 5, 535 | Ativo = true, 536 | DataIni = new DateTime(2020, 10, 5, 15, 56, 31, 868, DateTimeKind.Local).AddTicks(6390), 537 | Nome = "Alexandre", 538 | Registro = 5, 539 | Sobrenome = "Montanha" 540 | }); 541 | }); 542 | 543 | modelBuilder.Entity("SmartSchool.WebAPI.Models.AlunoCurso", b => 544 | { 545 | b.HasOne("SmartSchool.WebAPI.Models.Aluno", "Aluno") 546 | .WithMany() 547 | .HasForeignKey("AlunoId") 548 | .OnDelete(DeleteBehavior.Cascade) 549 | .IsRequired(); 550 | 551 | b.HasOne("SmartSchool.WebAPI.Models.Curso", "Curso") 552 | .WithMany() 553 | .HasForeignKey("CursoId") 554 | .OnDelete(DeleteBehavior.Cascade) 555 | .IsRequired(); 556 | }); 557 | 558 | modelBuilder.Entity("SmartSchool.WebAPI.Models.AlunoDisciplina", b => 559 | { 560 | b.HasOne("SmartSchool.WebAPI.Models.Aluno", "Aluno") 561 | .WithMany("AlunosDisciplinas") 562 | .HasForeignKey("AlunoId") 563 | .OnDelete(DeleteBehavior.Cascade) 564 | .IsRequired(); 565 | 566 | b.HasOne("SmartSchool.WebAPI.Models.Disciplina", "Disciplina") 567 | .WithMany("AlunosDisciplinas") 568 | .HasForeignKey("DisciplinaId") 569 | .OnDelete(DeleteBehavior.Cascade) 570 | .IsRequired(); 571 | }); 572 | 573 | modelBuilder.Entity("SmartSchool.WebAPI.Models.Disciplina", b => 574 | { 575 | b.HasOne("SmartSchool.WebAPI.Models.Curso", "Curso") 576 | .WithMany("Disciplinas") 577 | .HasForeignKey("CursoId") 578 | .OnDelete(DeleteBehavior.Cascade) 579 | .IsRequired(); 580 | 581 | b.HasOne("SmartSchool.WebAPI.Models.Disciplina", "Prerequisito") 582 | .WithMany() 583 | .HasForeignKey("PrerequisitoId"); 584 | 585 | b.HasOne("SmartSchool.WebAPI.Models.Professor", "Professor") 586 | .WithMany("Disciplinas") 587 | .HasForeignKey("ProfessorId") 588 | .OnDelete(DeleteBehavior.Cascade) 589 | .IsRequired(); 590 | }); 591 | #pragma warning restore 612, 618 592 | } 593 | } 594 | } 595 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Models/Aluno.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SmartSchool.WebAPI.Models 5 | { 6 | public class Aluno 7 | { 8 | public Aluno() { } 9 | public Aluno(int id, 10 | int matricula, 11 | string nome, 12 | string sobrenome, 13 | string telefone, 14 | DateTime dataNasc) 15 | { 16 | this.Id = id; 17 | this.Matricula = matricula; 18 | this.Nome = nome; 19 | this.Sobrenome = sobrenome; 20 | this.Telefone = telefone; 21 | this.DataNasc = dataNasc; 22 | } 23 | public int Id { get; set; } 24 | public int Matricula { get; set; } 25 | public string Nome { get; set; } 26 | public string Sobrenome { get; set; } 27 | public string Telefone { get; set; } 28 | public DateTime DataNasc { get; set; } 29 | public DateTime DataIni { get; set; } = DateTime.Now; 30 | public DateTime? DataFim { get; set; } = null; 31 | public bool Ativo { get; set; } = true; 32 | public IEnumerable AlunosDisciplinas { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Models/AlunoCurso.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.Models 4 | { 5 | public class AlunoCurso 6 | { 7 | public AlunoCurso() { } 8 | public AlunoCurso(int alunoId, int cursoId) 9 | { 10 | this.AlunoId = alunoId; 11 | this.CursoId = cursoId; 12 | } 13 | public DateTime DataIni { get; set; } = DateTime.Now; 14 | public DateTime? DataFim { get; set; } 15 | public int AlunoId { get; set; } 16 | public Aluno Aluno { get; set; } 17 | public int CursoId { get; set; } 18 | public Curso Curso { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Models/AlunoDisciplina.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.Models 4 | { 5 | public class AlunoDisciplina 6 | { 7 | public AlunoDisciplina() { } 8 | public AlunoDisciplina(int alunoId, int disciplinaId) 9 | { 10 | this.AlunoId = alunoId; 11 | this.DisciplinaId = disciplinaId; 12 | } 13 | public DateTime DataIni { get; set; } = DateTime.Now; 14 | public DateTime? DataFim { get; set; } 15 | public int? Nota { get; set; } = null; 16 | public int AlunoId { get; set; } 17 | public Aluno Aluno { get; set; } 18 | public int DisciplinaId { get; set; } 19 | public Disciplina Disciplina { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Models/Curso.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SmartSchool.WebAPI.Models 4 | { 5 | public class Curso 6 | { 7 | public Curso() { } 8 | public Curso(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.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, int cursoId) 9 | { 10 | this.Id = id; 11 | this.Nome = nome; 12 | this.ProfessorId = professorId; 13 | this.CursoId = cursoId; 14 | } 15 | public int Id { get; set; } 16 | public string Nome { get; set; } 17 | public int CargaHoraria { get; set; } 18 | public int? PrerequisitoId { get; set; } = null; 19 | public Disciplina Prerequisito { get; set; } 20 | public int ProfessorId { get; set; } 21 | public Professor Professor { get; set; } 22 | public int CursoId { get; set; } 23 | public Curso Curso { get; set; } 24 | public IEnumerable AlunosDisciplinas { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Models/Professor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SmartSchool.WebAPI.Models 5 | { 6 | public class Professor 7 | { 8 | public Professor() { } 9 | public Professor(int id, int registro, string nome, string sobrenome) 10 | { 11 | this.Id = id; 12 | this.Registro = registro; 13 | this.Nome = nome; 14 | this.Sobrenome = sobrenome; 15 | } 16 | public int Id { get; set; } 17 | public int Registro { get; set; } 18 | public string Nome { get; set; } 19 | public string Sobrenome { get; set; } 20 | public string Telefone { get; set; } 21 | public DateTime DataIni { get; set; } = DateTime.Now; 22 | public DateTime? DataFim { get; set; } = null; 23 | public bool Ativo { get; set; } = true; 24 | public IEnumerable Disciplinas { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /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.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:36663" 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "environmentVariables": { 14 | "ASPNETCORE_ENVIRONMENT": "Development" 15 | } 16 | }, 17 | "SmartSchool.WebAPI": { 18 | "commandName": "Project", 19 | "applicationUrl": "http://localhost:5000", 20 | "environmentVariables": { 21 | "ASPNETCORE_ENVIRONMENT": "Development" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/SmartSchool.WebAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | netcoreapp3.1 4 | SmartSchool.WebAPI.xml 5 | 1701;1702;1591 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/SmartSchool.WebAPI.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SmartSchool.WebAPI 5 | 6 | 7 | 8 | 9 | Versão 1 do meu controlador de Alunos 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Método responsável para retornar todos os meus alunos 22 | 23 | 24 | 25 | 26 | 27 | Método responsável por retonar apenas um único AlunoDTO. 28 | 29 | 30 | 31 | 32 | 33 | Método responsável por retonar apenas um único AlunoDTO. 34 | 35 | 36 | 37 | 38 | 39 | Método responsável por retonar apenas um Aluno por meio do Código ID 40 | 41 | 42 | 43 | 44 | 45 | 46 | Versão 1 do meu controlador de Professores 47 | 48 | 49 | 50 | 51 | Identificador e chave do Banco 52 | 53 | 54 | 55 | 56 | Chave do Aluno, para outros negócios na Instituição 57 | 58 | 59 | 60 | 61 | Nome e o Primeiro nome o o Sobrenome do Aluno 62 | 63 | 64 | 65 | 66 | Esta idade é o calculo relacionado a data de nascimento do Aluno 67 | 68 | 69 | 70 | 71 | Ativar ou não o Aluno 72 | 73 | 74 | 75 | 76 | Este � o DTO de Aluno para Registrar. 77 | 78 | 79 | 80 | 81 | Este � o DTO de Aluno para Registrar. 82 | 83 | 84 | 85 | 86 | Identificador e chave do Banco. 87 | 88 | 89 | 90 | 91 | Chave do Aluno, para outros neg�cios na Institui��o. 92 | 93 | 94 | 95 | 96 | Nome � o Primeiro nome o o Sobrenome do Aluno. 97 | 98 | 99 | 100 | 101 | Versão 2 do meu controlador de Alunos 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Método responsável para retornar todos os meus alunos 114 | 115 | 116 | 117 | 118 | 119 | Método responsável por retonar apenas um Aluno por meio do Código ID 120 | 121 | 122 | 123 | 124 | 125 | 126 | Identificador e chave do Banco 127 | 128 | 129 | 130 | 131 | Chave do Aluno, para outros neg�cios na Institui��o 132 | 133 | 134 | 135 | 136 | Nome � o Primeiro nome o o Sobrenome do Aluno 137 | 138 | 139 | 140 | 141 | Esta idade � o calculo relacionado a data de nascimento do Aluno 142 | 143 | 144 | 145 | 146 | Ativar ou n�o o Aluno 147 | 148 | 149 | 150 | 151 | Este � o DTO de Aluno para Registrar. 152 | 153 | 154 | 155 | 156 | Identificador e chave do Banco. 157 | 158 | 159 | 160 | 161 | Chave do Aluno, para outros neg�cios na Institui��o. 162 | 163 | 164 | 165 | 166 | Nome � o Primeiro nome o o Sobrenome do Aluno. 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/SmartSchool.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchool.WebAPI/SmartSchool.db -------------------------------------------------------------------------------- /SmartSchool.WebAPI/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Threading.Tasks; 7 | using AutoMapper; 8 | using Microsoft.AspNetCore.Builder; 9 | using Microsoft.AspNetCore.Hosting; 10 | using Microsoft.AspNetCore.HttpsPolicy; 11 | using Microsoft.AspNetCore.Mvc; 12 | using Microsoft.AspNetCore.Mvc.ApiExplorer; 13 | using Microsoft.EntityFrameworkCore; 14 | using Microsoft.Extensions.Configuration; 15 | using Microsoft.Extensions.DependencyInjection; 16 | using Microsoft.Extensions.Hosting; 17 | using Microsoft.Extensions.Logging; 18 | using SmartSchool.WebAPI.Data; 19 | 20 | namespace SmartSchool.WebAPI 21 | { 22 | public class Startup 23 | { 24 | public Startup(IConfiguration configuration) 25 | { 26 | Configuration = configuration; 27 | } 28 | 29 | public IConfiguration Configuration { get; } 30 | 31 | // This method gets called by the runtime. Use this method to add services to the container. 32 | public void ConfigureServices(IServiceCollection services) 33 | { 34 | services.AddDbContext( 35 | context => context.UseMySql(Configuration.GetConnectionString("MySqlConnection")) 36 | ); 37 | 38 | services.AddControllers() 39 | .AddNewtonsoftJson( 40 | opt => opt.SerializerSettings.ReferenceLoopHandling = 41 | Newtonsoft.Json.ReferenceLoopHandling.Ignore); 42 | 43 | services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); 44 | 45 | services.AddScoped(); 46 | 47 | services.AddVersionedApiExplorer(options => 48 | { 49 | options.GroupNameFormat = "'v'VVV"; 50 | options.SubstituteApiVersionInUrl = true; 51 | }) 52 | .AddApiVersioning(options => 53 | { 54 | options.DefaultApiVersion = new ApiVersion(1, 0); 55 | options.AssumeDefaultVersionWhenUnspecified = true; 56 | options.ReportApiVersions = true; 57 | }); 58 | 59 | var apiProviderDescription = services.BuildServiceProvider() 60 | .GetService(); 61 | 62 | services.AddSwaggerGen(options => { 63 | foreach (var description in apiProviderDescription.ApiVersionDescriptions) 64 | { 65 | options.SwaggerDoc( 66 | description.GroupName, 67 | new Microsoft.OpenApi.Models.OpenApiInfo() 68 | { 69 | Title = "SmartSchool API", 70 | Version = description.ApiVersion.ToString(), 71 | TermsOfService = new Uri("http://SeusTermosDeUso.com"), 72 | Description = "A descrição da WebAPI do SmartSchool", 73 | License = new Microsoft.OpenApi.Models.OpenApiLicense 74 | { 75 | Name = "SmartSchool License", 76 | Url = new Uri("http://mit.com") 77 | }, 78 | Contact = new Microsoft.OpenApi.Models.OpenApiContact 79 | { 80 | Name = "Vinícius de Andrade", 81 | Email = "", 82 | Url = new Uri("http://programadamente.com") 83 | } 84 | } 85 | ); 86 | } 87 | 88 | var xmlCommentsFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; 89 | var xmlCommentsFullPath = Path.Combine(AppContext.BaseDirectory, xmlCommentsFile); 90 | 91 | options.IncludeXmlComments(xmlCommentsFullPath); 92 | }); 93 | services.AddCors(); 94 | } 95 | 96 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 97 | public void Configure(IApplicationBuilder app, 98 | IWebHostEnvironment env, 99 | IApiVersionDescriptionProvider apiProviderDescription) 100 | { 101 | if (env.IsDevelopment()) 102 | { 103 | app.UseDeveloperExceptionPage(); 104 | } 105 | 106 | // app.UseHttpsRedirection(); 107 | 108 | app.UseRouting(); 109 | app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); 110 | 111 | app.UseSwagger() 112 | .UseSwaggerUI(options => 113 | { 114 | foreach (var description in apiProviderDescription.ApiVersionDescriptions) 115 | { 116 | options.SwaggerEndpoint( 117 | $"/swagger/{description.GroupName}/swagger.json", 118 | description.GroupName.ToUpperInvariant()); 119 | } 120 | options.RoutePrefix = ""; 121 | }); 122 | 123 | // app.UseAuthorization(); 124 | 125 | app.UseEndpoints(endpoints => 126 | { 127 | endpoints.MapControllers(); 128 | }); 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Controllers/AlunoController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using AutoMapper; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.EntityFrameworkCore; 6 | using SmartSchool.WebAPI.Data; 7 | using SmartSchool.WebAPI.V1.Dtos; 8 | using SmartSchool.WebAPI.Models; 9 | using System.Threading.Tasks; 10 | using SmartSchool.WebAPI.Helpers; 11 | 12 | namespace SmartSchool.WebAPI.V1.Controllers 13 | { 14 | /// 15 | /// Versão 1 do meu controlador de Alunos 16 | /// 17 | [ApiController] 18 | [ApiVersion("1.0")] 19 | [Route("api/v{version:apiVersion}/[controller]")] 20 | public class AlunoController : ControllerBase 21 | { 22 | public readonly IRepository _repo; 23 | private readonly IMapper _mapper; 24 | 25 | /// 26 | /// 27 | /// 28 | /// 29 | /// 30 | public AlunoController(IRepository repo, IMapper mapper) 31 | { 32 | _mapper = mapper; 33 | _repo = repo; 34 | } 35 | 36 | /// 37 | /// Método responsável para retornar todos os meus alunos 38 | /// 39 | /// 40 | [HttpGet] 41 | public async Task Get([FromQuery] PageParams pageParams) 42 | { 43 | var alunos = await _repo.GetAllAlunosAsync(pageParams, true); 44 | 45 | var alunosResult = _mapper.Map>(alunos); 46 | 47 | Response.AddPagination(alunos.CurrentPage, alunos.PageSize, alunos.TotalCount, alunos.TotalPages); 48 | 49 | return Ok(alunosResult); 50 | } 51 | 52 | /// 53 | /// Método responsável por retonar apenas um único AlunoDTO. 54 | /// 55 | /// 56 | [HttpGet("ByDisciplina/{id}")] 57 | public async Task GetByDisciplinaId(int id) 58 | { 59 | var result = await _repo.GetAllAlunosByDisciplinaIdAsync(id, false); 60 | return Ok(result); 61 | } 62 | 63 | /// 64 | /// Método responsável por retonar apenas um único AlunoDTO. 65 | /// 66 | /// 67 | [HttpGet("getRegister")] 68 | public IActionResult GetRegister() 69 | { 70 | return Ok(new AlunoRegistrarDto()); 71 | } 72 | 73 | /// 74 | /// Método responsável por retonar apenas um Aluno por meio do Código ID 75 | /// 76 | /// 77 | /// 78 | // api/aluno 79 | [HttpGet("{id}")] 80 | public IActionResult GetById(int id) 81 | { 82 | var aluno = _repo.GetAlunoById(id, false); 83 | if (aluno == null) return BadRequest("O Aluno não foi encontrado"); 84 | 85 | var alunoDto = _mapper.Map(aluno); 86 | 87 | return Ok(alunoDto); 88 | } 89 | 90 | // api/aluno 91 | [HttpPost] 92 | public IActionResult Post(AlunoRegistrarDto model) 93 | { 94 | var aluno = _mapper.Map(model); 95 | 96 | _repo.Add(aluno); 97 | if (_repo.SaveChanges()) 98 | { 99 | return Created($"/api/aluno/{model.Id}", _mapper.Map(aluno)); 100 | } 101 | 102 | return BadRequest("Aluno não cadastrado"); 103 | } 104 | 105 | // api/aluno 106 | [HttpPut("{id}")] 107 | public IActionResult Put(int id, AlunoRegistrarDto model) 108 | { 109 | var aluno = _repo.GetAlunoById(id); 110 | if (aluno == null) return BadRequest("Aluno não encontrado"); 111 | 112 | _mapper.Map(model, aluno); 113 | 114 | _repo.Update(aluno); 115 | if (_repo.SaveChanges()) 116 | { 117 | return Created($"/api/aluno/{model.Id}", _mapper.Map(aluno)); 118 | } 119 | 120 | return BadRequest("Aluno não Atualizado"); 121 | } 122 | 123 | // api/aluno 124 | [HttpPatch("{id}")] 125 | public IActionResult Patch(int id, AlunoPatchDto model) 126 | { 127 | var aluno = _repo.GetAlunoById(id); 128 | if (aluno == null) return BadRequest("Aluno não encontrado"); 129 | 130 | _mapper.Map(model, aluno); 131 | 132 | _repo.Update(aluno); 133 | if (_repo.SaveChanges()) 134 | { 135 | return Created($"/api/aluno/{model.Id}", _mapper.Map(aluno)); 136 | } 137 | 138 | return BadRequest("Aluno não Atualizado"); 139 | } 140 | 141 | // api/aluno/{id}/trocarEstado 142 | [HttpPatch("{id}/trocarEstado")] 143 | public IActionResult trocarEstado(int id, TrocaEstadoDto trocaEstado) 144 | { 145 | var aluno = _repo.GetAlunoById(id); 146 | if (aluno == null) return BadRequest("Aluno não encontrado"); 147 | 148 | aluno.Ativo = trocaEstado.Estado; 149 | 150 | _repo.Update(aluno); 151 | if (_repo.SaveChanges()) 152 | { 153 | var msn = aluno.Ativo ? "ativado" : "desativado"; 154 | return Ok(new { message = $"Aluno {msn} com sucesso!" }); 155 | } 156 | 157 | return BadRequest("Aluno não Atualizado"); 158 | } 159 | 160 | [HttpDelete("{id}")] 161 | public IActionResult Delete(int id) 162 | { 163 | var aluno = _repo.GetAlunoById(id); 164 | if (aluno == null) return BadRequest("Aluno não encontrado"); 165 | 166 | _repo.Delete(aluno); 167 | if (_repo.SaveChanges()) 168 | { 169 | return Ok("Aluno deletado"); 170 | } 171 | 172 | return BadRequest("Aluno não deletado"); 173 | } 174 | } 175 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Controllers/ProfessorController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using AutoMapper; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.EntityFrameworkCore; 6 | using SmartSchool.WebAPI.Data; 7 | using SmartSchool.WebAPI.V1.Dtos; 8 | using SmartSchool.WebAPI.Models; 9 | 10 | namespace SmartSchool.WebAPI.V1.Controllers 11 | { 12 | /// 13 | /// Versão 1 do meu controlador de Professores 14 | /// 15 | [ApiController] 16 | [ApiVersion("1.0")] 17 | [Route("api/v{version:apiVersion}/[controller]")] 18 | public class ProfessorController : ControllerBase 19 | { 20 | private readonly IRepository _repo; 21 | private readonly IMapper _mapper; 22 | public ProfessorController(IRepository repo, IMapper mapper) 23 | { 24 | _mapper = mapper; 25 | _repo = repo; 26 | } 27 | 28 | [HttpGet] 29 | public IActionResult Get() 30 | { 31 | var Professor = _repo.GetAllProfessores(true); 32 | return Ok(_mapper.Map>(Professor)); 33 | } 34 | 35 | [HttpGet("getRegister")] 36 | public IActionResult GetRegister() 37 | { 38 | return Ok(new ProfessorRegistrarDto()); 39 | } 40 | 41 | // api/Professor 42 | [HttpGet("{id}")] 43 | public IActionResult GetById(int id) 44 | { 45 | var Professor = _repo.GetProfessorById(id, true); 46 | if (Professor == null) return BadRequest("O Professor não foi encontrado"); 47 | 48 | var professorDto = _mapper.Map(Professor); 49 | 50 | return Ok(Professor); 51 | } 52 | 53 | // api/Professor 54 | [HttpGet("byaluno/{alunoId}")] 55 | public IActionResult GetByAlunoId(int alunoId) 56 | { 57 | var Professores = _repo.GetProfessoresByAlunoId(alunoId, true); 58 | if (Professores == null) return BadRequest("Professores não encontrados"); 59 | 60 | return Ok(_mapper.Map>(Professores)); 61 | } 62 | 63 | // api/Professor 64 | [HttpPost] 65 | public IActionResult Post(ProfessorRegistrarDto model) 66 | { 67 | var prof = _mapper.Map(model); 68 | 69 | _repo.Add(prof); 70 | if (_repo.SaveChanges()) 71 | { 72 | return Created($"/api/professor/{model.Id}", _mapper.Map(prof)); 73 | } 74 | 75 | return BadRequest("Professor não cadastrado"); 76 | } 77 | 78 | // api/Professor 79 | [HttpPut("{id}")] 80 | public IActionResult Put(int id, ProfessorRegistrarDto model) 81 | { 82 | var prof = _repo.GetProfessorById(id, false); 83 | if (prof == null) return BadRequest("Professor não encontrado"); 84 | 85 | _mapper.Map(model, prof); 86 | 87 | _repo.Update(prof); 88 | if (_repo.SaveChanges()) 89 | { 90 | return Created($"/api/professor/{model.Id}", _mapper.Map(prof)); 91 | } 92 | 93 | return BadRequest("Professor não Atualizado"); 94 | } 95 | 96 | // api/Professor 97 | [HttpPatch("{id}")] 98 | public IActionResult Patch(int id, ProfessorRegistrarDto model) 99 | { 100 | var prof = _repo.GetProfessorById(id, false); 101 | if (prof == null) return BadRequest("Professor não encontrado"); 102 | 103 | _mapper.Map(model, prof); 104 | 105 | _repo.Update(prof); 106 | if (_repo.SaveChanges()) 107 | { 108 | return Created($"/api/professor/{model.Id}", _mapper.Map(prof)); 109 | } 110 | 111 | return BadRequest("Professor não Atualizado"); 112 | } 113 | 114 | [HttpDelete("{id}")] 115 | public IActionResult Delete(int id) 116 | { 117 | var prof = _repo.GetProfessorById(id, false); 118 | if (prof == null) return BadRequest("Professor não encontrado"); 119 | 120 | _repo.Delete(prof); 121 | if (_repo.SaveChanges()) 122 | { 123 | return Ok("professor deletado"); 124 | } 125 | 126 | return BadRequest("professor não deletado"); 127 | } 128 | } 129 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Dtos/AlunoDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.V1.Dtos 4 | { 5 | public class AlunoDto 6 | { 7 | /// 8 | /// Identificador e chave do Banco 9 | /// 10 | public int Id { get; set; } 11 | /// 12 | /// Chave do Aluno, para outros negócios na Instituição 13 | /// 14 | public int Matricula { get; set; } 15 | /// 16 | /// Nome e o Primeiro nome o o Sobrenome do Aluno 17 | /// 18 | public string Nome { get; set; } 19 | public string Telefone { get; set; } 20 | /// 21 | /// Esta idade é o calculo relacionado a data de nascimento do Aluno 22 | /// 23 | public int Idade { get; set; } 24 | public DateTime DataIni { get; set; } 25 | /// 26 | /// Ativar ou não o Aluno 27 | /// 28 | public bool Ativo { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Dtos/AlunoPatchDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.V1.Dtos 4 | { 5 | /// 6 | /// Este � o DTO de Aluno para Registrar. 7 | /// 8 | public class AlunoPatchDto 9 | { 10 | public int? Id { get; set; } 11 | public string Nome { get; set; } 12 | public string Sobrenome { get; set; } 13 | public string Telefone { get; set; } 14 | public bool Ativo { get; set; } 15 | } 16 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Dtos/AlunoRegistrarDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.V1.Dtos 4 | { 5 | /// 6 | /// Este � o DTO de Aluno para Registrar. 7 | /// 8 | public class AlunoRegistrarDto 9 | { 10 | /// 11 | /// Identificador e chave do Banco. 12 | /// 13 | public int Id { get; set; } 14 | /// 15 | /// Chave do Aluno, para outros neg�cios na Institui��o. 16 | /// 17 | public int Matricula { get; set; } 18 | /// 19 | /// Nome � o Primeiro nome o o Sobrenome do Aluno. 20 | /// 21 | public string Nome { get; set; } 22 | public string Sobrenome { get; set; } 23 | public string Telefone { get; set; } 24 | public DateTime DataNasc { get; set; } 25 | public DateTime DataIni { get; set; } = DateTime.Now; 26 | public DateTime? DataFim { get; set; } = null; 27 | public bool Ativo { get; set; } = true; 28 | } 29 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Dtos/CursoDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SmartSchool.WebAPI.V1.Dtos 4 | { 5 | public class CursoDto 6 | { 7 | public int Id { get; set; } 8 | public string Nome { get; set; } 9 | public IEnumerable Disciplinas { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Dtos/DisciplinaDto.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace SmartSchool.WebAPI.V1.Dtos 4 | { 5 | public class DisciplinaDto 6 | { 7 | public int Id { get; set; } 8 | public string Nome { get; set; } 9 | public int CargaHoraria { get; set; } 10 | public int? PrerequisitoId { get; set; } = null; 11 | public DisciplinaDto Prerequisito { get; set; } 12 | public int ProfessorId { get; set; } 13 | public ProfessorDto Professor { get; set; } 14 | public int CursoId { get; set; } 15 | public CursoDto Curso { get; set; } 16 | public IEnumerable Alunos { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Dtos/ProfessorDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SmartSchool.WebAPI.V1.Dtos 5 | { 6 | public class ProfessorDto 7 | { 8 | public int Id { get; set; } 9 | public int Registro { get; set; } 10 | public string Nome { get; set; } 11 | public string Telefone { get; set; } 12 | public bool Ativo { get; set; } = true; 13 | public IEnumerable Disciplinas { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Dtos/ProfessorRegistrarDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.V1.Dtos 4 | { 5 | public class ProfessorRegistrarDto 6 | { 7 | public int Id { get; set; } 8 | public int Registro { get; set; } 9 | public string Nome { get; set; } 10 | public string Sobrenome { get; set; } 11 | public string Telefone { get; set; } 12 | public DateTime DataIni { get; set; } = DateTime.Now; 13 | public DateTime? DataFim { get; set; } = null; 14 | public bool Ativo { get; set; } = true; 15 | } 16 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Dtos/TrocaEstadoDto.cs: -------------------------------------------------------------------------------- 1 | namespace SmartSchool.WebAPI.V1.Dtos 2 | { 3 | public class TrocaEstadoDto 4 | { 5 | public bool Estado { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V1/Profiles/SmartSchoolProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using SmartSchool.WebAPI.V1.Dtos; 3 | using SmartSchool.WebAPI.Models; 4 | using SmartSchool.WebAPI.Helpers; 5 | 6 | namespace SmartSchool.WebAPI.V1.Profiles 7 | { 8 | public class SmartSchoolProfile : Profile 9 | { 10 | public SmartSchoolProfile() 11 | { 12 | CreateMap() 13 | .ForMember( 14 | dest => dest.Nome, 15 | opt => opt.MapFrom(src => $"{src.Nome} {src.Sobrenome}") 16 | ) 17 | .ForMember( 18 | dest => dest.Idade, 19 | opt => opt.MapFrom(src => src.DataNasc.GetCurrentAge()) 20 | ); 21 | 22 | CreateMap(); 23 | CreateMap().ReverseMap(); 24 | CreateMap().ReverseMap(); 25 | 26 | CreateMap() 27 | .ForMember( 28 | dest => dest.Nome, 29 | opt => opt.MapFrom(src => $"{src.Nome} {src.Sobrenome}") 30 | ); 31 | 32 | CreateMap(); 33 | CreateMap().ReverseMap(); 34 | 35 | CreateMap().ReverseMap(); 36 | CreateMap().ReverseMap(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V2/Controllers/AlunoController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using AutoMapper; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.EntityFrameworkCore; 6 | using SmartSchool.WebAPI.Data; 7 | using SmartSchool.WebAPI.V1.Dtos; 8 | using SmartSchool.WebAPI.Models; 9 | 10 | namespace SmartSchool.WebAPI.V2.Controllers 11 | { 12 | /// 13 | /// Versão 2 do meu controlador de Alunos 14 | /// 15 | [ApiController] 16 | [ApiVersion("2.0")] 17 | [Route("api/v{version:apiVersion}/[controller]")] 18 | public class AlunoController : ControllerBase 19 | { 20 | public readonly IRepository _repo; 21 | private readonly IMapper _mapper; 22 | 23 | /// 24 | /// 25 | /// 26 | /// 27 | /// 28 | public AlunoController(IRepository repo, IMapper mapper) 29 | { 30 | _mapper = mapper; 31 | _repo = repo; 32 | } 33 | 34 | /// 35 | /// Método responsável para retornar todos os meus alunos 36 | /// 37 | /// 38 | [HttpGet] 39 | public IActionResult Get() 40 | { 41 | var alunos = _repo.GetAllAlunos(true); 42 | return Ok(_mapper.Map>(alunos)); 43 | } 44 | 45 | /// 46 | /// Método responsável por retonar apenas um Aluno por meio do Código ID 47 | /// 48 | /// 49 | /// 50 | // api/aluno 51 | [HttpGet("{id}")] 52 | public IActionResult GetById(int id) 53 | { 54 | var aluno = _repo.GetAlunoById(id, false); 55 | if (aluno == null) return BadRequest("O Aluno não foi encontrado"); 56 | 57 | var alunoDto = _mapper.Map(aluno); 58 | 59 | return Ok(alunoDto); 60 | } 61 | 62 | // api/aluno 63 | [HttpPost] 64 | public IActionResult Post(AlunoRegistrarDto model) 65 | { 66 | var aluno = _mapper.Map(model); 67 | 68 | _repo.Add(aluno); 69 | if (_repo.SaveChanges()) 70 | { 71 | return Created($"/api/aluno/{model.Id}", _mapper.Map(aluno)); 72 | } 73 | 74 | return BadRequest("Aluno não cadastrado"); 75 | } 76 | 77 | // api/aluno 78 | [HttpPut("{id}")] 79 | public IActionResult Put(int id, AlunoRegistrarDto model) 80 | { 81 | var aluno = _repo.GetAlunoById(id); 82 | if (aluno == null) return BadRequest("Aluno não encontrado"); 83 | 84 | _mapper.Map(model, aluno); 85 | 86 | _repo.Update(aluno); 87 | if (_repo.SaveChanges()) 88 | { 89 | return Created($"/api/aluno/{model.Id}", _mapper.Map(aluno)); 90 | } 91 | 92 | return BadRequest("Aluno não Atualizado"); 93 | } 94 | 95 | [HttpDelete("{id}")] 96 | public IActionResult Delete(int id) 97 | { 98 | var aluno = _repo.GetAlunoById(id); 99 | if (aluno == null) return BadRequest("Aluno não encontrado"); 100 | 101 | _repo.Delete(aluno); 102 | if (_repo.SaveChanges()) 103 | { 104 | return Ok("Aluno deletado"); 105 | } 106 | 107 | return BadRequest("Aluno não deletado"); 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V2/Dtos/AlunoDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.V2.Dtos 4 | { 5 | public class AlunoDto 6 | { 7 | /// 8 | /// Identificador e chave do Banco 9 | /// 10 | public int Id { get; set; } 11 | /// 12 | /// Chave do Aluno, para outros neg�cios na Institui��o 13 | /// 14 | public int Matricula { get; set; } 15 | /// 16 | /// Nome � o Primeiro nome o o Sobrenome do Aluno 17 | /// 18 | public string Nome { get; set; } 19 | public string Telefone { get; set; } 20 | /// 21 | /// Esta idade � o calculo relacionado a data de nascimento do Aluno 22 | /// 23 | public int Idade { get; set; } 24 | public DateTime DataIni { get; set; } 25 | /// 26 | /// Ativar ou n�o o Aluno 27 | /// 28 | public bool Ativo { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V2/Dtos/AlunoRegistrarDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SmartSchool.WebAPI.V2.Dtos 4 | { 5 | /// 6 | /// Este � o DTO de Aluno para Registrar. 7 | /// 8 | public class AlunoRegistrarDto 9 | { 10 | /// 11 | /// Identificador e chave do Banco. 12 | /// 13 | public int Id { get; set; } 14 | /// 15 | /// Chave do Aluno, para outros neg�cios na Institui��o. 16 | /// 17 | public int Matricula { get; set; } 18 | /// 19 | /// Nome � o Primeiro nome o o Sobrenome do Aluno. 20 | /// 21 | public string Nome { get; set; } 22 | public string Sobrenome { get; set; } 23 | public string Telefone { get; set; } 24 | public DateTime DataNasc { get; set; } 25 | public DateTime DataIni { get; set; } = DateTime.Now; 26 | public DateTime? DataFim { get; set; } = null; 27 | public bool Ativo { get; set; } = true; 28 | } 29 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/V2/Profiles/SmartSchoolProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using SmartSchool.WebAPI.V2.Dtos; 3 | using SmartSchool.WebAPI.Models; 4 | using SmartSchool.WebAPI.Helpers; 5 | 6 | namespace SmartSchool.WebAPI.V2.Profiles 7 | { 8 | public class SmartSchoolProfile : Profile 9 | { 10 | public SmartSchoolProfile() 11 | { 12 | CreateMap() 13 | .ForMember( 14 | dest => dest.Nome, 15 | opt => opt.MapFrom(src => $"{src.Nome} {src.Sobrenome}") 16 | ) 17 | .ForMember( 18 | dest => dest.Idade, 19 | opt => opt.MapFrom(src => src.DataNasc.GetCurrentAge()) 20 | ); 21 | 22 | CreateMap(); 23 | CreateMap().ReverseMap(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /SmartSchool.WebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "Default": "Data Source=SmartSchool.db", 4 | "MySqlConnection": "Server=localhost;Port=3306;Database=SmartSchoolDB;User=root;Password=lalaland;" 5 | }, 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "Default": "Data Source=SmartSchool.db", 4 | "MySqlConnection": "Server=localhost;Port=3306;Database=SmartSchoolDB;User=root;Password=lalaland;" 5 | }, 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /SmartSchool.WebAPI/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | 3 | volumes: 4 | SmartSchoolDb: 5 | 6 | networks: 7 | mysqlNET: 8 | smartschoolNET: 9 | 10 | services: 11 | 12 | mysql: 13 | image: "mysql:5.7" 14 | container_name: mysql 15 | ports: 16 | - "3306:3306" 17 | volumes: 18 | - SmartSchoolDb:/var/lib/mysql 19 | networks: 20 | - mysqlNET 21 | environment: 22 | - MYSQL_USER=root 23 | - MYSQL_PASSWORD=lalaland 24 | - MYSQL_ROOT_PASSWORD=lalaland 25 | - MYSQL_ROOT_HOST=% 26 | - bind-address:0.0.0.0 27 | 28 | smartschool: 29 | build: 30 | context: . 31 | dockerfile: Dockerfile 32 | container_name: smartschool 33 | networks: 34 | - mysqlNET 35 | - smartschoolNET 36 | ports: 37 | - 5000:80 38 | environment: 39 | - DBHOST=mysql 40 | depends_on: 41 | - mysql -------------------------------------------------------------------------------- /SmartSchool.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26124.0 5 | MinimumVisualStudioVersion = 15.0.26124.0 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SmartSchool.WebAPI", "SmartSchool.WebAPI\SmartSchool.WebAPI.csproj", "{DF8B33F2-BE79-47E2-8E17-0DE39146C78E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|Any CPU = Release|Any CPU 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Debug|x64.ActiveCfg = Debug|Any CPU 24 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Debug|x64.Build.0 = Debug|Any CPU 25 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Debug|x86.ActiveCfg = Debug|Any CPU 26 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Debug|x86.Build.0 = Debug|Any CPU 27 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Release|x64.ActiveCfg = Release|Any CPU 30 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Release|x64.Build.0 = Release|Any CPU 31 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Release|x86.ActiveCfg = Release|Any CPU 32 | {DF8B33F2-BE79-47E2-8E17-0DE39146C78E}.Release|x86.Build.0 = Release|Any CPU 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /SmartSchoolApp/.browserslistrc: -------------------------------------------------------------------------------- 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 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major version 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 9-11 # For IE 9-11 support, remove 'not'. 18 | -------------------------------------------------------------------------------- /SmartSchoolApp/.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 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /SmartSchoolApp/.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 | -------------------------------------------------------------------------------- /SmartSchoolApp/README.md: -------------------------------------------------------------------------------- 1 | # SmartSchoolApp 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.0. 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 | -------------------------------------------------------------------------------- /SmartSchoolApp/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "SmartSchoolApp": { 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/SmartSchoolApp", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "tsconfig.app.json", 21 | "aot": true, 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 | "extractLicenses": true, 46 | "vendorChunk": false, 47 | "buildOptimizer": true, 48 | "budgets": [ 49 | { 50 | "type": "initial", 51 | "maximumWarning": "2mb", 52 | "maximumError": "5mb" 53 | }, 54 | { 55 | "type": "anyComponentStyle", 56 | "maximumWarning": "6kb", 57 | "maximumError": "10kb" 58 | } 59 | ] 60 | } 61 | } 62 | }, 63 | "serve": { 64 | "builder": "@angular-devkit/build-angular:dev-server", 65 | "options": { 66 | "browserTarget": "SmartSchoolApp:build" 67 | }, 68 | "configurations": { 69 | "production": { 70 | "browserTarget": "SmartSchoolApp:build:production" 71 | } 72 | } 73 | }, 74 | "extract-i18n": { 75 | "builder": "@angular-devkit/build-angular:extract-i18n", 76 | "options": { 77 | "browserTarget": "SmartSchoolApp:build" 78 | } 79 | }, 80 | "test": { 81 | "builder": "@angular-devkit/build-angular:karma", 82 | "options": { 83 | "main": "src/test.ts", 84 | "polyfills": "src/polyfills.ts", 85 | "tsConfig": "tsconfig.spec.json", 86 | "karmaConfig": "karma.conf.js", 87 | "assets": [ 88 | "src/favicon.ico", 89 | "src/assets" 90 | ], 91 | "styles": [ 92 | "src/styles.css" 93 | ], 94 | "scripts": [] 95 | } 96 | }, 97 | "lint": { 98 | "builder": "@angular-devkit/build-angular:tslint", 99 | "options": { 100 | "tsConfig": [ 101 | "tsconfig.app.json", 102 | "tsconfig.spec.json", 103 | "e2e/tsconfig.json" 104 | ], 105 | "exclude": [ 106 | "**/node_modules/**" 107 | ] 108 | } 109 | }, 110 | "e2e": { 111 | "builder": "@angular-devkit/build-angular:protractor", 112 | "options": { 113 | "protractorConfig": "e2e/protractor.conf.js", 114 | "devServerTarget": "SmartSchoolApp:serve" 115 | }, 116 | "configurations": { 117 | "production": { 118 | "devServerTarget": "SmartSchoolApp:serve:production" 119 | } 120 | } 121 | } 122 | } 123 | } 124 | }, 125 | "defaultProject": "SmartSchoolApp", 126 | "cli": { 127 | "analytics": false 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /SmartSchoolApp/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, StacktraceOption } = 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({ 31 | spec: { 32 | displayStacktrace: StacktraceOption.PRETTY 33 | } 34 | })); 35 | } 36 | }; -------------------------------------------------------------------------------- /SmartSchoolApp/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('SmartSchoolApp 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 | -------------------------------------------------------------------------------- /SmartSchoolApp/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo(): Promise { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText(): Promise { 9 | return element(by.css('app-root .content span')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SmartSchoolApp/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "../tsconfig.base.json", 4 | "compilerOptions": { 5 | "outDir": "../out-tsc/e2e", 6 | "module": "commonjs", 7 | "target": "es2018", 8 | "types": [ 9 | "jasmine", 10 | "jasminewd2", 11 | "node" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SmartSchoolApp/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/SmartSchoolApp'), 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 | -------------------------------------------------------------------------------- /SmartSchoolApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "smart-school-app", 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": "~10.0.0", 15 | "@angular/common": "~10.0.0", 16 | "@angular/compiler": "~10.0.0", 17 | "@angular/core": "~10.0.0", 18 | "@angular/forms": "~10.0.0", 19 | "@angular/platform-browser": "~10.0.0", 20 | "@angular/platform-browser-dynamic": "~10.0.0", 21 | "@angular/router": "~10.0.0", 22 | "bootstrap": "^4.5.2", 23 | "ngx-bootstrap": "^6.1.0", 24 | "ngx-spinner": "^10.0.1", 25 | "ngx-toastr": "^13.1.0", 26 | "rxjs": "~6.5.5", 27 | "tslib": "^2.0.0", 28 | "zone.js": "~0.10.3" 29 | }, 30 | "devDependencies": { 31 | "@angular-devkit/build-angular": "~0.1000.0", 32 | "@angular/cli": "~10.0.0", 33 | "@angular/compiler-cli": "~10.0.0", 34 | "@types/node": "^12.11.1", 35 | "@types/jasmine": "~3.5.0", 36 | "@types/jasminewd2": "~2.0.3", 37 | "codelyzer": "^6.0.0-next.1", 38 | "jasmine-core": "~3.5.0", 39 | "jasmine-spec-reporter": "~5.0.0", 40 | "karma": "~5.0.0", 41 | "karma-chrome-launcher": "~3.1.0", 42 | "karma-coverage-istanbul-reporter": "~3.0.2", 43 | "karma-jasmine": "~3.3.0", 44 | "karma-jasmine-html-reporter": "^1.5.0", 45 | "protractor": "~7.0.0", 46 | "ts-node": "~8.3.0", 47 | "tslint": "~6.1.0", 48 | "typescript": "~3.9.5" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { AlunosComponent } from './components/alunos/alunos.component'; 4 | import { DashboardComponent } from './components/dashboard/dashboard.component'; 5 | import { PerfilComponent } from './components/perfil/perfil.component'; 6 | import { ProfessoresComponent } from './components/professores/professores.component'; 7 | import { ProfessorDetalheComponent } from './components/professores/professor-detalhe/professor-detalhe.component'; 8 | 9 | const routes: Routes = [ 10 | { path: 'alunos', component: AlunosComponent }, 11 | { path: 'alunos/:id', component: AlunosComponent }, 12 | { path: 'professores', component: ProfessoresComponent }, 13 | { path: 'professor/:id', component: ProfessorDetalheComponent }, 14 | { path: 'perfil', component: PerfilComponent }, 15 | { path: 'dashboard', component: DashboardComponent }, 16 | { path: '', redirectTo: 'dashboard', pathMatch: 'full' }, 17 | { path: '**', redirectTo: 'dashboard', pathMatch: 'full' } 18 | ]; 19 | 20 | @NgModule({ 21 | imports: [RouterModule.forRoot(routes)], 22 | exports: [RouterModule] 23 | }) 24 | export class AppRoutingModule { } 25 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/app.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 | 7 | 8 |

Carregando...

9 |
10 | -------------------------------------------------------------------------------- /SmartSchoolApp/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.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'SmartSchoolApp'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('SmartSchoolApp'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement; 33 | expect(compiled.querySelector('.content span').textContent).toContain('SmartSchoolApp app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 = 'SmartSchoolApp'; 10 | } 11 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { HttpClientModule } from '@angular/common/http'; 4 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 5 | 6 | import { AppRoutingModule } from './app-routing.module'; 7 | import { AppComponent } from './app.component'; 8 | 9 | import { AlunosComponent } from './components/alunos/alunos.component'; 10 | import { AlunosProfessoresComponent } from './components/professores/alunos-professores/alunos-professores.component'; 11 | import { ProfessorDetalheComponent } from './components/professores/professor-detalhe/professor-detalhe.component'; 12 | import { ProfessoresAlunosComponent } from './components/alunos/professores-alunos/professores-alunos.component'; 13 | import { ProfessoresComponent } from './components/professores/professores.component'; 14 | import { PerfilComponent } from './components/perfil/perfil.component'; 15 | import { DashboardComponent } from './components/dashboard/dashboard.component'; 16 | import { TituloComponent } from './components/shared/titulo/titulo.component'; 17 | import { NavComponent } from './components/shared/nav/nav.component'; 18 | 19 | import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; 20 | import { ModalModule } from 'ngx-bootstrap/modal'; 21 | import { PaginationModule } from 'ngx-bootstrap/pagination'; 22 | 23 | import { ToastrModule } from 'ngx-toastr'; 24 | import { NgxSpinnerModule } from 'ngx-spinner'; 25 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; 26 | 27 | @NgModule({ 28 | declarations: [ 29 | AppComponent, 30 | AlunosComponent, 31 | AlunosProfessoresComponent, 32 | ProfessorDetalheComponent, 33 | ProfessoresAlunosComponent, 34 | ProfessoresComponent, 35 | PerfilComponent, 36 | DashboardComponent, 37 | NavComponent, 38 | TituloComponent 39 | ], 40 | imports: [ 41 | BrowserModule, 42 | AppRoutingModule, 43 | FormsModule, 44 | ReactiveFormsModule, 45 | HttpClientModule, 46 | ModalModule.forRoot(), 47 | BsDropdownModule.forRoot(), 48 | PaginationModule.forRoot(), 49 | BrowserAnimationsModule, 50 | NgxSpinnerModule, 51 | ToastrModule.forRoot({ 52 | timeOut: 3500, 53 | positionClass: 'toast-bottom-right', 54 | preventDuplicates: true, 55 | progressBar: true, 56 | closeButton: true 57 | }) 58 | ], 59 | providers: [], 60 | bootstrap: [AppComponent] 61 | }) 62 | export class AppModule { } 63 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/alunos/alunos.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/alunos/alunos.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/alunos/alunos.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |
5 |
6 | 7 |
8 |
9 | 12 |
13 |
14 | 15 |
16 |
17 | 18 | 19 |
20 |
21 | 22 | 23 |
24 |
25 | 26 | 27 |
28 |
29 |
30 | 31 |
32 |
33 |
34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 52 | 53 | 54 | 55 | 65 | 66 | 67 |
Visualizar#Nome CompletotelefoneOpções
51 | {{aluno.id}}{{aluno.nome}}{{aluno.telefone}} 56 |
57 | 59 | 63 |
64 |
68 | 69 |
70 | 71 | 82 | 83 | 84 | 85 |
86 | 87 |
88 | 89 |
90 | 91 | 92 | 95 | 100 | 101 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/alunos/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 { AlunosComponent } from './alunos.component'; 7 | 8 | describe('AlunosComponent', () => { 9 | let component: AlunosComponent; 10 | let fixture: ComponentFixture; 11 | 12 | beforeEach(async(() => { 13 | TestBed.configureTestingModule({ 14 | declarations: [ AlunosComponent ] 15 | }) 16 | .compileComponents(); 17 | })); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(AlunosComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/alunos/alunos.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, OnDestroy, TemplateRef } from '@angular/core'; 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 3 | import { ActivatedRoute } from '@angular/router'; 4 | import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; 5 | import { NgxSpinnerService } from 'ngx-spinner'; 6 | import { ToastrService } from 'ngx-toastr'; 7 | import { Subject } from 'rxjs'; 8 | import { takeUntil } from 'rxjs/operators'; 9 | import { PaginatedResult, Pagination } from 'src/app/models/Pagination'; 10 | 11 | import { Aluno } from '../../models/Aluno'; 12 | import { Professor } from '../../models/Professor'; 13 | 14 | import { AlunoService } from '../../services/aluno.service'; 15 | import { ProfessorService } from '../../services/professor.service'; 16 | 17 | @Component({ 18 | selector: 'app-alunos', 19 | templateUrl: './alunos.component.html', 20 | styleUrls: ['./alunos.component.css'] 21 | }) 22 | export class AlunosComponent implements OnInit, OnDestroy { 23 | 24 | public modalRef: BsModalRef; 25 | public alunoForm: FormGroup; 26 | public titulo = 'Alunos'; 27 | public alunoSelecionado: Aluno; 28 | public textSimple: string; 29 | public profsAlunos: Professor[]; 30 | public alunos: Aluno[]; 31 | public aluno: Aluno; 32 | public modeSave = 'post'; 33 | public msnDeleteAluno: string; 34 | pagination: Pagination; 35 | 36 | private unsubscriber = new Subject(); 37 | 38 | constructor( 39 | private alunoService: AlunoService, 40 | private route: ActivatedRoute, 41 | private professorService: ProfessorService, 42 | private fb: FormBuilder, 43 | private modalService: BsModalService, 44 | private toastr: ToastrService, 45 | private spinner: NgxSpinnerService 46 | ) { 47 | this.criarForm(); 48 | } 49 | 50 | ngOnInit(): void { 51 | this.pagination = { currentPage: 1, itemsPerPage: 4 } as Pagination; 52 | this.carregarAlunos(); 53 | } 54 | 55 | professoresAlunos(template: TemplateRef, id: number): void { 56 | this.spinner.show(); 57 | this.professorService.getByAlunoId(id) 58 | .pipe(takeUntil(this.unsubscriber)) 59 | .subscribe((professores: Professor[]) => { 60 | this.profsAlunos = professores; 61 | this.modalRef = this.modalService.show(template); 62 | }, (error: any) => { 63 | this.toastr.error(`erro: ${error.message}`); 64 | console.error(error.message); 65 | this.spinner.hide(); 66 | }, () => this.spinner.hide() 67 | ); 68 | } 69 | 70 | criarForm(): void { 71 | this.alunoForm = this.fb.group({ 72 | id: [0], 73 | nome: ['', Validators.required], 74 | sobrenome: ['', Validators.required], 75 | telefone: ['', Validators.required], 76 | ativo: [] 77 | }); 78 | } 79 | 80 | trocarEstado(aluno: Aluno) { 81 | this.alunoService.trocarEstado(aluno.id, !aluno.ativo) 82 | .pipe(takeUntil(this.unsubscriber)) 83 | .subscribe( 84 | (resp) => { 85 | console.log(resp); 86 | this.carregarAlunos(); 87 | this.toastr.success('Aluno salvo com sucesso!'); 88 | }, 89 | (error: any) => { 90 | this.toastr.error(`Erro: Aluno não pode ser salvo!`); 91 | console.error(error); 92 | this.spinner.hide(); 93 | }, 94 | () => this.spinner.hide() 95 | ); 96 | } 97 | 98 | saveAluno(): void { 99 | if (this.alunoForm.valid) { 100 | this.spinner.show(); 101 | 102 | if (this.modeSave === 'post') { 103 | this.aluno = {...this.alunoForm.value}; 104 | } else { 105 | this.aluno = {id: this.alunoSelecionado.id, ...this.alunoForm.value}; 106 | } 107 | 108 | this.alunoService[this.modeSave](this.aluno) 109 | .pipe(takeUntil(this.unsubscriber)) 110 | .subscribe( 111 | () => { 112 | this.carregarAlunos(); 113 | this.toastr.success('Aluno salvo com sucesso!'); 114 | }, 115 | (error: any) => { 116 | this.toastr.error(`Erro: Aluno não pode ser salvo!`); 117 | console.error(error); 118 | this.spinner.hide(); 119 | }, 120 | () => this.spinner.hide() 121 | ); 122 | 123 | } 124 | } 125 | 126 | carregarAlunos(): void { 127 | const alunoId = +this.route.snapshot.paramMap.get('id'); 128 | 129 | this.spinner.show(); 130 | this.alunoService.getAll(this.pagination.currentPage, this.pagination.itemsPerPage) 131 | .pipe(takeUntil(this.unsubscriber)) 132 | .subscribe((alunos: PaginatedResult) => { 133 | this.alunos = alunos.result; 134 | this.pagination = alunos.pagination; 135 | 136 | if (alunoId > 0) { 137 | this.alunoSelect(alunoId); 138 | } 139 | 140 | this.toastr.success('Alunos foram carregado com Sucesso!'); 141 | }, 142 | (error: any) => { 143 | this.toastr.error('Alunos não carregados!'); 144 | console.error(error); 145 | this.spinner.hide(); 146 | }, 147 | () => this.spinner.hide() 148 | ); 149 | } 150 | 151 | pageChanged(event: any): void { 152 | this.pagination.currentPage = event.page; 153 | this.carregarAlunos(); 154 | } 155 | 156 | alunoSelect(alunoId: number): void { 157 | this.modeSave = 'patch'; 158 | this.alunoService.getById(alunoId).subscribe( 159 | (alunoReturn) => { 160 | this.alunoSelecionado = alunoReturn; 161 | this.alunoForm.patchValue(this.alunoSelecionado); 162 | }, 163 | (error) => { 164 | this.toastr.error('Alunos não carregados!'); 165 | console.error(error); 166 | this.spinner.hide(); 167 | }, 168 | () => this.spinner.hide() 169 | ); 170 | } 171 | 172 | voltar(): void { 173 | this.alunoSelecionado = null; 174 | } 175 | 176 | openModal(template: TemplateRef, alunoId: number): void { 177 | this.professoresAlunos(template, alunoId); 178 | } 179 | 180 | closeModal(): void { 181 | this.modalRef.hide(); 182 | } 183 | 184 | ngOnDestroy(): void { 185 | this.unsubscriber.next(); 186 | this.unsubscriber.complete(); 187 | } 188 | 189 | } 190 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/alunos/professores-alunos/professores-alunos.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/alunos/professores-alunos/professores-alunos.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/alunos/professores-alunos/professores-alunos.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 |
Visualizar#NomeDisciplina
13 | 14 | {{prof.id}}{{prof.nome}}{{disciplinaConcat(prof.disciplinas)}}
21 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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(): void { 20 | } 21 | 22 | disciplinaConcat(disciplinas: Disciplina[]): string { 23 | return Util.nomeConcat(disciplinas); 24 | } 25 | 26 | professorSelect(prof: Professor): void { 27 | this.closeModal.emit(null); 28 | this.router.navigate(['/professor', prof.id]); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/dashboard/dashboard.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/dashboard/dashboard.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/dashboard/dashboard.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | dashboard works! 5 |

6 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/perfil/perfil.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/perfil/perfil.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/perfil/perfil.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | perfil works! 5 |

6 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/professores/alunos-professores/alunos-professores.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/professores/alunos-professores/alunos-professores.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/professores/alunos-professores/alunos-professores.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
Visualizar#NomeSobrenometelefone
{{aluno.id}}{{aluno.nome}}{{aluno.sobrenome}}{{aluno.telefone}}
21 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | 28 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/professores/professor-detalhe/professor-detalhe.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/professores/professor-detalhe/professor-detalhe.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/professores/professor-detalhe/professor-detalhe.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 |
7 | 10 |
11 |
12 | 13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 36 | 37 | 38 |
#NomeOpções
{{disciplina.id}}{{disciplina.nome}} 31 |
32 | 34 |
35 |
39 |
40 |
41 |
42 | 43 | 44 | 47 | 52 | 53 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/professores/professores.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/professores/professores.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/professores/professores.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 |
Visualizar#NomeDisciplina
16 | Detalhe 17 | {{prof.id}}{{prof.nome}}{{disciplinaConcat(prof.disciplinas)}}
24 |
25 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/shared/nav/nav.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/shared/nav/nav.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/shared/nav/nav.component.html: -------------------------------------------------------------------------------- 1 | 32 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/shared/titulo/titulo.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/app/components/shared/titulo/titulo.component.css -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/shared/titulo/titulo.component.html: -------------------------------------------------------------------------------- 1 |

2 | {{titulo}} 3 |

4 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/components/shared/titulo/titulo.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } 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 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/models/Aluno.ts: -------------------------------------------------------------------------------- 1 | export class Aluno { 2 | id: number; 3 | nome: string; 4 | sobrenome: string; 5 | telefone: number; 6 | ativo: boolean; 7 | } 8 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/models/Disciplina.ts: -------------------------------------------------------------------------------- 1 | 2 | export class Disciplina { 3 | id: number; 4 | nome: string; 5 | professorId: number; 6 | } 7 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/models/Pagination.ts: -------------------------------------------------------------------------------- 1 | export interface Pagination { 2 | currentPage: number; 3 | itemsPerPage: number; 4 | totalItems: number; 5 | totalPages: number; 6 | } 7 | 8 | export class PaginatedResult { 9 | result: T; 10 | pagination: Pagination; 11 | } 12 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/services/aluno.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient, HttpParams } 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 | import { PaginatedResult } from '../models/Pagination'; 9 | import { map, repeat } from 'rxjs/operators'; 10 | 11 | @Injectable({ 12 | providedIn: 'root' 13 | }) 14 | export class AlunoService { 15 | 16 | baseURL = `${environment.mainUrlAPI}aluno`; 17 | 18 | constructor(private http: HttpClient) { } 19 | 20 | getAll(page?: number, itemsPerPage?: number ): Observable> { 21 | const paginatedResult: PaginatedResult = new PaginatedResult(); 22 | 23 | let params = new HttpParams(); 24 | 25 | if (page != null && itemsPerPage != null) { 26 | params = params.append('pageNumber', page.toString()); 27 | params = params.append('pageSize', itemsPerPage.toString()); 28 | } 29 | 30 | return this.http.get(this.baseURL, { observe: 'response', params }) 31 | .pipe( 32 | map(response => { 33 | paginatedResult.result = response.body; 34 | if (response.headers.get('Pagination') != null) { 35 | paginatedResult.pagination = JSON.parse(response.headers.get('Pagination')); 36 | } 37 | return paginatedResult; 38 | }) 39 | ); 40 | } 41 | 42 | getById(id: number): Observable { 43 | return this.http.get(`${this.baseURL}/${id}`); 44 | } 45 | 46 | getByDisciplinaId(id: number): Observable { 47 | return this.http.get(`${this.baseURL}/ByDisciplina/${id}`); 48 | } 49 | 50 | post(aluno: Aluno) { 51 | return this.http.post(this.baseURL, aluno); 52 | } 53 | 54 | put(aluno: Aluno) { 55 | return this.http.put(`${this.baseURL}/${aluno.id}`, aluno); 56 | } 57 | 58 | trocarEstado(alunoId: number, ativo: boolean) { 59 | return this.http.patch(`${this.baseURL}/${alunoId}/trocarEstado`, { Estado: ativo }); 60 | } 61 | 62 | patch(aluno: Aluno) { 63 | return this.http.patch(`${this.baseURL}/${aluno.id}`, aluno); 64 | } 65 | 66 | delete(id: number) { 67 | return this.http.delete(`${this.baseURL}/${id}`); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | } 42 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/app/util/util.ts: -------------------------------------------------------------------------------- 1 | export class Util { 2 | static nomeConcat(item: any[]): string { 3 | return item.map(x => x.nome).join(','); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/assets/.gitkeep -------------------------------------------------------------------------------- /SmartSchoolApp/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | mainUrlAPI: 'http://localhost:5000/api/' 4 | }; 5 | -------------------------------------------------------------------------------- /SmartSchoolApp/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/v1/' 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 | -------------------------------------------------------------------------------- /SmartSchoolApp/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vsandrade/AspNetCoreWebAPI/9bf66150292363544135a074ab8a137bca728d8a/SmartSchoolApp/src/favicon.ico -------------------------------------------------------------------------------- /SmartSchoolApp/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SmartSchoolApp 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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'; 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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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 | -------------------------------------------------------------------------------- /SmartSchoolApp/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: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /SmartSchoolApp/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.base.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /SmartSchoolApp/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "sourceMap": true, 8 | "declaration": false, 9 | "downlevelIteration": true, 10 | "experimentalDecorators": true, 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "module": "es2020", 15 | "lib": [ 16 | "es2018", 17 | "dom" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SmartSchoolApp/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* 2 | This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience. 3 | It is not intended to be used to perform a compilation. 4 | 5 | To learn more about this file see: https://angular.io/config/solution-tsconfig. 6 | */ 7 | { 8 | "files": [], 9 | "references": [ 10 | { 11 | "path": "./tsconfig.app.json" 12 | }, 13 | { 14 | "path": "./tsconfig.spec.json" 15 | }, 16 | { 17 | "path": "./e2e/tsconfig.json" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /SmartSchoolApp/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.base.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 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 | -------------------------------------------------------------------------------- /SmartSchoolApp/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | "align": { 5 | "options": [ 6 | "parameters", 7 | "statements" 8 | ] 9 | }, 10 | "array-type": false, 11 | "arrow-return-shorthand": true, 12 | "curly": true, 13 | "deprecation": { 14 | "severity": "warning" 15 | }, 16 | "component-class-suffix": true, 17 | "contextual-lifecycle": true, 18 | "directive-class-suffix": true, 19 | "directive-selector": [ 20 | true, 21 | "attribute", 22 | "app", 23 | "camelCase" 24 | ], 25 | "component-selector": [ 26 | true, 27 | "element", 28 | "app", 29 | "kebab-case" 30 | ], 31 | "eofline": true, 32 | "import-blacklist": [ 33 | true, 34 | "rxjs/Rx" 35 | ], 36 | "import-spacing": true, 37 | "indent": { 38 | "options": [ 39 | "spaces" 40 | ] 41 | }, 42 | "max-classes-per-file": false, 43 | "max-line-length": [ 44 | true, 45 | 140 46 | ], 47 | "member-ordering": [ 48 | true, 49 | { 50 | "order": [ 51 | "static-field", 52 | "instance-field", 53 | "static-method", 54 | "instance-method" 55 | ] 56 | } 57 | ], 58 | "no-console": [ 59 | true, 60 | "debug", 61 | "info", 62 | "time", 63 | "timeEnd", 64 | "trace" 65 | ], 66 | "no-empty": false, 67 | "no-inferrable-types": [ 68 | true, 69 | "ignore-params" 70 | ], 71 | "no-non-null-assertion": true, 72 | "no-redundant-jsdoc": true, 73 | "no-switch-case-fall-through": true, 74 | "no-var-requires": false, 75 | "object-literal-key-quotes": [ 76 | true, 77 | "as-needed" 78 | ], 79 | "quotemark": [ 80 | true, 81 | "single" 82 | ], 83 | "semicolon": { 84 | "options": [ 85 | "always" 86 | ] 87 | }, 88 | "space-before-function-paren": { 89 | "options": { 90 | "anonymous": "never", 91 | "asyncArrow": "always", 92 | "constructor": "never", 93 | "method": "never", 94 | "named": "never" 95 | } 96 | }, 97 | "typedef": [ 98 | true, 99 | "call-signature" 100 | ], 101 | "typedef-whitespace": { 102 | "options": [ 103 | { 104 | "call-signature": "nospace", 105 | "index-signature": "nospace", 106 | "parameter": "nospace", 107 | "property-declaration": "nospace", 108 | "variable-declaration": "nospace" 109 | }, 110 | { 111 | "call-signature": "onespace", 112 | "index-signature": "onespace", 113 | "parameter": "onespace", 114 | "property-declaration": "onespace", 115 | "variable-declaration": "onespace" 116 | } 117 | ] 118 | }, 119 | "variable-name": { 120 | "options": [ 121 | "ban-keywords", 122 | "check-format", 123 | "allow-pascal-case" 124 | ] 125 | }, 126 | "whitespace": { 127 | "options": [ 128 | "check-branch", 129 | "check-decl", 130 | "check-operator", 131 | "check-separator", 132 | "check-type", 133 | "check-typecast" 134 | ] 135 | }, 136 | "no-conflicting-lifecycle": true, 137 | "no-host-metadata-property": true, 138 | "no-input-rename": true, 139 | "no-inputs-metadata-property": true, 140 | "no-output-native": true, 141 | "no-output-on-prefix": true, 142 | "no-output-rename": true, 143 | "no-outputs-metadata-property": true, 144 | "template-banana-in-box": true, 145 | "template-no-negated-async": true, 146 | "use-lifecycle-interface": true, 147 | "use-pipe-transform-interface": true 148 | }, 149 | "rulesDirectory": [ 150 | "codelyzer" 151 | ] 152 | } --------------------------------------------------------------------------------