├── .gitattributes ├── .gitignore ├── E-Learning-Management-System.sln └── E-Learning-Management-System ├── Controllers ├── AccountController.cs ├── AdminstratorController.cs ├── CertificateController.cs ├── ContentController.cs ├── CourseController.cs ├── InstructorController.cs ├── LearnerController.cs ├── QuizController.cs └── TheQuizzesController.cs ├── DTO ├── AdminstratorDTO.cs ├── CertificateDTO.cs ├── ContentDTO.cs ├── CourseDTO.cs ├── CourseIncludeInstructorDTO.cs ├── InstructorDTO.cs ├── LearnerDTO.cs ├── LoginDTO.cs ├── QuizDTO.cs ├── RegisterDTO.cs ├── Response.cs └── TheQuizzesDTO.cs ├── E-Learning-Management-System.csproj ├── E-Learning-Management-System.http ├── MappingProfile.cs ├── Migrations ├── 20240512195600_nina.Designer.cs ├── 20240512195600_nina.cs ├── 20240515131134_init.Designer.cs ├── 20240515131134_init.cs └── ContextModelSnapshot.cs ├── Models ├── Adminstrator.cs ├── ApplicationUser.cs ├── Certificate.cs ├── Content.cs ├── Context.cs ├── Course.cs ├── Feedback.cs ├── Instructor.cs ├── Learner.cs ├── Quiz.cs └── TheQuizzes.cs ├── Program.cs ├── Properties └── launchSettings.json ├── Repository ├── CourseRepository.cs ├── ICourseRepository.cs ├── IDeletable.cs ├── IRepository.cs └── Repository.cs ├── appsettings.Development.json └── appsettings.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.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 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /E-Learning-Management-System.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.9.34728.123 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "E-Learning-Management-System", "E-Learning-Management-System\E-Learning-Management-System.csproj", "{0F832CCD-A9EC-4C3F-86A1-6E0E41B6AD73}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {0F832CCD-A9EC-4C3F-86A1-6E0E41B6AD73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {0F832CCD-A9EC-4C3F-86A1-6E0E41B6AD73}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {0F832CCD-A9EC-4C3F-86A1-6E0E41B6AD73}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {0F832CCD-A9EC-4C3F-86A1-6E0E41B6AD73}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {C2FA3CB9-F963-40EB-9917-6D9BE41C49E5} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using E_Learning_Management_System.Models; 4 | using Microsoft.AspNetCore.Identity; 5 | using E_Learning_Management_System.DTO; 6 | using Microsoft.IdentityModel.Tokens; 7 | using System.IdentityModel.Tokens.Jwt; 8 | using System.Security.Claims; 9 | using System.Text; 10 | 11 | namespace E_Learning_Management_System.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class AccountController : ControllerBase 16 | { 17 | private readonly UserManager userManager; 18 | private readonly IConfiguration config; 19 | 20 | public AccountController 21 | (UserManager userManager, IConfiguration config) 22 | { 23 | this.userManager = userManager; 24 | this.config = config; 25 | } 26 | [HttpPost("register")] 27 | public async Task Register(RegisterDTO userDto) 28 | { 29 | if (ModelState.IsValid) 30 | { 31 | ApplicationUser appuser = new ApplicationUser() 32 | { 33 | UserName = userDto.UserName, 34 | Email = userDto.Email, 35 | PasswordHash = userDto.Password, 36 | Address= userDto.Address, 37 | AccountType= userDto.AccountType 38 | }; 39 | 40 | IdentityResult result = 41 | await userManager.CreateAsync(appuser, userDto.Password); 42 | if (result.Succeeded) 43 | { 44 | 45 | return Ok(new { message = "Account Created" }); 46 | } 47 | return BadRequest(new { errors = result.Errors }); 48 | } 49 | return BadRequest(ModelState); 50 | } 51 | 52 | [HttpPost("Login")] 53 | public async Task Login(LoginDTO userDto) 54 | { 55 | if (ModelState.IsValid) 56 | { 57 | ApplicationUser? userFromDb = 58 | await userManager.FindByNameAsync(userDto.UserName); 59 | if (userFromDb != null) 60 | { 61 | bool found = await userManager.CheckPasswordAsync(userFromDb, userDto.Password); 62 | if (found) 63 | { 64 | 65 | List myclaims = new List(); 66 | myclaims.Add(new Claim(ClaimTypes.Name, userFromDb.UserName)); 67 | myclaims.Add(new Claim(ClaimTypes.NameIdentifier, userFromDb.Id)); 68 | myclaims.Add(new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())); 69 | 70 | //claim roles 71 | var roles = await userManager.GetRolesAsync(userFromDb); 72 | foreach (var role in roles) 73 | { 74 | myclaims.Add(new Claim(ClaimTypes.Role, role)); 75 | } 76 | 77 | 78 | var SignKey = new SymmetricSecurityKey( 79 | Encoding.UTF8.GetBytes(config["JWT:SecritKey"])); 80 | 81 | SigningCredentials signingCredentials = 82 | new SigningCredentials(SignKey, SecurityAlgorithms.HmacSha256); 83 | 84 | 85 | JwtSecurityToken mytoken = new JwtSecurityToken( 86 | issuer: config["JWT:ValidIss"], 87 | audience: config["JWT:ValidAud"], 88 | expires: DateTime.Now.AddHours(1), 89 | claims: myclaims, 90 | signingCredentials: signingCredentials); 91 | return Ok(new 92 | { 93 | token = new JwtSecurityTokenHandler().WriteToken(mytoken), 94 | expired = mytoken.ValidTo 95 | }); 96 | } 97 | } 98 | return Unauthorized("Invalid account"); 99 | } 100 | return BadRequest(ModelState); 101 | } 102 | 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/AdminstratorController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using E_Learning_Management_System.DTO; 3 | using E_Learning_Management_System.Models; 4 | using E_Learning_Management_System.Repository; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Identity; 8 | using Microsoft.AspNetCore.Mvc; 9 | 10 | namespace E_Learning_Management_System.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class AdminstratorController : ControllerBase 15 | { 16 | 17 | private readonly IRepository AdminRepository; 18 | private readonly UserManager userManager; 19 | private readonly IMapper mapper; 20 | 21 | public AdminstratorController(IRepository adminRepository, UserManager userManager, IMapper mapper) 22 | { 23 | AdminRepository = adminRepository; 24 | this.userManager = userManager; 25 | this.mapper = mapper; 26 | } 27 | 28 | [HttpPost] 29 | [Authorize] 30 | public async Task AddAdmin(AdminstratorDTO adminstratorDTO) 31 | { 32 | if (ModelState.IsValid) 33 | { 34 | var currentUser = await userManager.GetUserAsync(User); 35 | Adminstrator Adminstrator = mapper.Map(adminstratorDTO); 36 | Adminstrator.AccountId = currentUser.Id; 37 | AdminRepository.insert(Adminstrator); 38 | AdminRepository.save(); 39 | return Ok("Adminstrator added successfully"); 40 | 41 | 42 | } 43 | return BadRequest("Invalid Adminstrator data"); 44 | 45 | } 46 | [HttpGet] 47 | [Authorize] 48 | public IActionResult GetAll() 49 | { 50 | List Admins = AdminRepository.GetAll(); 51 | if (Admins != null) 52 | { 53 | List DTOs = new List(); 54 | foreach (Adminstrator adminstrator in Admins) 55 | { 56 | AdminstratorDTO DTO = new AdminstratorDTO(); 57 | DTO.Name = adminstrator.Name; 58 | DTOs.Add(DTO); 59 | } 60 | return Ok(DTOs); 61 | } 62 | return NotFound("There is no Admins"); 63 | } 64 | [HttpGet("ByAdminId/{AdminId:int}")] 65 | [Authorize] 66 | public IActionResult GetAdminByAdminId(int AdminId) 67 | { 68 | var Admin = AdminRepository.Get(c => c.id == AdminId); 69 | if (Admin == null) 70 | { 71 | return NotFound("Admin not found"); 72 | } 73 | AdminstratorDTO adminstratorDTO = mapper.Map(Admin); 74 | return Ok(adminstratorDTO); 75 | } 76 | 77 | [HttpPut("{id}")] 78 | [Authorize] 79 | public async Task UpdateAdminstrator(int id, AdminstratorDTO adminstratorDTO) 80 | { 81 | Adminstrator Adminstrator = AdminRepository.Get(a => a.id == id); 82 | 83 | if (Adminstrator == null) 84 | { 85 | return NotFound("Adminstrator not found"); 86 | } 87 | var currentUser = await userManager.GetUserAsync(User); 88 | Adminstrator.Name = adminstratorDTO.Name; 89 | Adminstrator.AccountId = currentUser.Id; 90 | AdminRepository.update(Adminstrator); 91 | AdminRepository.save(); 92 | return Ok("Adminstrator updated successfully"); 93 | 94 | } 95 | [HttpDelete("{id}")] 96 | [Authorize] 97 | public IActionResult DeleteAdmin(int id) 98 | { 99 | Adminstrator existingAdmin = AdminRepository.Get(a => a.id == id); 100 | if (existingAdmin == null) 101 | { 102 | return NotFound("Admin not found"); 103 | } 104 | AdminRepository.delete(existingAdmin); 105 | AdminRepository.save(); 106 | 107 | return Ok("Admin deleted successfully"); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/CertificateController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using E_Learning_Management_System.DTO; 3 | using E_Learning_Management_System.Models; 4 | using E_Learning_Management_System.Repository; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Identity; 8 | using Microsoft.AspNetCore.Mvc; 9 | using System; 10 | using System.Threading.Tasks; 11 | 12 | namespace E_Learning_Management_System.Controllers 13 | { 14 | [Route("api/[controller]")] 15 | [ApiController] 16 | public class CertificateController : ControllerBase 17 | { 18 | private readonly IRepository certificateRepository; 19 | private readonly UserManager userManager; 20 | private readonly IMapper mapper; 21 | private readonly IRepository quizRepository; 22 | 23 | public CertificateController(IRepository certificateRepository, UserManager userManager, IMapper mapper , IRepository quizRepository) 24 | { 25 | this.certificateRepository = certificateRepository; 26 | this.userManager = userManager; 27 | this.mapper = mapper; 28 | this.quizRepository = quizRepository; 29 | } 30 | 31 | [HttpPost] 32 | [Authorize] 33 | public async Task AddCertificate(CertificateDTO certificateDTO) 34 | { 35 | if (ModelState.IsValid) 36 | { 37 | var currentUser = await userManager.GetUserAsync(User); 38 | var certificate = mapper.Map(certificateDTO); 39 | certificate.Date = DateTime.UtcNow; 40 | certificateRepository.insert(certificate); 41 | certificateRepository.save(); 42 | 43 | return Ok("Certificate added successfully"); 44 | } 45 | return BadRequest("Invalid Certificate"); 46 | } 47 | [HttpPut("{id}")] 48 | [Authorize] 49 | public async Task UpdateCertificate(int id, CertificateDTO certificateDTO) 50 | { 51 | Certificate certificate = certificateRepository.Get(e => e.Id == id); 52 | 53 | if (certificate == null) 54 | { 55 | return NotFound("I not found"); 56 | } 57 | certificate.Date = certificateDTO.Date; 58 | certificateRepository.update(certificate); 59 | certificateRepository.save(); 60 | return Ok("Certificate updated successfully"); 61 | 62 | } 63 | 64 | [HttpDelete("{id}")] 65 | [Authorize] 66 | public IActionResult DeleteCertificate(int id) 67 | { 68 | Certificate certificate = certificateRepository.Get(e => e.Id == id); 69 | if (certificate == null) 70 | { 71 | return NotFound("Certtificate not found"); 72 | } 73 | certificateRepository.delete(certificate); 74 | certificateRepository.save(); 75 | return Ok("Certificate deleted successfully"); 76 | 77 | 78 | } 79 | 80 | [HttpGet] 81 | [Authorize] 82 | public IActionResult GetAll() 83 | { 84 | List certificates = certificateRepository.GetAll(); 85 | if (certificates != null) 86 | { 87 | List certificateDTOs = certificates.Select(e => new CertificateDTO 88 | { 89 | Date = e.Date, 90 | }).ToList(); 91 | return Ok(certificateDTOs); 92 | } 93 | 94 | return NotFound("There is no Certificates"); 95 | } 96 | 97 | [HttpGet("{id}")] 98 | [Authorize] 99 | public IActionResult GetCertficateById(int id) 100 | { 101 | Certificate certificate = certificateRepository.Get(e => e.Id == id); 102 | if (certificate == null) 103 | { 104 | return NotFound("Certtificate not found"); 105 | } 106 | CertificateDTO certificateDTO = mapper.Map(certificate); 107 | return Ok(certificateDTO); 108 | 109 | } 110 | 111 | 112 | 113 | [HttpPost("print")] 114 | [Authorize] 115 | public async Task PrintCertificateForCourse(int theQuizzesId) 116 | { 117 | var quizzesForTheQuizzes = quizRepository.GetAll().Where(q => q.TheQuizzesId == theQuizzesId).ToList(); 118 | 119 | if (quizzesForTheQuizzes == null || !quizzesForTheQuizzes.Any()) 120 | { 121 | return NotFound("No quizzes found for the specified TheQuizzes entity"); 122 | } 123 | 124 | var currentUser = await userManager.GetUserAsync(User); 125 | 126 | // Check if the learner has passed all quizzes associated with the specified TheQuizzes entity 127 | var hasPassedAllQuizzes = CheckIfLearnerPassedAllQuizzes(quizzesForTheQuizzes); 128 | 129 | if (hasPassedAllQuizzes) 130 | { 131 | // Generate and issue the certificate 132 | var certificate = GenerateCertificateForTheQuizzes(currentUser); 133 | 134 | certificateRepository.insert(certificate); 135 | certificateRepository.save(); 136 | 137 | return Ok("Certificate issued successfully"); 138 | } 139 | 140 | return BadRequest("Learner has not passed all quizzes associated with the specified TheQuizzes entity"); 141 | } 142 | 143 | private bool CheckIfLearnerPassedAllQuizzes(IEnumerable quizzesForTheQuizzes) 144 | { 145 | foreach (var quiz in quizzesForTheQuizzes) 146 | { 147 | if (!CheckIfLearnerPassedQuiz(quiz)) 148 | { 149 | // If the learner fails any quiz, return false immediately 150 | return false; 151 | } 152 | } 153 | 154 | // If the loop completes without returning false, it means the learner passed all quizzes 155 | return true; 156 | } 157 | 158 | private Certificate GenerateCertificateForTheQuizzes(ApplicationUser currentUser) 159 | { 160 | // Generate certificate for completing all quizzes associated with the TheQuizzes entity 161 | var certificate = new Certificate 162 | { 163 | Date = DateTime.UtcNow, 164 | // LearnerId = int.Parse(currentUser.Id), 165 | // Add other relevant information for the certificate 166 | }; 167 | 168 | return certificate; 169 | } 170 | 171 | private bool CheckIfLearnerPassedQuiz(Quiz quiz) 172 | { 173 | return quiz.Mark > 55; 174 | } 175 | 176 | 177 | 178 | 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/ContentController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using E_Learning_Management_System.DTO; 3 | using E_Learning_Management_System.Models; 4 | using E_Learning_Management_System.Repository; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Identity; 8 | using Microsoft.AspNetCore.Mvc; 9 | 10 | namespace E_Learning_Management_System.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class ContentController : ControllerBase 15 | { 16 | private readonly IRepository contentRepository; 17 | private readonly ICourseRepository courseRepository; 18 | private readonly UserManager userManager; 19 | private readonly IMapper mapper; 20 | 21 | 22 | public ContentController(ICourseRepository courseRepository,IRepository contentRepository, UserManager userManager, IMapper mapper) 23 | { 24 | this.contentRepository = contentRepository; 25 | this.userManager = userManager; 26 | this.mapper = mapper; 27 | this.courseRepository = courseRepository; 28 | } 29 | 30 | [HttpPost] 31 | [Authorize] 32 | public async Task AddContent(ContentDTO contentDTO) 33 | { 34 | if (ModelState.IsValid) 35 | { 36 | try 37 | { 38 | Content content = new Content 39 | { 40 | Type = contentDTO.Type, 41 | }; 42 | contentRepository.insert(content); 43 | contentRepository.save(); 44 | 45 | return Ok("Content added successfully"); 46 | } 47 | catch (Exception ex) 48 | { 49 | return StatusCode(500, "An error occurred while adding content"); 50 | } 51 | } 52 | return BadRequest("Invalid content data"); 53 | } 54 | 55 | [HttpGet] 56 | // [Authorize] 57 | public IActionResult GetAll() 58 | { 59 | List contents = contentRepository.GetAll(); 60 | if (contents != null) 61 | { 62 | List dtos = contents.Select(c => new ContentDTO 63 | { 64 | Id = c.Id, 65 | Type = c.Type, 66 | content=c.content, 67 | videoPathURL= c.videoPathURL, 68 | }).ToList(); 69 | return Ok(dtos); 70 | } 71 | return NotFound("No content found"); 72 | } 73 | 74 | [HttpGet("{id}")] 75 | [Authorize] 76 | public IActionResult GetContentById(int id) 77 | { 78 | var content = contentRepository.Get(c => c.Id == id); 79 | if (content == null) 80 | { 81 | return NotFound("Content not found"); 82 | } 83 | ContentDTO dto = new ContentDTO 84 | { 85 | Id = content.Id, 86 | Type = content.Type, 87 | content = content.content, 88 | videoPathURL = content.videoPathURL, 89 | }; 90 | return Ok(dto); 91 | } 92 | 93 | [HttpPut("{id}")] 94 | [Authorize] 95 | public async Task UpdateContent(int id, ContentDTO contentDTO) 96 | { 97 | if (ModelState.IsValid) 98 | { 99 | try 100 | { 101 | Content existingContent = contentRepository.Get(c => c.Id == id); 102 | 103 | if (existingContent == null) 104 | { 105 | return NotFound("Content not found"); 106 | } 107 | 108 | existingContent.Type = contentDTO.Type; 109 | contentRepository.update(existingContent); 110 | contentRepository.save(); 111 | 112 | return Ok("Content updated successfully"); 113 | } 114 | catch (Exception ex) 115 | { 116 | return StatusCode(500, "An error occurred while updating content"); 117 | } 118 | } 119 | return BadRequest("Invalid content data"); 120 | } 121 | 122 | [HttpDelete("{id}")] 123 | [Authorize] 124 | public async Task DeleteContent(int id) 125 | { 126 | try 127 | { 128 | Content existingContent = contentRepository.Get(c => c.Id == id); 129 | if (existingContent == null) 130 | { 131 | return NotFound("Content not found"); 132 | } 133 | contentRepository.delete(existingContent); 134 | contentRepository.save(); 135 | 136 | return Ok("Content deleted successfully"); 137 | } 138 | catch (Exception ex) 139 | { 140 | return StatusCode(500, "An error occurred while deleting content"); 141 | } 142 | } 143 | 144 | [HttpGet("course/{courseId}")] 145 | //[Authorize] 146 | public IActionResult GetContentsByCourseId(int courseId) 147 | { 148 | try 149 | { 150 | 151 | var course = courseRepository.Get(c=>c.Id==courseId); 152 | 153 | if (course == null) 154 | { 155 | return NotFound("Course not found"); 156 | } 157 | // List Contents = contentRepository.GetAll().ToList(); 158 | // Retrieve contents associated with the course 159 | List contentDTOs = contentRepository.GetAll() 160 | .Where(c => c.CourseId == courseId) 161 | .Select(c => new ContentDTO 162 | { 163 | Id = c.Id, 164 | Type = c.Type, 165 | content = c.content, // Ensure property names match 166 | videoPathURL = c.videoPathURL 167 | }).ToList(); 168 | 169 | return Ok(contentDTOs); 170 | } 171 | catch (Exception ex) 172 | { 173 | return StatusCode(500, "An error occurred while retrieving contents by course id"); 174 | } 175 | } 176 | 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/CourseController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using E_Learning_Management_System.DTO; 3 | using E_Learning_Management_System.Models; 4 | using E_Learning_Management_System.Repository; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Identity; 7 | using Microsoft.AspNetCore.Mvc; 8 | 9 | namespace E_Learning_Management_System.Controllers 10 | { 11 | [Route("api/[controller]")] 12 | [ApiController] 13 | public class CourseController : ControllerBase 14 | { 15 | private readonly ICourseRepository courseRepository; 16 | private readonly UserManager userManager; 17 | private readonly IMapper mapper; 18 | 19 | //seravia controller 20 | 21 | public CourseController(ICourseRepository courseRepository, UserManager userManager, IMapper mapper) 22 | 23 | { 24 | this.courseRepository = courseRepository; 25 | this.userManager = userManager; 26 | this.mapper = mapper; 27 | } 28 | [HttpPost] 29 | [Authorize] 30 | public async Task AddCoure(CourseDTO courseDTO) 31 | { 32 | if (ModelState.IsValid) 33 | { 34 | var currenUser = await userManager.GetUserAsync(User); 35 | int insId = (int)currenUser.InstructorId; 36 | Course course = mapper.Map(courseDTO); 37 | course.InstructorId = insId; 38 | courseRepository.insert(course); 39 | courseRepository.save(); 40 | return Ok(new 41 | { 42 | Message = "Added successfully" 43 | }); 44 | } 45 | return BadRequest(new 46 | { 47 | Error = "Unable to add course" 48 | }); 49 | } 50 | [HttpGet] 51 | [Authorize] 52 | public IActionResult GetAll() 53 | { 54 | List courses = courseRepository.GetAllIncludeInstructor(); 55 | if (courses != null) 56 | { 57 | List dTOs = new List(); 58 | foreach (Course course in courses) 59 | { 60 | CourseIncludeInstructorDTO dTO = new CourseIncludeInstructorDTO(); 61 | dTO.id= course.Id; 62 | dTO.Name = course.Name; 63 | dTO.ImgPath = course.ImgPath; 64 | dTO.DurationInHours = course.DurationInHours; 65 | dTO.InstructorName = course.Instructor.Name; 66 | 67 | dTOs.Add(dTO); 68 | } 69 | return Ok(dTOs); 70 | } 71 | return NotFound(new 72 | { 73 | Error = "There is no courses" 74 | }); 75 | } 76 | [HttpGet("ByCourseId/{courseId:int}")] 77 | // [Authorize] 78 | public IActionResult GetCourseByCourseId(int courseId) 79 | { 80 | var course = courseRepository.Get(c => c.Id == courseId); 81 | if (course == null) 82 | { 83 | return NotFound(new 84 | { 85 | Error = "Course Not Found" 86 | }); 87 | } 88 | CourseDTO courseDTO = mapper.Map(course); 89 | 90 | return Ok(courseDTO); 91 | 92 | 93 | return Ok(courseDTO); 94 | 95 | } 96 | [HttpGet("byInstructorId/{instructorId:int}")] 97 | [Authorize] 98 | public IActionResult GetCoursesForSpecificInstructor(int instructorId) 99 | { 100 | List courses = courseRepository.GetAll() 101 | .Where(c => c.InstructorId == instructorId).ToList(); 102 | if (courses != null) 103 | { 104 | List dTOs = new List(); 105 | foreach (Course course in courses) 106 | { 107 | CourseDTO dTO = new CourseDTO(); 108 | dTO.Name = course.Name; 109 | dTOs.Add(dTO); 110 | } 111 | return Ok(dTOs); 112 | } 113 | return NotFound(new 114 | { 115 | Error = "No courses found for this instructor." 116 | }); 117 | 118 | } 119 | [HttpPut("{id}")] 120 | [Authorize] 121 | public async Task UpdateCourse(int id, CourseDTO courseDTO) 122 | { 123 | Course existingCourse = courseRepository.Get(c => c.Id == id); 124 | var currenUser = await userManager.GetUserAsync(User); 125 | int insId = (int)currenUser.InstructorId; 126 | if (existingCourse == null) 127 | { 128 | return NotFound(new 129 | { 130 | Error = "courses Not found" 131 | }); 132 | } 133 | existingCourse.Name = courseDTO.Name; 134 | existingCourse.InstructorId = insId; 135 | courseRepository.update(existingCourse); 136 | courseRepository.save(); 137 | 138 | return Ok(new 139 | { 140 | Message = "Course updated successfully" 141 | }); 142 | } 143 | [HttpDelete("{id}")] 144 | [Authorize] 145 | public IActionResult DeleteCourse(int id) 146 | { 147 | Course existingCourse = courseRepository.Get(c => c.Id == id); 148 | if (existingCourse == null) 149 | { 150 | return NotFound(new 151 | { 152 | Error = "Course not found" 153 | }); 154 | 155 | } 156 | courseRepository.delete(existingCourse); 157 | courseRepository.save(); 158 | 159 | return Ok(new 160 | { 161 | Message = "Course Deleted successfully" 162 | }); 163 | } 164 | 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/InstructorController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using E_Learning_Management_System.DTO; 3 | using E_Learning_Management_System.Models; 4 | using E_Learning_Management_System.Repository; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.AspNetCore.Identity; 8 | using Microsoft.AspNetCore.Mvc; 9 | using System.Diagnostics.Metrics; 10 | 11 | namespace E_Learning_Management_System.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | public class InstructorController : ControllerBase 16 | { 17 | private readonly IRepository Insrepository; 18 | private readonly UserManager userManager; 19 | private readonly IMapper mapper; 20 | 21 | public InstructorController(IRepository insrepository, UserManager userManager, IMapper mapper) 22 | { 23 | Insrepository = insrepository; 24 | this.userManager = userManager; 25 | this.mapper = mapper; 26 | } 27 | 28 | [HttpPost] 29 | [Authorize] 30 | public async Task AddInstructor(InstructorDTO instructorDTO) 31 | { 32 | if(ModelState.IsValid) 33 | { 34 | var currentUser = await userManager.GetUserAsync(User); 35 | Instructor instructor= mapper.Map(instructorDTO); 36 | instructor.AccountId = currentUser.Id; 37 | Insrepository.insert(instructor); 38 | Insrepository.save(); 39 | return Ok("Instructor added successfully"); 40 | 41 | 42 | } 43 | return BadRequest("Invalid instructor data"); 44 | 45 | } 46 | [HttpPut("{id}")] 47 | [Authorize] 48 | public async Task UpdateInstructor( int id,InstructorDTO instructorDTO) 49 | { 50 | Instructor instructor = Insrepository.Get(e=>e.Id == id); 51 | 52 | if (instructor == null) 53 | { 54 | return NotFound("Instructor not found"); 55 | } 56 | var currentUser = await userManager.GetUserAsync(User); 57 | instructor.Name = instructorDTO.Name; 58 | instructor.AccountId = currentUser.Id; 59 | Insrepository.update(instructor); 60 | Insrepository.save(); 61 | return Ok("Instructor updated successfully"); 62 | 63 | } 64 | 65 | [HttpDelete("{id}")] 66 | [Authorize] 67 | public IActionResult DeleteInstructor(int id) { 68 | Instructor instructor = Insrepository.Get(e => e.Id == id); 69 | if (instructor == null) 70 | { 71 | return NotFound("Instructor not found"); 72 | } 73 | Insrepository.delete(instructor); 74 | Insrepository.save(); 75 | return Ok("Instructor deleted successfully"); 76 | 77 | 78 | } 79 | [HttpGet] 80 | [Authorize] 81 | public IActionResult GetAll() 82 | { 83 | List instructors = Insrepository.GetAll(); 84 | if(instructors != null) 85 | { 86 | List instructorDTOs = instructors.Select(e=> new InstructorDTO 87 | { 88 | Name = e.Name, 89 | }).ToList(); 90 | return Ok(instructorDTOs); 91 | } 92 | 93 | return NotFound("There is no Instructors"); 94 | } 95 | 96 | [HttpGet("{id}")] 97 | [Authorize] 98 | public IActionResult GetInstructorById(int id) { 99 | 100 | Instructor instructor = Insrepository.Get(e => e.Id == id); 101 | if (instructor == null) 102 | { 103 | return NotFound("Instructor not found"); 104 | } 105 | InstructorDTO instructorDTO = mapper.Map(instructor); 106 | return Ok(instructorDTO); 107 | 108 | } 109 | 110 | 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/LearnerController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using E_Learning_Management_System.DTO; 3 | using E_Learning_Management_System.Models; 4 | using E_Learning_Management_System.Repository; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Identity; 7 | using Microsoft.AspNetCore.Mvc; 8 | 9 | namespace E_Learning_Management_System.Controllers 10 | { 11 | [Route("api/[controller]")] 12 | [ApiController] 13 | public class LearnerController : ControllerBase 14 | { 15 | private readonly IRepository learnerRepository; 16 | private readonly UserManager userManager; 17 | private readonly IMapper mapper; 18 | 19 | //Maria controller 20 | public LearnerController(IRepository learnerRepository, UserManager userManager, IMapper mapper) 21 | { 22 | this.learnerRepository = learnerRepository; 23 | this.userManager = userManager; 24 | this.mapper = mapper; 25 | } 26 | [HttpPost] 27 | [Authorize] 28 | public async Task AddLearner(LearnerDTO learnerDTO) 29 | { 30 | if (ModelState.IsValid) 31 | { 32 | var currenUser = await userManager.GetUserAsync(User); 33 | Learner learner = mapper.Map(learnerDTO); 34 | learner.AccountId = currenUser.Id; 35 | learnerRepository.insert(learner); 36 | learnerRepository.save(); 37 | return Ok("Learner added successfuly"); 38 | 39 | } 40 | return BadRequest("can not add"); 41 | } 42 | [HttpGet] 43 | [Authorize] 44 | public IActionResult GetAll() 45 | { 46 | List learners = learnerRepository.GetAll(); 47 | if (learners != null) 48 | { 49 | List dTOs = new List(); 50 | foreach (Learner learner in learners) 51 | { 52 | LearnerDTO dTO = new LearnerDTO(); 53 | dTO.Name = learner.Name; 54 | dTOs.Add(dTO); 55 | } 56 | return Ok(dTOs); 57 | } 58 | return NotFound("There is no Learners"); 59 | } 60 | [HttpGet("ByLearnerId/{learnerId:int}")] 61 | [Authorize] 62 | public IActionResult GetLearnerByLearnerId(int learnerId) 63 | { 64 | var learner = learnerRepository.Get(c => c.Id == learnerId); 65 | if (learner == null) 66 | { 67 | return NotFound("Learner not found"); 68 | } 69 | LearnerDTO learnerDTO = mapper.Map(learner); 70 | return Ok(learnerDTO); 71 | } 72 | 73 | 74 | [HttpPut("{id}")] 75 | [Authorize] 76 | public async Task UpdateLearner(int id, LearnerDTO learnerDTO) 77 | { 78 | Learner existingLearner = learnerRepository.Get(l => l.Id == id); 79 | var currenUser = await userManager.GetUserAsync(User); 80 | if (existingLearner == null) 81 | { 82 | return NotFound("Learner not found"); 83 | } 84 | var currentUser = await userManager.GetUserAsync(User); 85 | existingLearner.Name = learnerDTO.Name; 86 | existingLearner.AccountId = currentUser.Id; 87 | learnerRepository.update(existingLearner); 88 | learnerRepository.save(); 89 | 90 | return Ok("Learner updated successfully"); 91 | 92 | } 93 | [HttpDelete("{id}")] 94 | //[Authorize] 95 | public IActionResult DeleteLearner(int id) 96 | { 97 | Learner existingLearner = learnerRepository.Get(l => l.Id == id); 98 | if (existingLearner == null) 99 | { 100 | return NotFound("Learner not found"); 101 | } 102 | learnerRepository.delete(existingLearner); 103 | learnerRepository.save(); 104 | 105 | return Ok("Learner deleted successfully"); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/QuizController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using E_Learning_Management_System.DTO; 5 | using E_Learning_Management_System.Models; 6 | using E_Learning_Management_System.Repository; 7 | using Microsoft.AspNetCore.Authorization; 8 | using Microsoft.AspNetCore.Identity; 9 | using Microsoft.AspNetCore.Mvc; 10 | using AutoMapper; 11 | 12 | 13 | 14 | namespace E_Learning_Management_System.Controllers 15 | { 16 | [Route("api/[controller]")] 17 | [ApiController] 18 | public class QuizController : ControllerBase 19 | { 20 | private readonly IRepository quizRepository; 21 | private readonly UserManager userManager; 22 | private readonly IMapper mapper; 23 | 24 | public QuizController(IRepository quizRepository, UserManager userManager, IMapper mapper) 25 | { 26 | this.quizRepository = quizRepository; 27 | this.userManager = userManager; 28 | this.mapper = mapper; 29 | } 30 | 31 | [HttpPost] 32 | [Authorize] 33 | public async Task AddQuiz(QuizDTO quizDTO) 34 | { 35 | if (ModelState.IsValid) 36 | { 37 | var currentUser = await userManager.GetUserAsync(User); 38 | int learnerId = (int)currentUser.LearnerId; 39 | Quiz quiz = mapper.Map(quizDTO); 40 | quiz.LearnerId = learnerId; 41 | quizRepository.insert(quiz); 42 | quizRepository.save(); 43 | return Ok("Quiz added successfully"); 44 | } 45 | return BadRequest("Cannot add quiz"); 46 | } 47 | 48 | [HttpGet] 49 | [Authorize] 50 | public IActionResult GetAll() 51 | { 52 | List quizzes = quizRepository.GetAll(); 53 | if (quizzes != null) 54 | { 55 | List dtos = new List(); 56 | foreach (var quiz in quizzes) 57 | { 58 | QuizDTO dto = new QuizDTO 59 | { 60 | Id = quiz.Id, 61 | Mark = quiz.Mark, 62 | }; 63 | dtos.Add(dto); 64 | } 65 | return Ok(dtos); 66 | } 67 | return NotFound("No quizzes found"); 68 | } 69 | 70 | [HttpGet("{id}")] 71 | [Authorize] 72 | public IActionResult GetQuizById(int id) 73 | { 74 | var quiz = quizRepository.Get(q => q.Id == id); 75 | if (quiz == null) 76 | { 77 | return NotFound("Quiz not found"); 78 | } 79 | QuizDTO dto = mapper.Map(quiz); 80 | return Ok(dto); 81 | } 82 | 83 | [HttpPut("{id}")] 84 | [Authorize] 85 | public IActionResult UpdateQuiz(int id, QuizDTO quizDTO) 86 | { 87 | Quiz existingQuiz = quizRepository.Get(q => q.Id == id); 88 | if (existingQuiz == null) 89 | { 90 | return NotFound("Quiz not found"); 91 | } 92 | mapper.Map(quizDTO, existingQuiz); 93 | quizRepository.update(existingQuiz); 94 | quizRepository.save(); 95 | return Ok("Quiz updated successfully"); 96 | } 97 | 98 | [HttpDelete("{id}")] 99 | [Authorize] 100 | public IActionResult DeleteQuiz(int id) 101 | { 102 | Quiz existingQuiz = quizRepository.Get(q => q.Id == id); 103 | if (existingQuiz == null) 104 | { 105 | return NotFound("Quiz not found"); 106 | } 107 | quizRepository.delete(existingQuiz); 108 | quizRepository.save(); 109 | return Ok("Quiz deleted successfully"); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Controllers/TheQuizzesController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using E_Learning_Management_System.DTO; 3 | using E_Learning_Management_System.Models; 4 | using E_Learning_Management_System.Repository; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Microsoft.AspNetCore.Identity; 7 | using Microsoft.AspNetCore.Mvc; 8 | using System.Linq; 9 | using Microsoft.EntityFrameworkCore; 10 | using System.Collections.Generic; 11 | namespace E_Learning_Management_System.Controllers 12 | { 13 | [Route("api/[controller]")] 14 | [ApiController] 15 | //Maria 16 | public class TheQuizzesController : ControllerBase 17 | { 18 | private readonly IRepository theQuizzesRepository; 19 | private readonly IMapper mapper; 20 | private readonly UserManager userManager; 21 | 22 | public TheQuizzesController(IRepository theQuizzesRepository, UserManager userManager, IMapper mapper) 23 | { 24 | this.theQuizzesRepository = theQuizzesRepository; 25 | this.mapper = mapper; 26 | this.userManager = userManager; 27 | } 28 | 29 | //[HttpPost] 30 | //[Authorize] 31 | //public async Task AddTheQuizzes(TheQuizzesDTO theQuizzesDTO) 32 | //{ 33 | // var currentUser = await userManager.GetUserAsync(User); 34 | // if (currentUser == null || currentUser.InstructorId == null) 35 | // return BadRequest("Current user or InstructorId is null"); 36 | 37 | // int insId = currentUser.InstructorId.Value; 38 | // var theQuizzes = mapper.Map(theQuizzesDTO); 39 | // theQuizzes.InstructorId = insId; 40 | // theQuizzesRepository.insert(theQuizzes); 41 | // theQuizzesRepository.save(); 42 | 43 | // return Ok("TheQuizzes added successfully"); 44 | //} 45 | 46 | [HttpGet] 47 | [Authorize] 48 | public IActionResult GetAllTheQuizzes() 49 | { 50 | List theQuizzes = theQuizzesRepository.GetAll(); 51 | List theQuizzesDTOs = mapper.Map>(theQuizzes); 52 | return Ok(theQuizzesDTOs); 53 | } 54 | 55 | [HttpGet("{id}")] 56 | [Authorize] 57 | public IActionResult GetTheQuizzesById(int id) 58 | { 59 | TheQuizzes theQuizzes = theQuizzesRepository.Get(q => q.Id == id); 60 | if (theQuizzes == null) 61 | { 62 | return NotFound("TheQuizzes not found"); 63 | } 64 | TheQuizzesDTO theQuizzesDTO = mapper.Map(theQuizzes); 65 | return Ok(theQuizzesDTO); 66 | } 67 | 68 | //[HttpPut("{id}")] 69 | //[Authorize] 70 | //public async Task UpdateTheQuizzes(int id, TheQuizzesDTO theQuizzesDTO) 71 | //{ 72 | // TheQuizzes existingTheQuizzes = theQuizzesRepository.Get(q => q.Id == id); 73 | // var currenUser = await userManager.GetUserAsync(User); 74 | // int insId = (int)currenUser.InstructorId; 75 | // if (existingTheQuizzes == null) 76 | // { 77 | // return NotFound("TheQuizzes not found"); 78 | // } 79 | // mapper.Map(theQuizzesDTO, existingTheQuizzes); 80 | // theQuizzesRepository.update(existingTheQuizzes); 81 | // theQuizzesRepository.save(); 82 | // return Ok("TheQuizzes updated successfully"); 83 | //} 84 | 85 | [HttpDelete("{id}")] 86 | [Authorize] 87 | public IActionResult DeleteTheQuizzes(int id) 88 | { 89 | TheQuizzes existingTheQuizzes = theQuizzesRepository.Get(q => q.Id == id); 90 | if (existingTheQuizzes == null) 91 | { 92 | return NotFound("TheQuizzes not found"); 93 | } 94 | theQuizzesRepository.delete(existingTheQuizzes); 95 | theQuizzesRepository.save(); 96 | return Ok("TheQuizzes deleted successfully"); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/AdminstratorDTO.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace E_Learning_Management_System.DTO 4 | { 5 | public class AdminstratorDTO 6 | { 7 | 8 | [Required(ErrorMessage = " Name Is Required")] 9 | [MinLength(3, ErrorMessage = "Name must be 3 char at least")] 10 | public string Name { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/CertificateDTO.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.DTO 2 | { 3 | public class CertificateDTO 4 | { 5 | public DateTime Date { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/ContentDTO.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.DTO 2 | { 3 | public class ContentDTO 4 | { 5 | public int Id { get; set; } 6 | public string Type { get; set; } 7 | public string videoPathURL { get; set; } 8 | public string content { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/CourseDTO.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Models; 2 | 3 | namespace E_Learning_Management_System.DTO 4 | { 5 | public class CourseDTO 6 | { 7 | public String Name { get; set; } 8 | public string ImgPath { get; set; } 9 | public int DurationInHours { get; set; } 10 | 11 | public int instructorId { get; set; } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/CourseIncludeInstructorDTO.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.DTO 2 | { 3 | public class CourseIncludeInstructorDTO 4 | { 5 | public int id { get; set; } 6 | public String Name { get; set; } 7 | public string ImgPath { get; set; } 8 | public string Content { get; set; } 9 | public int DurationInHours { get; set; } 10 | public string InstructorName { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/InstructorDTO.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace E_Learning_Management_System.DTO 4 | { 5 | public class InstructorDTO 6 | { 7 | [Required(ErrorMessage = " Name Is Required")] 8 | [MinLength(3, ErrorMessage = "Name must be 3 char at least")] 9 | public string Name { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/LearnerDTO.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace E_Learning_Management_System.DTO 4 | { 5 | public class LearnerDTO 6 | { 7 | 8 | [Required(ErrorMessage = " Name Is Required")] 9 | [MinLength(3, ErrorMessage = "Name must be 3 char at least")] 10 | public string Name { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/LoginDTO.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.DTO 2 | { 3 | public class LoginDTO 4 | { 5 | public string UserName { get; set; } 6 | public string Password { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/QuizDTO.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.DTO 2 | { 3 | public class QuizDTO 4 | { 5 | public int Id { get; set; } 6 | public double Mark { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/RegisterDTO.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.DTO 2 | { 3 | public class RegisterDTO 4 | { 5 | public string UserName { get; set; } 6 | public string Password { get; set; } 7 | public string Email { get; set; } 8 | public string Address { get; set; } 9 | public string AccountType { get; set; } 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/Response.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.DTO 2 | { 3 | public class Response 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /E-Learning-Management-System/DTO/TheQuizzesDTO.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel.DataAnnotations; 3 | namespace E_Learning_Management_System.DTO 4 | { 5 | public class TheQuizzesDTO 6 | { 7 | public int Id { get; set; } 8 | public int? CertificateId { get; set; } 9 | public int? InstructorId { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /E-Learning-Management-System/E-Learning-Management-System.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | E_Learning_Management_System 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | all 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /E-Learning-Management-System/E-Learning-Management-System.http: -------------------------------------------------------------------------------- 1 | @E_Learning_Management_System_HostAddress = http://localhost:5104 2 | 3 | GET {{E_Learning_Management_System_HostAddress}}/weatherforecast/ 4 | Accept: application/json 5 | 6 | ### 7 | -------------------------------------------------------------------------------- /E-Learning-Management-System/MappingProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using E_Learning_Management_System.DTO; 3 | using E_Learning_Management_System.Models; 4 | 5 | namespace E_Learning_Management_System 6 | { 7 | public class MappingProfile : Profile 8 | { 9 | public MappingProfile() 10 | { 11 | CreateMap(); 12 | CreateMap(); 13 | 14 | CreateMap(); 15 | CreateMap(); 16 | 17 | 18 | CreateMap(); 19 | CreateMap(); 20 | 21 | CreateMap(); 22 | CreateMap(); 23 | 24 | CreateMap(); 25 | CreateMap (); 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | CreateMap(); 48 | CreateMap(); 49 | 50 | CreateMap(); 51 | CreateMap(); 52 | 53 | CreateMap(); 54 | CreateMap(); 55 | 56 | 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Migrations/20240512195600_nina.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using E_Learning_Management_System.Models; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Migrations; 8 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 9 | 10 | #nullable disable 11 | 12 | namespace E_Learning_Management_System.Migrations 13 | { 14 | [DbContext(typeof(Context))] 15 | [Migration("20240512195600_nina")] 16 | partial class nina 17 | { 18 | /// 19 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 20 | { 21 | #pragma warning disable 612, 618 22 | modelBuilder 23 | .HasAnnotation("ProductVersion", "8.0.4") 24 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 25 | 26 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); 27 | 28 | modelBuilder.Entity("CourseLearner", b => 29 | { 30 | b.Property("CoursesId") 31 | .HasColumnType("int"); 32 | 33 | b.Property("LearnersId") 34 | .HasColumnType("int"); 35 | 36 | b.HasKey("CoursesId", "LearnersId"); 37 | 38 | b.HasIndex("LearnersId"); 39 | 40 | b.ToTable("CourseLearner"); 41 | }); 42 | 43 | modelBuilder.Entity("E_Learning_Management_System.Models.Adminstrator", b => 44 | { 45 | b.Property("id") 46 | .ValueGeneratedOnAdd() 47 | .HasColumnType("int"); 48 | 49 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); 50 | 51 | b.Property("AccountId") 52 | .HasColumnType("nvarchar(450)"); 53 | 54 | b.Property("ContentId") 55 | .HasColumnType("int"); 56 | 57 | b.Property("IsDeleted") 58 | .HasColumnType("bit"); 59 | 60 | b.Property("Name") 61 | .IsRequired() 62 | .HasColumnType("nvarchar(max)"); 63 | 64 | b.HasKey("id"); 65 | 66 | b.HasIndex("AccountId"); 67 | 68 | b.HasIndex("ContentId"); 69 | 70 | b.ToTable("Adminstrator"); 71 | }); 72 | 73 | modelBuilder.Entity("E_Learning_Management_System.Models.ApplicationUser", b => 74 | { 75 | b.Property("Id") 76 | .HasColumnType("nvarchar(450)"); 77 | 78 | b.Property("AccessFailedCount") 79 | .HasColumnType("int"); 80 | 81 | b.Property("AccountType") 82 | .IsRequired() 83 | .HasColumnType("nvarchar(max)"); 84 | 85 | b.Property("Address") 86 | .IsRequired() 87 | .HasColumnType("nvarchar(max)"); 88 | 89 | b.Property("AdminstratorId") 90 | .HasColumnType("int"); 91 | 92 | b.Property("ConcurrencyStamp") 93 | .IsConcurrencyToken() 94 | .HasColumnType("nvarchar(max)"); 95 | 96 | b.Property("Email") 97 | .HasMaxLength(256) 98 | .HasColumnType("nvarchar(256)"); 99 | 100 | b.Property("EmailConfirmed") 101 | .HasColumnType("bit"); 102 | 103 | b.Property("InstructorId") 104 | .HasColumnType("int"); 105 | 106 | b.Property("IsDeleted") 107 | .HasColumnType("bit"); 108 | 109 | b.Property("LearnerId") 110 | .HasColumnType("int"); 111 | 112 | b.Property("LockoutEnabled") 113 | .HasColumnType("bit"); 114 | 115 | b.Property("LockoutEnd") 116 | .HasColumnType("datetimeoffset"); 117 | 118 | b.Property("NormalizedEmail") 119 | .HasMaxLength(256) 120 | .HasColumnType("nvarchar(256)"); 121 | 122 | b.Property("NormalizedUserName") 123 | .HasMaxLength(256) 124 | .HasColumnType("nvarchar(256)"); 125 | 126 | b.Property("PasswordHash") 127 | .HasColumnType("nvarchar(max)"); 128 | 129 | b.Property("PhoneNumber") 130 | .HasColumnType("nvarchar(max)"); 131 | 132 | b.Property("PhoneNumberConfirmed") 133 | .HasColumnType("bit"); 134 | 135 | b.Property("SecurityStamp") 136 | .HasColumnType("nvarchar(max)"); 137 | 138 | b.Property("TwoFactorEnabled") 139 | .HasColumnType("bit"); 140 | 141 | b.Property("UserName") 142 | .HasMaxLength(256) 143 | .HasColumnType("nvarchar(256)"); 144 | 145 | b.HasKey("Id"); 146 | 147 | b.HasIndex("AdminstratorId"); 148 | 149 | b.HasIndex("InstructorId"); 150 | 151 | b.HasIndex("LearnerId"); 152 | 153 | b.HasIndex("NormalizedEmail") 154 | .HasDatabaseName("EmailIndex"); 155 | 156 | b.HasIndex("NormalizedUserName") 157 | .IsUnique() 158 | .HasDatabaseName("UserNameIndex") 159 | .HasFilter("[NormalizedUserName] IS NOT NULL"); 160 | 161 | b.ToTable("AspNetUsers", (string)null); 162 | }); 163 | 164 | modelBuilder.Entity("E_Learning_Management_System.Models.Certificate", b => 165 | { 166 | b.Property("Id") 167 | .ValueGeneratedOnAdd() 168 | .HasColumnType("int"); 169 | 170 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 171 | 172 | b.Property("Date") 173 | .HasColumnType("datetime2"); 174 | 175 | b.Property("IsDeleted") 176 | .HasColumnType("bit"); 177 | 178 | b.Property("LearnerId") 179 | .HasColumnType("int"); 180 | 181 | b.Property("QuizId") 182 | .HasColumnType("int"); 183 | 184 | b.HasKey("Id"); 185 | 186 | b.HasIndex("LearnerId"); 187 | 188 | b.HasIndex("QuizId") 189 | .IsUnique() 190 | .HasFilter("[QuizId] IS NOT NULL"); 191 | 192 | b.ToTable("Certificate"); 193 | }); 194 | 195 | modelBuilder.Entity("E_Learning_Management_System.Models.Content", b => 196 | { 197 | b.Property("Id") 198 | .ValueGeneratedOnAdd() 199 | .HasColumnType("int"); 200 | 201 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 202 | 203 | b.Property("AdminstratorId") 204 | .HasColumnType("int"); 205 | 206 | b.Property("CourseId") 207 | .HasColumnType("int"); 208 | 209 | b.Property("IsDeleted") 210 | .HasColumnType("bit"); 211 | 212 | b.Property("LearnerId") 213 | .HasColumnType("int"); 214 | 215 | b.Property("Type") 216 | .IsRequired() 217 | .HasColumnType("nvarchar(max)"); 218 | 219 | b.HasKey("Id"); 220 | 221 | b.HasIndex("AdminstratorId"); 222 | 223 | b.HasIndex("CourseId"); 224 | 225 | b.HasIndex("LearnerId"); 226 | 227 | b.ToTable("Content"); 228 | }); 229 | 230 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 231 | { 232 | b.Property("Id") 233 | .ValueGeneratedOnAdd() 234 | .HasColumnType("int"); 235 | 236 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 237 | 238 | b.Property("InstructorId") 239 | .HasColumnType("int"); 240 | 241 | b.Property("IsDeleted") 242 | .HasColumnType("bit"); 243 | 244 | b.Property("Name") 245 | .IsRequired() 246 | .HasColumnType("nvarchar(max)"); 247 | 248 | b.HasKey("Id"); 249 | 250 | b.HasIndex("InstructorId"); 251 | 252 | b.ToTable("Course"); 253 | }); 254 | 255 | modelBuilder.Entity("E_Learning_Management_System.Models.Feedback", b => 256 | { 257 | b.Property("Id") 258 | .ValueGeneratedOnAdd() 259 | .HasColumnType("int"); 260 | 261 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 262 | 263 | b.Property("InstructorId") 264 | .HasColumnType("int"); 265 | 266 | b.Property("IsDeleted") 267 | .HasColumnType("bit"); 268 | 269 | b.Property("LearnerId") 270 | .HasColumnType("int"); 271 | 272 | b.Property("Message") 273 | .IsRequired() 274 | .HasColumnType("nvarchar(max)"); 275 | 276 | b.Property("QuizId") 277 | .HasColumnType("int"); 278 | 279 | b.HasKey("Id"); 280 | 281 | b.HasIndex("InstructorId"); 282 | 283 | b.HasIndex("LearnerId"); 284 | 285 | b.HasIndex("QuizId"); 286 | 287 | b.ToTable("Feedback"); 288 | }); 289 | 290 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 291 | { 292 | b.Property("Id") 293 | .ValueGeneratedOnAdd() 294 | .HasColumnType("int"); 295 | 296 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 297 | 298 | b.Property("AccountId") 299 | .HasColumnType("nvarchar(450)"); 300 | 301 | b.Property("IsDeleted") 302 | .HasColumnType("bit"); 303 | 304 | b.Property("Name") 305 | .IsRequired() 306 | .HasColumnType("nvarchar(max)"); 307 | 308 | b.HasKey("Id"); 309 | 310 | b.HasIndex("AccountId"); 311 | 312 | b.ToTable("Instructor"); 313 | }); 314 | 315 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 316 | { 317 | b.Property("Id") 318 | .ValueGeneratedOnAdd() 319 | .HasColumnType("int"); 320 | 321 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 322 | 323 | b.Property("AccountId") 324 | .HasColumnType("nvarchar(450)"); 325 | 326 | b.Property("ContentId") 327 | .HasColumnType("int"); 328 | 329 | b.Property("IsDeleted") 330 | .HasColumnType("bit"); 331 | 332 | b.Property("Name") 333 | .IsRequired() 334 | .HasColumnType("nvarchar(max)"); 335 | 336 | b.Property("QuizId") 337 | .HasColumnType("int"); 338 | 339 | b.HasKey("Id"); 340 | 341 | b.HasIndex("AccountId"); 342 | 343 | b.HasIndex("ContentId"); 344 | 345 | b.HasIndex("QuizId"); 346 | 347 | b.ToTable("Learner"); 348 | }); 349 | 350 | modelBuilder.Entity("E_Learning_Management_System.Models.Quiz", b => 351 | { 352 | b.Property("Id") 353 | .ValueGeneratedOnAdd() 354 | .HasColumnType("int"); 355 | 356 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 357 | 358 | b.Property("FeedbackId") 359 | .HasColumnType("int"); 360 | 361 | b.Property("IsDeleted") 362 | .HasColumnType("bit"); 363 | 364 | b.Property("LearnerId") 365 | .HasColumnType("int"); 366 | 367 | b.Property("Mark") 368 | .HasColumnType("float"); 369 | 370 | b.Property("TheQuizzesId") 371 | .HasColumnType("int"); 372 | 373 | b.HasKey("Id"); 374 | 375 | b.HasIndex("FeedbackId"); 376 | 377 | b.HasIndex("LearnerId"); 378 | 379 | b.HasIndex("TheQuizzesId"); 380 | 381 | b.ToTable("Quiz"); 382 | }); 383 | 384 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 385 | { 386 | b.Property("Id") 387 | .ValueGeneratedOnAdd() 388 | .HasColumnType("int"); 389 | 390 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 391 | 392 | b.Property("CertificateId") 393 | .HasColumnType("int"); 394 | 395 | b.Property("InstructorId") 396 | .HasColumnType("int"); 397 | 398 | b.Property("IsDeleted") 399 | .HasColumnType("bit"); 400 | 401 | b.HasKey("Id"); 402 | 403 | b.HasIndex("CertificateId"); 404 | 405 | b.HasIndex("InstructorId"); 406 | 407 | b.ToTable("TheQuizzes"); 408 | }); 409 | 410 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => 411 | { 412 | b.Property("Id") 413 | .HasColumnType("nvarchar(450)"); 414 | 415 | b.Property("ConcurrencyStamp") 416 | .IsConcurrencyToken() 417 | .HasColumnType("nvarchar(max)"); 418 | 419 | b.Property("Name") 420 | .HasMaxLength(256) 421 | .HasColumnType("nvarchar(256)"); 422 | 423 | b.Property("NormalizedName") 424 | .HasMaxLength(256) 425 | .HasColumnType("nvarchar(256)"); 426 | 427 | b.HasKey("Id"); 428 | 429 | b.HasIndex("NormalizedName") 430 | .IsUnique() 431 | .HasDatabaseName("RoleNameIndex") 432 | .HasFilter("[NormalizedName] IS NOT NULL"); 433 | 434 | b.ToTable("AspNetRoles", (string)null); 435 | }); 436 | 437 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 438 | { 439 | b.Property("Id") 440 | .ValueGeneratedOnAdd() 441 | .HasColumnType("int"); 442 | 443 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 444 | 445 | b.Property("ClaimType") 446 | .HasColumnType("nvarchar(max)"); 447 | 448 | b.Property("ClaimValue") 449 | .HasColumnType("nvarchar(max)"); 450 | 451 | b.Property("RoleId") 452 | .IsRequired() 453 | .HasColumnType("nvarchar(450)"); 454 | 455 | b.HasKey("Id"); 456 | 457 | b.HasIndex("RoleId"); 458 | 459 | b.ToTable("AspNetRoleClaims", (string)null); 460 | }); 461 | 462 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 463 | { 464 | b.Property("Id") 465 | .ValueGeneratedOnAdd() 466 | .HasColumnType("int"); 467 | 468 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 469 | 470 | b.Property("ClaimType") 471 | .HasColumnType("nvarchar(max)"); 472 | 473 | b.Property("ClaimValue") 474 | .HasColumnType("nvarchar(max)"); 475 | 476 | b.Property("UserId") 477 | .IsRequired() 478 | .HasColumnType("nvarchar(450)"); 479 | 480 | b.HasKey("Id"); 481 | 482 | b.HasIndex("UserId"); 483 | 484 | b.ToTable("AspNetUserClaims", (string)null); 485 | }); 486 | 487 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 488 | { 489 | b.Property("LoginProvider") 490 | .HasColumnType("nvarchar(450)"); 491 | 492 | b.Property("ProviderKey") 493 | .HasColumnType("nvarchar(450)"); 494 | 495 | b.Property("ProviderDisplayName") 496 | .HasColumnType("nvarchar(max)"); 497 | 498 | b.Property("UserId") 499 | .IsRequired() 500 | .HasColumnType("nvarchar(450)"); 501 | 502 | b.HasKey("LoginProvider", "ProviderKey"); 503 | 504 | b.HasIndex("UserId"); 505 | 506 | b.ToTable("AspNetUserLogins", (string)null); 507 | }); 508 | 509 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 510 | { 511 | b.Property("UserId") 512 | .HasColumnType("nvarchar(450)"); 513 | 514 | b.Property("RoleId") 515 | .HasColumnType("nvarchar(450)"); 516 | 517 | b.HasKey("UserId", "RoleId"); 518 | 519 | b.HasIndex("RoleId"); 520 | 521 | b.ToTable("AspNetUserRoles", (string)null); 522 | }); 523 | 524 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 525 | { 526 | b.Property("UserId") 527 | .HasColumnType("nvarchar(450)"); 528 | 529 | b.Property("LoginProvider") 530 | .HasColumnType("nvarchar(450)"); 531 | 532 | b.Property("Name") 533 | .HasColumnType("nvarchar(450)"); 534 | 535 | b.Property("Value") 536 | .HasColumnType("nvarchar(max)"); 537 | 538 | b.HasKey("UserId", "LoginProvider", "Name"); 539 | 540 | b.ToTable("AspNetUserTokens", (string)null); 541 | }); 542 | 543 | modelBuilder.Entity("CourseLearner", b => 544 | { 545 | b.HasOne("E_Learning_Management_System.Models.Course", null) 546 | .WithMany() 547 | .HasForeignKey("CoursesId") 548 | .OnDelete(DeleteBehavior.Cascade) 549 | .IsRequired(); 550 | 551 | b.HasOne("E_Learning_Management_System.Models.Learner", null) 552 | .WithMany() 553 | .HasForeignKey("LearnersId") 554 | .OnDelete(DeleteBehavior.Cascade) 555 | .IsRequired(); 556 | }); 557 | 558 | modelBuilder.Entity("E_Learning_Management_System.Models.Adminstrator", b => 559 | { 560 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 561 | .WithMany() 562 | .HasForeignKey("AccountId"); 563 | 564 | b.HasOne("E_Learning_Management_System.Models.Content", "Content") 565 | .WithMany() 566 | .HasForeignKey("ContentId"); 567 | 568 | b.Navigation("Account"); 569 | 570 | b.Navigation("Content"); 571 | }); 572 | 573 | modelBuilder.Entity("E_Learning_Management_System.Models.ApplicationUser", b => 574 | { 575 | b.HasOne("E_Learning_Management_System.Models.Adminstrator", "Adminstrator") 576 | .WithMany() 577 | .HasForeignKey("AdminstratorId"); 578 | 579 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 580 | .WithMany() 581 | .HasForeignKey("InstructorId"); 582 | 583 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 584 | .WithMany() 585 | .HasForeignKey("LearnerId"); 586 | 587 | b.Navigation("Adminstrator"); 588 | 589 | b.Navigation("Instructor"); 590 | 591 | b.Navigation("Learner"); 592 | }); 593 | 594 | modelBuilder.Entity("E_Learning_Management_System.Models.Certificate", b => 595 | { 596 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 597 | .WithMany("Certificates") 598 | .HasForeignKey("LearnerId"); 599 | 600 | b.HasOne("E_Learning_Management_System.Models.TheQuizzes", "Quizzes") 601 | .WithOne() 602 | .HasForeignKey("E_Learning_Management_System.Models.Certificate", "QuizId"); 603 | 604 | b.Navigation("Learner"); 605 | 606 | b.Navigation("Quizzes"); 607 | }); 608 | 609 | modelBuilder.Entity("E_Learning_Management_System.Models.Content", b => 610 | { 611 | b.HasOne("E_Learning_Management_System.Models.Adminstrator", "Adminstrator") 612 | .WithMany() 613 | .HasForeignKey("AdminstratorId"); 614 | 615 | b.HasOne("E_Learning_Management_System.Models.Course", "Course") 616 | .WithMany("Contents") 617 | .HasForeignKey("CourseId"); 618 | 619 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 620 | .WithMany() 621 | .HasForeignKey("LearnerId"); 622 | 623 | b.Navigation("Adminstrator"); 624 | 625 | b.Navigation("Course"); 626 | 627 | b.Navigation("Learner"); 628 | }); 629 | 630 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 631 | { 632 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 633 | .WithMany("Coruses") 634 | .HasForeignKey("InstructorId"); 635 | 636 | b.Navigation("Instructor"); 637 | }); 638 | 639 | modelBuilder.Entity("E_Learning_Management_System.Models.Feedback", b => 640 | { 641 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 642 | .WithMany("Feedbacks") 643 | .HasForeignKey("InstructorId"); 644 | 645 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 646 | .WithMany("Feedbacks") 647 | .HasForeignKey("LearnerId"); 648 | 649 | b.HasOne("E_Learning_Management_System.Models.Quiz", "Quiz") 650 | .WithMany() 651 | .HasForeignKey("QuizId"); 652 | 653 | b.Navigation("Instructor"); 654 | 655 | b.Navigation("Learner"); 656 | 657 | b.Navigation("Quiz"); 658 | }); 659 | 660 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 661 | { 662 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 663 | .WithMany() 664 | .HasForeignKey("AccountId"); 665 | 666 | b.Navigation("Account"); 667 | }); 668 | 669 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 670 | { 671 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 672 | .WithMany() 673 | .HasForeignKey("AccountId"); 674 | 675 | b.HasOne("E_Learning_Management_System.Models.Content", "Content") 676 | .WithMany() 677 | .HasForeignKey("ContentId"); 678 | 679 | b.HasOne("E_Learning_Management_System.Models.Quiz", "Quiz") 680 | .WithMany() 681 | .HasForeignKey("QuizId"); 682 | 683 | b.Navigation("Account"); 684 | 685 | b.Navigation("Content"); 686 | 687 | b.Navigation("Quiz"); 688 | }); 689 | 690 | modelBuilder.Entity("E_Learning_Management_System.Models.Quiz", b => 691 | { 692 | b.HasOne("E_Learning_Management_System.Models.Feedback", "Feedback") 693 | .WithMany() 694 | .HasForeignKey("FeedbackId"); 695 | 696 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 697 | .WithMany() 698 | .HasForeignKey("LearnerId"); 699 | 700 | b.HasOne("E_Learning_Management_System.Models.TheQuizzes", "TheQuizzes") 701 | .WithMany("Quizzes") 702 | .HasForeignKey("TheQuizzesId"); 703 | 704 | b.Navigation("Feedback"); 705 | 706 | b.Navigation("Learner"); 707 | 708 | b.Navigation("TheQuizzes"); 709 | }); 710 | 711 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 712 | { 713 | b.HasOne("E_Learning_Management_System.Models.Certificate", "Certificate") 714 | .WithMany() 715 | .HasForeignKey("CertificateId"); 716 | 717 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 718 | .WithMany("TheQuizzes") 719 | .HasForeignKey("InstructorId"); 720 | 721 | b.Navigation("Certificate"); 722 | 723 | b.Navigation("Instructor"); 724 | }); 725 | 726 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 727 | { 728 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 729 | .WithMany() 730 | .HasForeignKey("RoleId") 731 | .OnDelete(DeleteBehavior.Cascade) 732 | .IsRequired(); 733 | }); 734 | 735 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 736 | { 737 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 738 | .WithMany() 739 | .HasForeignKey("UserId") 740 | .OnDelete(DeleteBehavior.Cascade) 741 | .IsRequired(); 742 | }); 743 | 744 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 745 | { 746 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 747 | .WithMany() 748 | .HasForeignKey("UserId") 749 | .OnDelete(DeleteBehavior.Cascade) 750 | .IsRequired(); 751 | }); 752 | 753 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 754 | { 755 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 756 | .WithMany() 757 | .HasForeignKey("RoleId") 758 | .OnDelete(DeleteBehavior.Cascade) 759 | .IsRequired(); 760 | 761 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 762 | .WithMany() 763 | .HasForeignKey("UserId") 764 | .OnDelete(DeleteBehavior.Cascade) 765 | .IsRequired(); 766 | }); 767 | 768 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 769 | { 770 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 771 | .WithMany() 772 | .HasForeignKey("UserId") 773 | .OnDelete(DeleteBehavior.Cascade) 774 | .IsRequired(); 775 | }); 776 | 777 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 778 | { 779 | b.Navigation("Contents"); 780 | }); 781 | 782 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 783 | { 784 | b.Navigation("Coruses"); 785 | 786 | b.Navigation("Feedbacks"); 787 | 788 | b.Navigation("TheQuizzes"); 789 | }); 790 | 791 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 792 | { 793 | b.Navigation("Certificates"); 794 | 795 | b.Navigation("Feedbacks"); 796 | }); 797 | 798 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 799 | { 800 | b.Navigation("Quizzes"); 801 | }); 802 | #pragma warning restore 612, 618 803 | } 804 | } 805 | } 806 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Migrations/20240512195600_nina.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | #nullable disable 5 | 6 | namespace E_Learning_Management_System.Migrations 7 | { 8 | /// 9 | public partial class nina : Migration 10 | { 11 | /// 12 | protected override void Up(MigrationBuilder migrationBuilder) 13 | { 14 | migrationBuilder.CreateTable( 15 | name: "AspNetRoles", 16 | columns: table => new 17 | { 18 | Id = table.Column(type: "nvarchar(450)", nullable: false), 19 | Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), 20 | NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), 21 | ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true) 22 | }, 23 | constraints: table => 24 | { 25 | table.PrimaryKey("PK_AspNetRoles", x => x.Id); 26 | }); 27 | 28 | migrationBuilder.CreateTable( 29 | name: "AspNetRoleClaims", 30 | columns: table => new 31 | { 32 | Id = table.Column(type: "int", nullable: false) 33 | .Annotation("SqlServer:Identity", "1, 1"), 34 | RoleId = table.Column(type: "nvarchar(450)", nullable: false), 35 | ClaimType = table.Column(type: "nvarchar(max)", nullable: true), 36 | ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) 37 | }, 38 | constraints: table => 39 | { 40 | table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id); 41 | table.ForeignKey( 42 | name: "FK_AspNetRoleClaims_AspNetRoles_RoleId", 43 | column: x => x.RoleId, 44 | principalTable: "AspNetRoles", 45 | principalColumn: "Id", 46 | onDelete: ReferentialAction.Cascade); 47 | }); 48 | 49 | migrationBuilder.CreateTable( 50 | name: "Adminstrator", 51 | columns: table => new 52 | { 53 | id = table.Column(type: "int", nullable: false) 54 | .Annotation("SqlServer:Identity", "1, 1"), 55 | Name = table.Column(type: "nvarchar(max)", nullable: false), 56 | IsDeleted = table.Column(type: "bit", nullable: false), 57 | AccountId = table.Column(type: "nvarchar(450)", nullable: true), 58 | ContentId = table.Column(type: "int", nullable: true) 59 | }, 60 | constraints: table => 61 | { 62 | table.PrimaryKey("PK_Adminstrator", x => x.id); 63 | }); 64 | 65 | migrationBuilder.CreateTable( 66 | name: "AspNetUserClaims", 67 | columns: table => new 68 | { 69 | Id = table.Column(type: "int", nullable: false) 70 | .Annotation("SqlServer:Identity", "1, 1"), 71 | UserId = table.Column(type: "nvarchar(450)", nullable: false), 72 | ClaimType = table.Column(type: "nvarchar(max)", nullable: true), 73 | ClaimValue = table.Column(type: "nvarchar(max)", nullable: true) 74 | }, 75 | constraints: table => 76 | { 77 | table.PrimaryKey("PK_AspNetUserClaims", x => x.Id); 78 | }); 79 | 80 | migrationBuilder.CreateTable( 81 | name: "AspNetUserLogins", 82 | columns: table => new 83 | { 84 | LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), 85 | ProviderKey = table.Column(type: "nvarchar(450)", nullable: false), 86 | ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true), 87 | UserId = table.Column(type: "nvarchar(450)", nullable: false) 88 | }, 89 | constraints: table => 90 | { 91 | table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey }); 92 | }); 93 | 94 | migrationBuilder.CreateTable( 95 | name: "AspNetUserRoles", 96 | columns: table => new 97 | { 98 | UserId = table.Column(type: "nvarchar(450)", nullable: false), 99 | RoleId = table.Column(type: "nvarchar(450)", nullable: false) 100 | }, 101 | constraints: table => 102 | { 103 | table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId }); 104 | table.ForeignKey( 105 | name: "FK_AspNetUserRoles_AspNetRoles_RoleId", 106 | column: x => x.RoleId, 107 | principalTable: "AspNetRoles", 108 | principalColumn: "Id", 109 | onDelete: ReferentialAction.Cascade); 110 | }); 111 | 112 | migrationBuilder.CreateTable( 113 | name: "AspNetUsers", 114 | columns: table => new 115 | { 116 | Id = table.Column(type: "nvarchar(450)", nullable: false), 117 | Address = table.Column(type: "nvarchar(max)", nullable: false), 118 | IsDeleted = table.Column(type: "bit", nullable: false), 119 | AccountType = table.Column(type: "nvarchar(max)", nullable: false), 120 | LearnerId = table.Column(type: "int", nullable: true), 121 | InstructorId = table.Column(type: "int", nullable: true), 122 | AdminstratorId = table.Column(type: "int", nullable: true), 123 | UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), 124 | NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), 125 | Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), 126 | NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), 127 | EmailConfirmed = table.Column(type: "bit", nullable: false), 128 | PasswordHash = table.Column(type: "nvarchar(max)", nullable: true), 129 | SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true), 130 | ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true), 131 | PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), 132 | PhoneNumberConfirmed = table.Column(type: "bit", nullable: false), 133 | TwoFactorEnabled = table.Column(type: "bit", nullable: false), 134 | LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), 135 | LockoutEnabled = table.Column(type: "bit", nullable: false), 136 | AccessFailedCount = table.Column(type: "int", nullable: false) 137 | }, 138 | constraints: table => 139 | { 140 | table.PrimaryKey("PK_AspNetUsers", x => x.Id); 141 | table.ForeignKey( 142 | name: "FK_AspNetUsers_Adminstrator_AdminstratorId", 143 | column: x => x.AdminstratorId, 144 | principalTable: "Adminstrator", 145 | principalColumn: "id"); 146 | }); 147 | 148 | migrationBuilder.CreateTable( 149 | name: "AspNetUserTokens", 150 | columns: table => new 151 | { 152 | UserId = table.Column(type: "nvarchar(450)", nullable: false), 153 | LoginProvider = table.Column(type: "nvarchar(450)", nullable: false), 154 | Name = table.Column(type: "nvarchar(450)", nullable: false), 155 | Value = table.Column(type: "nvarchar(max)", nullable: true) 156 | }, 157 | constraints: table => 158 | { 159 | table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); 160 | table.ForeignKey( 161 | name: "FK_AspNetUserTokens_AspNetUsers_UserId", 162 | column: x => x.UserId, 163 | principalTable: "AspNetUsers", 164 | principalColumn: "Id", 165 | onDelete: ReferentialAction.Cascade); 166 | }); 167 | 168 | migrationBuilder.CreateTable( 169 | name: "Instructor", 170 | columns: table => new 171 | { 172 | Id = table.Column(type: "int", nullable: false) 173 | .Annotation("SqlServer:Identity", "1, 1"), 174 | Name = table.Column(type: "nvarchar(max)", nullable: false), 175 | IsDeleted = table.Column(type: "bit", nullable: false), 176 | AccountId = table.Column(type: "nvarchar(450)", nullable: true) 177 | }, 178 | constraints: table => 179 | { 180 | table.PrimaryKey("PK_Instructor", x => x.Id); 181 | table.ForeignKey( 182 | name: "FK_Instructor_AspNetUsers_AccountId", 183 | column: x => x.AccountId, 184 | principalTable: "AspNetUsers", 185 | principalColumn: "Id"); 186 | }); 187 | 188 | migrationBuilder.CreateTable( 189 | name: "Course", 190 | columns: table => new 191 | { 192 | Id = table.Column(type: "int", nullable: false) 193 | .Annotation("SqlServer:Identity", "1, 1"), 194 | Name = table.Column(type: "nvarchar(max)", nullable: false), 195 | IsDeleted = table.Column(type: "bit", nullable: false), 196 | InstructorId = table.Column(type: "int", nullable: true) 197 | }, 198 | constraints: table => 199 | { 200 | table.PrimaryKey("PK_Course", x => x.Id); 201 | table.ForeignKey( 202 | name: "FK_Course_Instructor_InstructorId", 203 | column: x => x.InstructorId, 204 | principalTable: "Instructor", 205 | principalColumn: "Id"); 206 | }); 207 | 208 | migrationBuilder.CreateTable( 209 | name: "Certificate", 210 | columns: table => new 211 | { 212 | Id = table.Column(type: "int", nullable: false) 213 | .Annotation("SqlServer:Identity", "1, 1"), 214 | Date = table.Column(type: "datetime2", nullable: false), 215 | IsDeleted = table.Column(type: "bit", nullable: false), 216 | QuizId = table.Column(type: "int", nullable: true), 217 | LearnerId = table.Column(type: "int", nullable: true) 218 | }, 219 | constraints: table => 220 | { 221 | table.PrimaryKey("PK_Certificate", x => x.Id); 222 | }); 223 | 224 | migrationBuilder.CreateTable( 225 | name: "TheQuizzes", 226 | columns: table => new 227 | { 228 | Id = table.Column(type: "int", nullable: false) 229 | .Annotation("SqlServer:Identity", "1, 1"), 230 | IsDeleted = table.Column(type: "bit", nullable: false), 231 | CertificateId = table.Column(type: "int", nullable: true), 232 | InstructorId = table.Column(type: "int", nullable: true) 233 | }, 234 | constraints: table => 235 | { 236 | table.PrimaryKey("PK_TheQuizzes", x => x.Id); 237 | table.ForeignKey( 238 | name: "FK_TheQuizzes_Certificate_CertificateId", 239 | column: x => x.CertificateId, 240 | principalTable: "Certificate", 241 | principalColumn: "Id"); 242 | table.ForeignKey( 243 | name: "FK_TheQuizzes_Instructor_InstructorId", 244 | column: x => x.InstructorId, 245 | principalTable: "Instructor", 246 | principalColumn: "Id"); 247 | }); 248 | 249 | migrationBuilder.CreateTable( 250 | name: "Content", 251 | columns: table => new 252 | { 253 | Id = table.Column(type: "int", nullable: false) 254 | .Annotation("SqlServer:Identity", "1, 1"), 255 | Type = table.Column(type: "nvarchar(max)", nullable: false), 256 | IsDeleted = table.Column(type: "bit", nullable: false), 257 | CourseId = table.Column(type: "int", nullable: true), 258 | LearnerId = table.Column(type: "int", nullable: true), 259 | AdminstratorId = table.Column(type: "int", nullable: true) 260 | }, 261 | constraints: table => 262 | { 263 | table.PrimaryKey("PK_Content", x => x.Id); 264 | table.ForeignKey( 265 | name: "FK_Content_Adminstrator_AdminstratorId", 266 | column: x => x.AdminstratorId, 267 | principalTable: "Adminstrator", 268 | principalColumn: "id"); 269 | table.ForeignKey( 270 | name: "FK_Content_Course_CourseId", 271 | column: x => x.CourseId, 272 | principalTable: "Course", 273 | principalColumn: "Id"); 274 | }); 275 | 276 | migrationBuilder.CreateTable( 277 | name: "CourseLearner", 278 | columns: table => new 279 | { 280 | CoursesId = table.Column(type: "int", nullable: false), 281 | LearnersId = table.Column(type: "int", nullable: false) 282 | }, 283 | constraints: table => 284 | { 285 | table.PrimaryKey("PK_CourseLearner", x => new { x.CoursesId, x.LearnersId }); 286 | table.ForeignKey( 287 | name: "FK_CourseLearner_Course_CoursesId", 288 | column: x => x.CoursesId, 289 | principalTable: "Course", 290 | principalColumn: "Id", 291 | onDelete: ReferentialAction.Cascade); 292 | }); 293 | 294 | migrationBuilder.CreateTable( 295 | name: "Feedback", 296 | columns: table => new 297 | { 298 | Id = table.Column(type: "int", nullable: false) 299 | .Annotation("SqlServer:Identity", "1, 1"), 300 | Message = table.Column(type: "nvarchar(max)", nullable: false), 301 | IsDeleted = table.Column(type: "bit", nullable: false), 302 | LearnerId = table.Column(type: "int", nullable: true), 303 | InstructorId = table.Column(type: "int", nullable: true), 304 | QuizId = table.Column(type: "int", nullable: true) 305 | }, 306 | constraints: table => 307 | { 308 | table.PrimaryKey("PK_Feedback", x => x.Id); 309 | table.ForeignKey( 310 | name: "FK_Feedback_Instructor_InstructorId", 311 | column: x => x.InstructorId, 312 | principalTable: "Instructor", 313 | principalColumn: "Id"); 314 | }); 315 | 316 | migrationBuilder.CreateTable( 317 | name: "Learner", 318 | columns: table => new 319 | { 320 | Id = table.Column(type: "int", nullable: false) 321 | .Annotation("SqlServer:Identity", "1, 1"), 322 | Name = table.Column(type: "nvarchar(max)", nullable: false), 323 | IsDeleted = table.Column(type: "bit", nullable: false), 324 | AccountId = table.Column(type: "nvarchar(450)", nullable: true), 325 | ContentId = table.Column(type: "int", nullable: true), 326 | QuizId = table.Column(type: "int", nullable: true) 327 | }, 328 | constraints: table => 329 | { 330 | table.PrimaryKey("PK_Learner", x => x.Id); 331 | table.ForeignKey( 332 | name: "FK_Learner_AspNetUsers_AccountId", 333 | column: x => x.AccountId, 334 | principalTable: "AspNetUsers", 335 | principalColumn: "Id"); 336 | table.ForeignKey( 337 | name: "FK_Learner_Content_ContentId", 338 | column: x => x.ContentId, 339 | principalTable: "Content", 340 | principalColumn: "Id"); 341 | }); 342 | 343 | migrationBuilder.CreateTable( 344 | name: "Quiz", 345 | columns: table => new 346 | { 347 | Id = table.Column(type: "int", nullable: false) 348 | .Annotation("SqlServer:Identity", "1, 1"), 349 | Mark = table.Column(type: "float", nullable: false), 350 | IsDeleted = table.Column(type: "bit", nullable: false), 351 | LearnerId = table.Column(type: "int", nullable: true), 352 | FeedbackId = table.Column(type: "int", nullable: true), 353 | TheQuizzesId = table.Column(type: "int", nullable: true) 354 | }, 355 | constraints: table => 356 | { 357 | table.PrimaryKey("PK_Quiz", x => x.Id); 358 | table.ForeignKey( 359 | name: "FK_Quiz_Feedback_FeedbackId", 360 | column: x => x.FeedbackId, 361 | principalTable: "Feedback", 362 | principalColumn: "Id"); 363 | table.ForeignKey( 364 | name: "FK_Quiz_Learner_LearnerId", 365 | column: x => x.LearnerId, 366 | principalTable: "Learner", 367 | principalColumn: "Id"); 368 | table.ForeignKey( 369 | name: "FK_Quiz_TheQuizzes_TheQuizzesId", 370 | column: x => x.TheQuizzesId, 371 | principalTable: "TheQuizzes", 372 | principalColumn: "Id"); 373 | }); 374 | 375 | migrationBuilder.CreateIndex( 376 | name: "IX_Adminstrator_AccountId", 377 | table: "Adminstrator", 378 | column: "AccountId"); 379 | 380 | migrationBuilder.CreateIndex( 381 | name: "IX_Adminstrator_ContentId", 382 | table: "Adminstrator", 383 | column: "ContentId"); 384 | 385 | migrationBuilder.CreateIndex( 386 | name: "IX_AspNetRoleClaims_RoleId", 387 | table: "AspNetRoleClaims", 388 | column: "RoleId"); 389 | 390 | migrationBuilder.CreateIndex( 391 | name: "RoleNameIndex", 392 | table: "AspNetRoles", 393 | column: "NormalizedName", 394 | unique: true, 395 | filter: "[NormalizedName] IS NOT NULL"); 396 | 397 | migrationBuilder.CreateIndex( 398 | name: "IX_AspNetUserClaims_UserId", 399 | table: "AspNetUserClaims", 400 | column: "UserId"); 401 | 402 | migrationBuilder.CreateIndex( 403 | name: "IX_AspNetUserLogins_UserId", 404 | table: "AspNetUserLogins", 405 | column: "UserId"); 406 | 407 | migrationBuilder.CreateIndex( 408 | name: "IX_AspNetUserRoles_RoleId", 409 | table: "AspNetUserRoles", 410 | column: "RoleId"); 411 | 412 | migrationBuilder.CreateIndex( 413 | name: "EmailIndex", 414 | table: "AspNetUsers", 415 | column: "NormalizedEmail"); 416 | 417 | migrationBuilder.CreateIndex( 418 | name: "IX_AspNetUsers_AdminstratorId", 419 | table: "AspNetUsers", 420 | column: "AdminstratorId"); 421 | 422 | migrationBuilder.CreateIndex( 423 | name: "IX_AspNetUsers_InstructorId", 424 | table: "AspNetUsers", 425 | column: "InstructorId"); 426 | 427 | migrationBuilder.CreateIndex( 428 | name: "IX_AspNetUsers_LearnerId", 429 | table: "AspNetUsers", 430 | column: "LearnerId"); 431 | 432 | migrationBuilder.CreateIndex( 433 | name: "UserNameIndex", 434 | table: "AspNetUsers", 435 | column: "NormalizedUserName", 436 | unique: true, 437 | filter: "[NormalizedUserName] IS NOT NULL"); 438 | 439 | migrationBuilder.CreateIndex( 440 | name: "IX_Certificate_LearnerId", 441 | table: "Certificate", 442 | column: "LearnerId"); 443 | 444 | migrationBuilder.CreateIndex( 445 | name: "IX_Certificate_QuizId", 446 | table: "Certificate", 447 | column: "QuizId", 448 | unique: true, 449 | filter: "[QuizId] IS NOT NULL"); 450 | 451 | migrationBuilder.CreateIndex( 452 | name: "IX_Content_AdminstratorId", 453 | table: "Content", 454 | column: "AdminstratorId"); 455 | 456 | migrationBuilder.CreateIndex( 457 | name: "IX_Content_CourseId", 458 | table: "Content", 459 | column: "CourseId"); 460 | 461 | migrationBuilder.CreateIndex( 462 | name: "IX_Content_LearnerId", 463 | table: "Content", 464 | column: "LearnerId"); 465 | 466 | migrationBuilder.CreateIndex( 467 | name: "IX_Course_InstructorId", 468 | table: "Course", 469 | column: "InstructorId"); 470 | 471 | migrationBuilder.CreateIndex( 472 | name: "IX_CourseLearner_LearnersId", 473 | table: "CourseLearner", 474 | column: "LearnersId"); 475 | 476 | migrationBuilder.CreateIndex( 477 | name: "IX_Feedback_InstructorId", 478 | table: "Feedback", 479 | column: "InstructorId"); 480 | 481 | migrationBuilder.CreateIndex( 482 | name: "IX_Feedback_LearnerId", 483 | table: "Feedback", 484 | column: "LearnerId"); 485 | 486 | migrationBuilder.CreateIndex( 487 | name: "IX_Feedback_QuizId", 488 | table: "Feedback", 489 | column: "QuizId"); 490 | 491 | migrationBuilder.CreateIndex( 492 | name: "IX_Instructor_AccountId", 493 | table: "Instructor", 494 | column: "AccountId"); 495 | 496 | migrationBuilder.CreateIndex( 497 | name: "IX_Learner_AccountId", 498 | table: "Learner", 499 | column: "AccountId"); 500 | 501 | migrationBuilder.CreateIndex( 502 | name: "IX_Learner_ContentId", 503 | table: "Learner", 504 | column: "ContentId"); 505 | 506 | migrationBuilder.CreateIndex( 507 | name: "IX_Learner_QuizId", 508 | table: "Learner", 509 | column: "QuizId"); 510 | 511 | migrationBuilder.CreateIndex( 512 | name: "IX_Quiz_FeedbackId", 513 | table: "Quiz", 514 | column: "FeedbackId"); 515 | 516 | migrationBuilder.CreateIndex( 517 | name: "IX_Quiz_LearnerId", 518 | table: "Quiz", 519 | column: "LearnerId"); 520 | 521 | migrationBuilder.CreateIndex( 522 | name: "IX_Quiz_TheQuizzesId", 523 | table: "Quiz", 524 | column: "TheQuizzesId"); 525 | 526 | migrationBuilder.CreateIndex( 527 | name: "IX_TheQuizzes_CertificateId", 528 | table: "TheQuizzes", 529 | column: "CertificateId"); 530 | 531 | migrationBuilder.CreateIndex( 532 | name: "IX_TheQuizzes_InstructorId", 533 | table: "TheQuizzes", 534 | column: "InstructorId"); 535 | 536 | migrationBuilder.AddForeignKey( 537 | name: "FK_Adminstrator_AspNetUsers_AccountId", 538 | table: "Adminstrator", 539 | column: "AccountId", 540 | principalTable: "AspNetUsers", 541 | principalColumn: "Id"); 542 | 543 | migrationBuilder.AddForeignKey( 544 | name: "FK_Adminstrator_Content_ContentId", 545 | table: "Adminstrator", 546 | column: "ContentId", 547 | principalTable: "Content", 548 | principalColumn: "Id"); 549 | 550 | migrationBuilder.AddForeignKey( 551 | name: "FK_AspNetUserClaims_AspNetUsers_UserId", 552 | table: "AspNetUserClaims", 553 | column: "UserId", 554 | principalTable: "AspNetUsers", 555 | principalColumn: "Id", 556 | onDelete: ReferentialAction.Cascade); 557 | 558 | migrationBuilder.AddForeignKey( 559 | name: "FK_AspNetUserLogins_AspNetUsers_UserId", 560 | table: "AspNetUserLogins", 561 | column: "UserId", 562 | principalTable: "AspNetUsers", 563 | principalColumn: "Id", 564 | onDelete: ReferentialAction.Cascade); 565 | 566 | migrationBuilder.AddForeignKey( 567 | name: "FK_AspNetUserRoles_AspNetUsers_UserId", 568 | table: "AspNetUserRoles", 569 | column: "UserId", 570 | principalTable: "AspNetUsers", 571 | principalColumn: "Id", 572 | onDelete: ReferentialAction.Cascade); 573 | 574 | migrationBuilder.AddForeignKey( 575 | name: "FK_AspNetUsers_Instructor_InstructorId", 576 | table: "AspNetUsers", 577 | column: "InstructorId", 578 | principalTable: "Instructor", 579 | principalColumn: "Id"); 580 | 581 | migrationBuilder.AddForeignKey( 582 | name: "FK_AspNetUsers_Learner_LearnerId", 583 | table: "AspNetUsers", 584 | column: "LearnerId", 585 | principalTable: "Learner", 586 | principalColumn: "Id"); 587 | 588 | migrationBuilder.AddForeignKey( 589 | name: "FK_Certificate_Learner_LearnerId", 590 | table: "Certificate", 591 | column: "LearnerId", 592 | principalTable: "Learner", 593 | principalColumn: "Id"); 594 | 595 | migrationBuilder.AddForeignKey( 596 | name: "FK_Certificate_TheQuizzes_QuizId", 597 | table: "Certificate", 598 | column: "QuizId", 599 | principalTable: "TheQuizzes", 600 | principalColumn: "Id"); 601 | 602 | migrationBuilder.AddForeignKey( 603 | name: "FK_Content_Learner_LearnerId", 604 | table: "Content", 605 | column: "LearnerId", 606 | principalTable: "Learner", 607 | principalColumn: "Id"); 608 | 609 | migrationBuilder.AddForeignKey( 610 | name: "FK_CourseLearner_Learner_LearnersId", 611 | table: "CourseLearner", 612 | column: "LearnersId", 613 | principalTable: "Learner", 614 | principalColumn: "Id", 615 | onDelete: ReferentialAction.Cascade); 616 | 617 | migrationBuilder.AddForeignKey( 618 | name: "FK_Feedback_Learner_LearnerId", 619 | table: "Feedback", 620 | column: "LearnerId", 621 | principalTable: "Learner", 622 | principalColumn: "Id"); 623 | 624 | migrationBuilder.AddForeignKey( 625 | name: "FK_Feedback_Quiz_QuizId", 626 | table: "Feedback", 627 | column: "QuizId", 628 | principalTable: "Quiz", 629 | principalColumn: "Id"); 630 | 631 | migrationBuilder.AddForeignKey( 632 | name: "FK_Learner_Quiz_QuizId", 633 | table: "Learner", 634 | column: "QuizId", 635 | principalTable: "Quiz", 636 | principalColumn: "Id"); 637 | } 638 | 639 | /// 640 | protected override void Down(MigrationBuilder migrationBuilder) 641 | { 642 | migrationBuilder.DropForeignKey( 643 | name: "FK_Adminstrator_AspNetUsers_AccountId", 644 | table: "Adminstrator"); 645 | 646 | migrationBuilder.DropForeignKey( 647 | name: "FK_Instructor_AspNetUsers_AccountId", 648 | table: "Instructor"); 649 | 650 | migrationBuilder.DropForeignKey( 651 | name: "FK_Learner_AspNetUsers_AccountId", 652 | table: "Learner"); 653 | 654 | migrationBuilder.DropForeignKey( 655 | name: "FK_Adminstrator_Content_ContentId", 656 | table: "Adminstrator"); 657 | 658 | migrationBuilder.DropForeignKey( 659 | name: "FK_Learner_Content_ContentId", 660 | table: "Learner"); 661 | 662 | migrationBuilder.DropForeignKey( 663 | name: "FK_Feedback_Instructor_InstructorId", 664 | table: "Feedback"); 665 | 666 | migrationBuilder.DropForeignKey( 667 | name: "FK_TheQuizzes_Instructor_InstructorId", 668 | table: "TheQuizzes"); 669 | 670 | migrationBuilder.DropForeignKey( 671 | name: "FK_Certificate_Learner_LearnerId", 672 | table: "Certificate"); 673 | 674 | migrationBuilder.DropForeignKey( 675 | name: "FK_Feedback_Learner_LearnerId", 676 | table: "Feedback"); 677 | 678 | migrationBuilder.DropForeignKey( 679 | name: "FK_Quiz_Learner_LearnerId", 680 | table: "Quiz"); 681 | 682 | migrationBuilder.DropForeignKey( 683 | name: "FK_Certificate_TheQuizzes_QuizId", 684 | table: "Certificate"); 685 | 686 | migrationBuilder.DropForeignKey( 687 | name: "FK_Quiz_TheQuizzes_TheQuizzesId", 688 | table: "Quiz"); 689 | 690 | migrationBuilder.DropForeignKey( 691 | name: "FK_Feedback_Quiz_QuizId", 692 | table: "Feedback"); 693 | 694 | migrationBuilder.DropTable( 695 | name: "AspNetRoleClaims"); 696 | 697 | migrationBuilder.DropTable( 698 | name: "AspNetUserClaims"); 699 | 700 | migrationBuilder.DropTable( 701 | name: "AspNetUserLogins"); 702 | 703 | migrationBuilder.DropTable( 704 | name: "AspNetUserRoles"); 705 | 706 | migrationBuilder.DropTable( 707 | name: "AspNetUserTokens"); 708 | 709 | migrationBuilder.DropTable( 710 | name: "CourseLearner"); 711 | 712 | migrationBuilder.DropTable( 713 | name: "AspNetRoles"); 714 | 715 | migrationBuilder.DropTable( 716 | name: "AspNetUsers"); 717 | 718 | migrationBuilder.DropTable( 719 | name: "Content"); 720 | 721 | migrationBuilder.DropTable( 722 | name: "Adminstrator"); 723 | 724 | migrationBuilder.DropTable( 725 | name: "Course"); 726 | 727 | migrationBuilder.DropTable( 728 | name: "Instructor"); 729 | 730 | migrationBuilder.DropTable( 731 | name: "Learner"); 732 | 733 | migrationBuilder.DropTable( 734 | name: "TheQuizzes"); 735 | 736 | migrationBuilder.DropTable( 737 | name: "Certificate"); 738 | 739 | migrationBuilder.DropTable( 740 | name: "Quiz"); 741 | 742 | migrationBuilder.DropTable( 743 | name: "Feedback"); 744 | } 745 | } 746 | } 747 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Migrations/20240515131134_init.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using E_Learning_Management_System.Models; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Migrations; 8 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 9 | 10 | #nullable disable 11 | 12 | namespace E_Learning_Management_System.Migrations 13 | { 14 | [DbContext(typeof(Context))] 15 | [Migration("20240515131134_init")] 16 | partial class init 17 | { 18 | /// 19 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 20 | { 21 | #pragma warning disable 612, 618 22 | modelBuilder 23 | .HasAnnotation("ProductVersion", "8.0.4") 24 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 25 | 26 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); 27 | 28 | modelBuilder.Entity("CourseLearner", b => 29 | { 30 | b.Property("CoursesId") 31 | .HasColumnType("int"); 32 | 33 | b.Property("LearnersId") 34 | .HasColumnType("int"); 35 | 36 | b.HasKey("CoursesId", "LearnersId"); 37 | 38 | b.HasIndex("LearnersId"); 39 | 40 | b.ToTable("CourseLearner"); 41 | }); 42 | 43 | modelBuilder.Entity("E_Learning_Management_System.Models.Adminstrator", b => 44 | { 45 | b.Property("id") 46 | .ValueGeneratedOnAdd() 47 | .HasColumnType("int"); 48 | 49 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); 50 | 51 | b.Property("AccountId") 52 | .HasColumnType("nvarchar(450)"); 53 | 54 | b.Property("ContentId") 55 | .HasColumnType("int"); 56 | 57 | b.Property("IsDeleted") 58 | .HasColumnType("bit"); 59 | 60 | b.Property("Name") 61 | .IsRequired() 62 | .HasColumnType("nvarchar(max)"); 63 | 64 | b.HasKey("id"); 65 | 66 | b.HasIndex("AccountId"); 67 | 68 | b.HasIndex("ContentId"); 69 | 70 | b.ToTable("Adminstrator"); 71 | }); 72 | 73 | modelBuilder.Entity("E_Learning_Management_System.Models.ApplicationUser", b => 74 | { 75 | b.Property("Id") 76 | .HasColumnType("nvarchar(450)"); 77 | 78 | b.Property("AccessFailedCount") 79 | .HasColumnType("int"); 80 | 81 | b.Property("AccountType") 82 | .IsRequired() 83 | .HasColumnType("nvarchar(max)"); 84 | 85 | b.Property("Address") 86 | .IsRequired() 87 | .HasColumnType("nvarchar(max)"); 88 | 89 | b.Property("AdminstratorId") 90 | .HasColumnType("int"); 91 | 92 | b.Property("ConcurrencyStamp") 93 | .IsConcurrencyToken() 94 | .HasColumnType("nvarchar(max)"); 95 | 96 | b.Property("Email") 97 | .HasMaxLength(256) 98 | .HasColumnType("nvarchar(256)"); 99 | 100 | b.Property("EmailConfirmed") 101 | .HasColumnType("bit"); 102 | 103 | b.Property("InstructorId") 104 | .HasColumnType("int"); 105 | 106 | b.Property("IsDeleted") 107 | .HasColumnType("bit"); 108 | 109 | b.Property("LearnerId") 110 | .HasColumnType("int"); 111 | 112 | b.Property("LockoutEnabled") 113 | .HasColumnType("bit"); 114 | 115 | b.Property("LockoutEnd") 116 | .HasColumnType("datetimeoffset"); 117 | 118 | b.Property("NormalizedEmail") 119 | .HasMaxLength(256) 120 | .HasColumnType("nvarchar(256)"); 121 | 122 | b.Property("NormalizedUserName") 123 | .HasMaxLength(256) 124 | .HasColumnType("nvarchar(256)"); 125 | 126 | b.Property("PasswordHash") 127 | .HasColumnType("nvarchar(max)"); 128 | 129 | b.Property("PhoneNumber") 130 | .HasColumnType("nvarchar(max)"); 131 | 132 | b.Property("PhoneNumberConfirmed") 133 | .HasColumnType("bit"); 134 | 135 | b.Property("SecurityStamp") 136 | .HasColumnType("nvarchar(max)"); 137 | 138 | b.Property("TwoFactorEnabled") 139 | .HasColumnType("bit"); 140 | 141 | b.Property("UserName") 142 | .HasMaxLength(256) 143 | .HasColumnType("nvarchar(256)"); 144 | 145 | b.HasKey("Id"); 146 | 147 | b.HasIndex("AdminstratorId"); 148 | 149 | b.HasIndex("InstructorId"); 150 | 151 | b.HasIndex("LearnerId"); 152 | 153 | b.HasIndex("NormalizedEmail") 154 | .HasDatabaseName("EmailIndex"); 155 | 156 | b.HasIndex("NormalizedUserName") 157 | .IsUnique() 158 | .HasDatabaseName("UserNameIndex") 159 | .HasFilter("[NormalizedUserName] IS NOT NULL"); 160 | 161 | b.ToTable("AspNetUsers", (string)null); 162 | }); 163 | 164 | modelBuilder.Entity("E_Learning_Management_System.Models.Certificate", b => 165 | { 166 | b.Property("Id") 167 | .ValueGeneratedOnAdd() 168 | .HasColumnType("int"); 169 | 170 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 171 | 172 | b.Property("Date") 173 | .HasColumnType("datetime2"); 174 | 175 | b.Property("IsDeleted") 176 | .HasColumnType("bit"); 177 | 178 | b.Property("LearnerId") 179 | .HasColumnType("int"); 180 | 181 | b.Property("QuizId") 182 | .HasColumnType("int"); 183 | 184 | b.HasKey("Id"); 185 | 186 | b.HasIndex("LearnerId"); 187 | 188 | b.HasIndex("QuizId") 189 | .IsUnique() 190 | .HasFilter("[QuizId] IS NOT NULL"); 191 | 192 | b.ToTable("Certificate"); 193 | }); 194 | 195 | modelBuilder.Entity("E_Learning_Management_System.Models.Content", b => 196 | { 197 | b.Property("Id") 198 | .ValueGeneratedOnAdd() 199 | .HasColumnType("int"); 200 | 201 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 202 | 203 | b.Property("AdminstratorId") 204 | .HasColumnType("int"); 205 | 206 | b.Property("CourseId") 207 | .HasColumnType("int"); 208 | 209 | b.Property("IsDeleted") 210 | .HasColumnType("bit"); 211 | 212 | b.Property("LearnerId") 213 | .HasColumnType("int"); 214 | 215 | b.Property("Type") 216 | .IsRequired() 217 | .HasColumnType("nvarchar(max)"); 218 | 219 | b.Property("content") 220 | .IsRequired() 221 | .HasColumnType("nvarchar(max)"); 222 | 223 | b.Property("videoPathURL") 224 | .IsRequired() 225 | .HasColumnType("nvarchar(max)"); 226 | 227 | b.HasKey("Id"); 228 | 229 | b.HasIndex("AdminstratorId"); 230 | 231 | b.HasIndex("CourseId"); 232 | 233 | b.HasIndex("LearnerId"); 234 | 235 | b.ToTable("Content"); 236 | }); 237 | 238 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 239 | { 240 | b.Property("Id") 241 | .ValueGeneratedOnAdd() 242 | .HasColumnType("int"); 243 | 244 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 245 | 246 | b.Property("DurationInHours") 247 | .HasColumnType("int"); 248 | 249 | b.Property("ImgPath") 250 | .IsRequired() 251 | .HasColumnType("nvarchar(max)"); 252 | 253 | b.Property("InstructorId") 254 | .HasColumnType("int"); 255 | 256 | b.Property("IsDeleted") 257 | .HasColumnType("bit"); 258 | 259 | b.Property("Name") 260 | .IsRequired() 261 | .HasColumnType("nvarchar(max)"); 262 | 263 | b.HasKey("Id"); 264 | 265 | b.HasIndex("InstructorId"); 266 | 267 | b.ToTable("Course"); 268 | }); 269 | 270 | modelBuilder.Entity("E_Learning_Management_System.Models.Feedback", b => 271 | { 272 | b.Property("Id") 273 | .ValueGeneratedOnAdd() 274 | .HasColumnType("int"); 275 | 276 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 277 | 278 | b.Property("InstructorId") 279 | .HasColumnType("int"); 280 | 281 | b.Property("IsDeleted") 282 | .HasColumnType("bit"); 283 | 284 | b.Property("LearnerId") 285 | .HasColumnType("int"); 286 | 287 | b.Property("Message") 288 | .IsRequired() 289 | .HasColumnType("nvarchar(max)"); 290 | 291 | b.Property("QuizId") 292 | .HasColumnType("int"); 293 | 294 | b.HasKey("Id"); 295 | 296 | b.HasIndex("InstructorId"); 297 | 298 | b.HasIndex("LearnerId"); 299 | 300 | b.HasIndex("QuizId"); 301 | 302 | b.ToTable("Feedback"); 303 | }); 304 | 305 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 306 | { 307 | b.Property("Id") 308 | .ValueGeneratedOnAdd() 309 | .HasColumnType("int"); 310 | 311 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 312 | 313 | b.Property("AccountId") 314 | .HasColumnType("nvarchar(450)"); 315 | 316 | b.Property("IsDeleted") 317 | .HasColumnType("bit"); 318 | 319 | b.Property("Name") 320 | .IsRequired() 321 | .HasColumnType("nvarchar(max)"); 322 | 323 | b.HasKey("Id"); 324 | 325 | b.HasIndex("AccountId"); 326 | 327 | b.ToTable("Instructor"); 328 | }); 329 | 330 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 331 | { 332 | b.Property("Id") 333 | .ValueGeneratedOnAdd() 334 | .HasColumnType("int"); 335 | 336 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 337 | 338 | b.Property("AccountId") 339 | .HasColumnType("nvarchar(450)"); 340 | 341 | b.Property("ContentId") 342 | .HasColumnType("int"); 343 | 344 | b.Property("IsDeleted") 345 | .HasColumnType("bit"); 346 | 347 | b.Property("Name") 348 | .IsRequired() 349 | .HasColumnType("nvarchar(max)"); 350 | 351 | b.Property("QuizId") 352 | .HasColumnType("int"); 353 | 354 | b.HasKey("Id"); 355 | 356 | b.HasIndex("AccountId"); 357 | 358 | b.HasIndex("ContentId"); 359 | 360 | b.HasIndex("QuizId"); 361 | 362 | b.ToTable("Learner"); 363 | }); 364 | 365 | modelBuilder.Entity("E_Learning_Management_System.Models.Quiz", b => 366 | { 367 | b.Property("Id") 368 | .ValueGeneratedOnAdd() 369 | .HasColumnType("int"); 370 | 371 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 372 | 373 | b.Property("FeedbackId") 374 | .HasColumnType("int"); 375 | 376 | b.Property("IsDeleted") 377 | .HasColumnType("bit"); 378 | 379 | b.Property("LearnerId") 380 | .HasColumnType("int"); 381 | 382 | b.Property("Mark") 383 | .HasColumnType("float"); 384 | 385 | b.Property("TheQuizzesId") 386 | .HasColumnType("int"); 387 | 388 | b.HasKey("Id"); 389 | 390 | b.HasIndex("FeedbackId"); 391 | 392 | b.HasIndex("LearnerId"); 393 | 394 | b.HasIndex("TheQuizzesId"); 395 | 396 | b.ToTable("Quiz"); 397 | }); 398 | 399 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 400 | { 401 | b.Property("Id") 402 | .ValueGeneratedOnAdd() 403 | .HasColumnType("int"); 404 | 405 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 406 | 407 | b.Property("CertificateId") 408 | .HasColumnType("int"); 409 | 410 | b.Property("InstructorId") 411 | .HasColumnType("int"); 412 | 413 | b.Property("IsDeleted") 414 | .HasColumnType("bit"); 415 | 416 | b.HasKey("Id"); 417 | 418 | b.HasIndex("CertificateId"); 419 | 420 | b.HasIndex("InstructorId"); 421 | 422 | b.ToTable("TheQuizzes"); 423 | }); 424 | 425 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => 426 | { 427 | b.Property("Id") 428 | .HasColumnType("nvarchar(450)"); 429 | 430 | b.Property("ConcurrencyStamp") 431 | .IsConcurrencyToken() 432 | .HasColumnType("nvarchar(max)"); 433 | 434 | b.Property("Name") 435 | .HasMaxLength(256) 436 | .HasColumnType("nvarchar(256)"); 437 | 438 | b.Property("NormalizedName") 439 | .HasMaxLength(256) 440 | .HasColumnType("nvarchar(256)"); 441 | 442 | b.HasKey("Id"); 443 | 444 | b.HasIndex("NormalizedName") 445 | .IsUnique() 446 | .HasDatabaseName("RoleNameIndex") 447 | .HasFilter("[NormalizedName] IS NOT NULL"); 448 | 449 | b.ToTable("AspNetRoles", (string)null); 450 | }); 451 | 452 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 453 | { 454 | b.Property("Id") 455 | .ValueGeneratedOnAdd() 456 | .HasColumnType("int"); 457 | 458 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 459 | 460 | b.Property("ClaimType") 461 | .HasColumnType("nvarchar(max)"); 462 | 463 | b.Property("ClaimValue") 464 | .HasColumnType("nvarchar(max)"); 465 | 466 | b.Property("RoleId") 467 | .IsRequired() 468 | .HasColumnType("nvarchar(450)"); 469 | 470 | b.HasKey("Id"); 471 | 472 | b.HasIndex("RoleId"); 473 | 474 | b.ToTable("AspNetRoleClaims", (string)null); 475 | }); 476 | 477 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 478 | { 479 | b.Property("Id") 480 | .ValueGeneratedOnAdd() 481 | .HasColumnType("int"); 482 | 483 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 484 | 485 | b.Property("ClaimType") 486 | .HasColumnType("nvarchar(max)"); 487 | 488 | b.Property("ClaimValue") 489 | .HasColumnType("nvarchar(max)"); 490 | 491 | b.Property("UserId") 492 | .IsRequired() 493 | .HasColumnType("nvarchar(450)"); 494 | 495 | b.HasKey("Id"); 496 | 497 | b.HasIndex("UserId"); 498 | 499 | b.ToTable("AspNetUserClaims", (string)null); 500 | }); 501 | 502 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 503 | { 504 | b.Property("LoginProvider") 505 | .HasColumnType("nvarchar(450)"); 506 | 507 | b.Property("ProviderKey") 508 | .HasColumnType("nvarchar(450)"); 509 | 510 | b.Property("ProviderDisplayName") 511 | .HasColumnType("nvarchar(max)"); 512 | 513 | b.Property("UserId") 514 | .IsRequired() 515 | .HasColumnType("nvarchar(450)"); 516 | 517 | b.HasKey("LoginProvider", "ProviderKey"); 518 | 519 | b.HasIndex("UserId"); 520 | 521 | b.ToTable("AspNetUserLogins", (string)null); 522 | }); 523 | 524 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 525 | { 526 | b.Property("UserId") 527 | .HasColumnType("nvarchar(450)"); 528 | 529 | b.Property("RoleId") 530 | .HasColumnType("nvarchar(450)"); 531 | 532 | b.HasKey("UserId", "RoleId"); 533 | 534 | b.HasIndex("RoleId"); 535 | 536 | b.ToTable("AspNetUserRoles", (string)null); 537 | }); 538 | 539 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 540 | { 541 | b.Property("UserId") 542 | .HasColumnType("nvarchar(450)"); 543 | 544 | b.Property("LoginProvider") 545 | .HasColumnType("nvarchar(450)"); 546 | 547 | b.Property("Name") 548 | .HasColumnType("nvarchar(450)"); 549 | 550 | b.Property("Value") 551 | .HasColumnType("nvarchar(max)"); 552 | 553 | b.HasKey("UserId", "LoginProvider", "Name"); 554 | 555 | b.ToTable("AspNetUserTokens", (string)null); 556 | }); 557 | 558 | modelBuilder.Entity("CourseLearner", b => 559 | { 560 | b.HasOne("E_Learning_Management_System.Models.Course", null) 561 | .WithMany() 562 | .HasForeignKey("CoursesId") 563 | .OnDelete(DeleteBehavior.Cascade) 564 | .IsRequired(); 565 | 566 | b.HasOne("E_Learning_Management_System.Models.Learner", null) 567 | .WithMany() 568 | .HasForeignKey("LearnersId") 569 | .OnDelete(DeleteBehavior.Cascade) 570 | .IsRequired(); 571 | }); 572 | 573 | modelBuilder.Entity("E_Learning_Management_System.Models.Adminstrator", b => 574 | { 575 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 576 | .WithMany() 577 | .HasForeignKey("AccountId"); 578 | 579 | b.HasOne("E_Learning_Management_System.Models.Content", "Content") 580 | .WithMany() 581 | .HasForeignKey("ContentId"); 582 | 583 | b.Navigation("Account"); 584 | 585 | b.Navigation("Content"); 586 | }); 587 | 588 | modelBuilder.Entity("E_Learning_Management_System.Models.ApplicationUser", b => 589 | { 590 | b.HasOne("E_Learning_Management_System.Models.Adminstrator", "Adminstrator") 591 | .WithMany() 592 | .HasForeignKey("AdminstratorId"); 593 | 594 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 595 | .WithMany() 596 | .HasForeignKey("InstructorId"); 597 | 598 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 599 | .WithMany() 600 | .HasForeignKey("LearnerId"); 601 | 602 | b.Navigation("Adminstrator"); 603 | 604 | b.Navigation("Instructor"); 605 | 606 | b.Navigation("Learner"); 607 | }); 608 | 609 | modelBuilder.Entity("E_Learning_Management_System.Models.Certificate", b => 610 | { 611 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 612 | .WithMany("Certificates") 613 | .HasForeignKey("LearnerId"); 614 | 615 | b.HasOne("E_Learning_Management_System.Models.TheQuizzes", "Quizzes") 616 | .WithOne() 617 | .HasForeignKey("E_Learning_Management_System.Models.Certificate", "QuizId"); 618 | 619 | b.Navigation("Learner"); 620 | 621 | b.Navigation("Quizzes"); 622 | }); 623 | 624 | modelBuilder.Entity("E_Learning_Management_System.Models.Content", b => 625 | { 626 | b.HasOne("E_Learning_Management_System.Models.Adminstrator", "Adminstrator") 627 | .WithMany() 628 | .HasForeignKey("AdminstratorId"); 629 | 630 | b.HasOne("E_Learning_Management_System.Models.Course", "Course") 631 | .WithMany("Contents") 632 | .HasForeignKey("CourseId"); 633 | 634 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 635 | .WithMany() 636 | .HasForeignKey("LearnerId"); 637 | 638 | b.Navigation("Adminstrator"); 639 | 640 | b.Navigation("Course"); 641 | 642 | b.Navigation("Learner"); 643 | }); 644 | 645 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 646 | { 647 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 648 | .WithMany("Coruses") 649 | .HasForeignKey("InstructorId"); 650 | 651 | b.Navigation("Instructor"); 652 | }); 653 | 654 | modelBuilder.Entity("E_Learning_Management_System.Models.Feedback", b => 655 | { 656 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 657 | .WithMany("Feedbacks") 658 | .HasForeignKey("InstructorId"); 659 | 660 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 661 | .WithMany("Feedbacks") 662 | .HasForeignKey("LearnerId"); 663 | 664 | b.HasOne("E_Learning_Management_System.Models.Quiz", "Quiz") 665 | .WithMany() 666 | .HasForeignKey("QuizId"); 667 | 668 | b.Navigation("Instructor"); 669 | 670 | b.Navigation("Learner"); 671 | 672 | b.Navigation("Quiz"); 673 | }); 674 | 675 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 676 | { 677 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 678 | .WithMany() 679 | .HasForeignKey("AccountId"); 680 | 681 | b.Navigation("Account"); 682 | }); 683 | 684 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 685 | { 686 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 687 | .WithMany() 688 | .HasForeignKey("AccountId"); 689 | 690 | b.HasOne("E_Learning_Management_System.Models.Content", "Content") 691 | .WithMany() 692 | .HasForeignKey("ContentId"); 693 | 694 | b.HasOne("E_Learning_Management_System.Models.Quiz", "Quiz") 695 | .WithMany() 696 | .HasForeignKey("QuizId"); 697 | 698 | b.Navigation("Account"); 699 | 700 | b.Navigation("Content"); 701 | 702 | b.Navigation("Quiz"); 703 | }); 704 | 705 | modelBuilder.Entity("E_Learning_Management_System.Models.Quiz", b => 706 | { 707 | b.HasOne("E_Learning_Management_System.Models.Feedback", "Feedback") 708 | .WithMany() 709 | .HasForeignKey("FeedbackId"); 710 | 711 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 712 | .WithMany() 713 | .HasForeignKey("LearnerId"); 714 | 715 | b.HasOne("E_Learning_Management_System.Models.TheQuizzes", "TheQuizzes") 716 | .WithMany("Quizzes") 717 | .HasForeignKey("TheQuizzesId"); 718 | 719 | b.Navigation("Feedback"); 720 | 721 | b.Navigation("Learner"); 722 | 723 | b.Navigation("TheQuizzes"); 724 | }); 725 | 726 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 727 | { 728 | b.HasOne("E_Learning_Management_System.Models.Certificate", "Certificate") 729 | .WithMany() 730 | .HasForeignKey("CertificateId"); 731 | 732 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 733 | .WithMany("TheQuizzes") 734 | .HasForeignKey("InstructorId"); 735 | 736 | b.Navigation("Certificate"); 737 | 738 | b.Navigation("Instructor"); 739 | }); 740 | 741 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 742 | { 743 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 744 | .WithMany() 745 | .HasForeignKey("RoleId") 746 | .OnDelete(DeleteBehavior.Cascade) 747 | .IsRequired(); 748 | }); 749 | 750 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 751 | { 752 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 753 | .WithMany() 754 | .HasForeignKey("UserId") 755 | .OnDelete(DeleteBehavior.Cascade) 756 | .IsRequired(); 757 | }); 758 | 759 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 760 | { 761 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 762 | .WithMany() 763 | .HasForeignKey("UserId") 764 | .OnDelete(DeleteBehavior.Cascade) 765 | .IsRequired(); 766 | }); 767 | 768 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 769 | { 770 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 771 | .WithMany() 772 | .HasForeignKey("RoleId") 773 | .OnDelete(DeleteBehavior.Cascade) 774 | .IsRequired(); 775 | 776 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 777 | .WithMany() 778 | .HasForeignKey("UserId") 779 | .OnDelete(DeleteBehavior.Cascade) 780 | .IsRequired(); 781 | }); 782 | 783 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 784 | { 785 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 786 | .WithMany() 787 | .HasForeignKey("UserId") 788 | .OnDelete(DeleteBehavior.Cascade) 789 | .IsRequired(); 790 | }); 791 | 792 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 793 | { 794 | b.Navigation("Contents"); 795 | }); 796 | 797 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 798 | { 799 | b.Navigation("Coruses"); 800 | 801 | b.Navigation("Feedbacks"); 802 | 803 | b.Navigation("TheQuizzes"); 804 | }); 805 | 806 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 807 | { 808 | b.Navigation("Certificates"); 809 | 810 | b.Navigation("Feedbacks"); 811 | }); 812 | 813 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 814 | { 815 | b.Navigation("Quizzes"); 816 | }); 817 | #pragma warning restore 612, 618 818 | } 819 | } 820 | } 821 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Migrations/ContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using E_Learning_Management_System.Models; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | 9 | #nullable disable 10 | 11 | namespace E_Learning_Management_System.Migrations 12 | { 13 | [DbContext(typeof(Context))] 14 | partial class ContextModelSnapshot : ModelSnapshot 15 | { 16 | protected override void BuildModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "8.0.4") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 22 | 23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); 24 | 25 | modelBuilder.Entity("CourseLearner", b => 26 | { 27 | b.Property("CoursesId") 28 | .HasColumnType("int"); 29 | 30 | b.Property("LearnersId") 31 | .HasColumnType("int"); 32 | 33 | b.HasKey("CoursesId", "LearnersId"); 34 | 35 | b.HasIndex("LearnersId"); 36 | 37 | b.ToTable("CourseLearner"); 38 | }); 39 | 40 | modelBuilder.Entity("E_Learning_Management_System.Models.Adminstrator", b => 41 | { 42 | b.Property("id") 43 | .ValueGeneratedOnAdd() 44 | .HasColumnType("int"); 45 | 46 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("id")); 47 | 48 | b.Property("AccountId") 49 | .HasColumnType("nvarchar(450)"); 50 | 51 | b.Property("ContentId") 52 | .HasColumnType("int"); 53 | 54 | b.Property("IsDeleted") 55 | .HasColumnType("bit"); 56 | 57 | b.Property("Name") 58 | .IsRequired() 59 | .HasColumnType("nvarchar(max)"); 60 | 61 | b.HasKey("id"); 62 | 63 | b.HasIndex("AccountId"); 64 | 65 | b.HasIndex("ContentId"); 66 | 67 | b.ToTable("Adminstrator"); 68 | }); 69 | 70 | modelBuilder.Entity("E_Learning_Management_System.Models.ApplicationUser", b => 71 | { 72 | b.Property("Id") 73 | .HasColumnType("nvarchar(450)"); 74 | 75 | b.Property("AccessFailedCount") 76 | .HasColumnType("int"); 77 | 78 | b.Property("AccountType") 79 | .IsRequired() 80 | .HasColumnType("nvarchar(max)"); 81 | 82 | b.Property("Address") 83 | .IsRequired() 84 | .HasColumnType("nvarchar(max)"); 85 | 86 | b.Property("AdminstratorId") 87 | .HasColumnType("int"); 88 | 89 | b.Property("ConcurrencyStamp") 90 | .IsConcurrencyToken() 91 | .HasColumnType("nvarchar(max)"); 92 | 93 | b.Property("Email") 94 | .HasMaxLength(256) 95 | .HasColumnType("nvarchar(256)"); 96 | 97 | b.Property("EmailConfirmed") 98 | .HasColumnType("bit"); 99 | 100 | b.Property("InstructorId") 101 | .HasColumnType("int"); 102 | 103 | b.Property("IsDeleted") 104 | .HasColumnType("bit"); 105 | 106 | b.Property("LearnerId") 107 | .HasColumnType("int"); 108 | 109 | b.Property("LockoutEnabled") 110 | .HasColumnType("bit"); 111 | 112 | b.Property("LockoutEnd") 113 | .HasColumnType("datetimeoffset"); 114 | 115 | b.Property("NormalizedEmail") 116 | .HasMaxLength(256) 117 | .HasColumnType("nvarchar(256)"); 118 | 119 | b.Property("NormalizedUserName") 120 | .HasMaxLength(256) 121 | .HasColumnType("nvarchar(256)"); 122 | 123 | b.Property("PasswordHash") 124 | .HasColumnType("nvarchar(max)"); 125 | 126 | b.Property("PhoneNumber") 127 | .HasColumnType("nvarchar(max)"); 128 | 129 | b.Property("PhoneNumberConfirmed") 130 | .HasColumnType("bit"); 131 | 132 | b.Property("SecurityStamp") 133 | .HasColumnType("nvarchar(max)"); 134 | 135 | b.Property("TwoFactorEnabled") 136 | .HasColumnType("bit"); 137 | 138 | b.Property("UserName") 139 | .HasMaxLength(256) 140 | .HasColumnType("nvarchar(256)"); 141 | 142 | b.HasKey("Id"); 143 | 144 | b.HasIndex("AdminstratorId"); 145 | 146 | b.HasIndex("InstructorId"); 147 | 148 | b.HasIndex("LearnerId"); 149 | 150 | b.HasIndex("NormalizedEmail") 151 | .HasDatabaseName("EmailIndex"); 152 | 153 | b.HasIndex("NormalizedUserName") 154 | .IsUnique() 155 | .HasDatabaseName("UserNameIndex") 156 | .HasFilter("[NormalizedUserName] IS NOT NULL"); 157 | 158 | b.ToTable("AspNetUsers", (string)null); 159 | }); 160 | 161 | modelBuilder.Entity("E_Learning_Management_System.Models.Certificate", b => 162 | { 163 | b.Property("Id") 164 | .ValueGeneratedOnAdd() 165 | .HasColumnType("int"); 166 | 167 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 168 | 169 | b.Property("Date") 170 | .HasColumnType("datetime2"); 171 | 172 | b.Property("IsDeleted") 173 | .HasColumnType("bit"); 174 | 175 | b.Property("LearnerId") 176 | .HasColumnType("int"); 177 | 178 | b.Property("QuizId") 179 | .HasColumnType("int"); 180 | 181 | b.HasKey("Id"); 182 | 183 | b.HasIndex("LearnerId"); 184 | 185 | b.HasIndex("QuizId") 186 | .IsUnique() 187 | .HasFilter("[QuizId] IS NOT NULL"); 188 | 189 | b.ToTable("Certificate"); 190 | }); 191 | 192 | modelBuilder.Entity("E_Learning_Management_System.Models.Content", b => 193 | { 194 | b.Property("Id") 195 | .ValueGeneratedOnAdd() 196 | .HasColumnType("int"); 197 | 198 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 199 | 200 | b.Property("AdminstratorId") 201 | .HasColumnType("int"); 202 | 203 | b.Property("CourseId") 204 | .HasColumnType("int"); 205 | 206 | b.Property("IsDeleted") 207 | .HasColumnType("bit"); 208 | 209 | b.Property("LearnerId") 210 | .HasColumnType("int"); 211 | 212 | b.Property("Type") 213 | .IsRequired() 214 | .HasColumnType("nvarchar(max)"); 215 | 216 | b.Property("content") 217 | .IsRequired() 218 | .HasColumnType("nvarchar(max)"); 219 | 220 | b.Property("videoPathURL") 221 | .IsRequired() 222 | .HasColumnType("nvarchar(max)"); 223 | 224 | b.HasKey("Id"); 225 | 226 | b.HasIndex("AdminstratorId"); 227 | 228 | b.HasIndex("CourseId"); 229 | 230 | b.HasIndex("LearnerId"); 231 | 232 | b.ToTable("Content"); 233 | }); 234 | 235 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 236 | { 237 | b.Property("Id") 238 | .ValueGeneratedOnAdd() 239 | .HasColumnType("int"); 240 | 241 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 242 | 243 | b.Property("DurationInHours") 244 | .HasColumnType("int"); 245 | 246 | b.Property("ImgPath") 247 | .IsRequired() 248 | .HasColumnType("nvarchar(max)"); 249 | 250 | b.Property("InstructorId") 251 | .HasColumnType("int"); 252 | 253 | b.Property("IsDeleted") 254 | .HasColumnType("bit"); 255 | 256 | b.Property("Name") 257 | .IsRequired() 258 | .HasColumnType("nvarchar(max)"); 259 | 260 | b.HasKey("Id"); 261 | 262 | b.HasIndex("InstructorId"); 263 | 264 | b.ToTable("Course"); 265 | }); 266 | 267 | modelBuilder.Entity("E_Learning_Management_System.Models.Feedback", b => 268 | { 269 | b.Property("Id") 270 | .ValueGeneratedOnAdd() 271 | .HasColumnType("int"); 272 | 273 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 274 | 275 | b.Property("InstructorId") 276 | .HasColumnType("int"); 277 | 278 | b.Property("IsDeleted") 279 | .HasColumnType("bit"); 280 | 281 | b.Property("LearnerId") 282 | .HasColumnType("int"); 283 | 284 | b.Property("Message") 285 | .IsRequired() 286 | .HasColumnType("nvarchar(max)"); 287 | 288 | b.Property("QuizId") 289 | .HasColumnType("int"); 290 | 291 | b.HasKey("Id"); 292 | 293 | b.HasIndex("InstructorId"); 294 | 295 | b.HasIndex("LearnerId"); 296 | 297 | b.HasIndex("QuizId"); 298 | 299 | b.ToTable("Feedback"); 300 | }); 301 | 302 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 303 | { 304 | b.Property("Id") 305 | .ValueGeneratedOnAdd() 306 | .HasColumnType("int"); 307 | 308 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 309 | 310 | b.Property("AccountId") 311 | .HasColumnType("nvarchar(450)"); 312 | 313 | b.Property("IsDeleted") 314 | .HasColumnType("bit"); 315 | 316 | b.Property("Name") 317 | .IsRequired() 318 | .HasColumnType("nvarchar(max)"); 319 | 320 | b.HasKey("Id"); 321 | 322 | b.HasIndex("AccountId"); 323 | 324 | b.ToTable("Instructor"); 325 | }); 326 | 327 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 328 | { 329 | b.Property("Id") 330 | .ValueGeneratedOnAdd() 331 | .HasColumnType("int"); 332 | 333 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 334 | 335 | b.Property("AccountId") 336 | .HasColumnType("nvarchar(450)"); 337 | 338 | b.Property("ContentId") 339 | .HasColumnType("int"); 340 | 341 | b.Property("IsDeleted") 342 | .HasColumnType("bit"); 343 | 344 | b.Property("Name") 345 | .IsRequired() 346 | .HasColumnType("nvarchar(max)"); 347 | 348 | b.Property("QuizId") 349 | .HasColumnType("int"); 350 | 351 | b.HasKey("Id"); 352 | 353 | b.HasIndex("AccountId"); 354 | 355 | b.HasIndex("ContentId"); 356 | 357 | b.HasIndex("QuizId"); 358 | 359 | b.ToTable("Learner"); 360 | }); 361 | 362 | modelBuilder.Entity("E_Learning_Management_System.Models.Quiz", b => 363 | { 364 | b.Property("Id") 365 | .ValueGeneratedOnAdd() 366 | .HasColumnType("int"); 367 | 368 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 369 | 370 | b.Property("FeedbackId") 371 | .HasColumnType("int"); 372 | 373 | b.Property("IsDeleted") 374 | .HasColumnType("bit"); 375 | 376 | b.Property("LearnerId") 377 | .HasColumnType("int"); 378 | 379 | b.Property("Mark") 380 | .HasColumnType("float"); 381 | 382 | b.Property("TheQuizzesId") 383 | .HasColumnType("int"); 384 | 385 | b.HasKey("Id"); 386 | 387 | b.HasIndex("FeedbackId"); 388 | 389 | b.HasIndex("LearnerId"); 390 | 391 | b.HasIndex("TheQuizzesId"); 392 | 393 | b.ToTable("Quiz"); 394 | }); 395 | 396 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 397 | { 398 | b.Property("Id") 399 | .ValueGeneratedOnAdd() 400 | .HasColumnType("int"); 401 | 402 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 403 | 404 | b.Property("CertificateId") 405 | .HasColumnType("int"); 406 | 407 | b.Property("InstructorId") 408 | .HasColumnType("int"); 409 | 410 | b.Property("IsDeleted") 411 | .HasColumnType("bit"); 412 | 413 | b.HasKey("Id"); 414 | 415 | b.HasIndex("CertificateId"); 416 | 417 | b.HasIndex("InstructorId"); 418 | 419 | b.ToTable("TheQuizzes"); 420 | }); 421 | 422 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => 423 | { 424 | b.Property("Id") 425 | .HasColumnType("nvarchar(450)"); 426 | 427 | b.Property("ConcurrencyStamp") 428 | .IsConcurrencyToken() 429 | .HasColumnType("nvarchar(max)"); 430 | 431 | b.Property("Name") 432 | .HasMaxLength(256) 433 | .HasColumnType("nvarchar(256)"); 434 | 435 | b.Property("NormalizedName") 436 | .HasMaxLength(256) 437 | .HasColumnType("nvarchar(256)"); 438 | 439 | b.HasKey("Id"); 440 | 441 | b.HasIndex("NormalizedName") 442 | .IsUnique() 443 | .HasDatabaseName("RoleNameIndex") 444 | .HasFilter("[NormalizedName] IS NOT NULL"); 445 | 446 | b.ToTable("AspNetRoles", (string)null); 447 | }); 448 | 449 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 450 | { 451 | b.Property("Id") 452 | .ValueGeneratedOnAdd() 453 | .HasColumnType("int"); 454 | 455 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 456 | 457 | b.Property("ClaimType") 458 | .HasColumnType("nvarchar(max)"); 459 | 460 | b.Property("ClaimValue") 461 | .HasColumnType("nvarchar(max)"); 462 | 463 | b.Property("RoleId") 464 | .IsRequired() 465 | .HasColumnType("nvarchar(450)"); 466 | 467 | b.HasKey("Id"); 468 | 469 | b.HasIndex("RoleId"); 470 | 471 | b.ToTable("AspNetRoleClaims", (string)null); 472 | }); 473 | 474 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 475 | { 476 | b.Property("Id") 477 | .ValueGeneratedOnAdd() 478 | .HasColumnType("int"); 479 | 480 | SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); 481 | 482 | b.Property("ClaimType") 483 | .HasColumnType("nvarchar(max)"); 484 | 485 | b.Property("ClaimValue") 486 | .HasColumnType("nvarchar(max)"); 487 | 488 | b.Property("UserId") 489 | .IsRequired() 490 | .HasColumnType("nvarchar(450)"); 491 | 492 | b.HasKey("Id"); 493 | 494 | b.HasIndex("UserId"); 495 | 496 | b.ToTable("AspNetUserClaims", (string)null); 497 | }); 498 | 499 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 500 | { 501 | b.Property("LoginProvider") 502 | .HasColumnType("nvarchar(450)"); 503 | 504 | b.Property("ProviderKey") 505 | .HasColumnType("nvarchar(450)"); 506 | 507 | b.Property("ProviderDisplayName") 508 | .HasColumnType("nvarchar(max)"); 509 | 510 | b.Property("UserId") 511 | .IsRequired() 512 | .HasColumnType("nvarchar(450)"); 513 | 514 | b.HasKey("LoginProvider", "ProviderKey"); 515 | 516 | b.HasIndex("UserId"); 517 | 518 | b.ToTable("AspNetUserLogins", (string)null); 519 | }); 520 | 521 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 522 | { 523 | b.Property("UserId") 524 | .HasColumnType("nvarchar(450)"); 525 | 526 | b.Property("RoleId") 527 | .HasColumnType("nvarchar(450)"); 528 | 529 | b.HasKey("UserId", "RoleId"); 530 | 531 | b.HasIndex("RoleId"); 532 | 533 | b.ToTable("AspNetUserRoles", (string)null); 534 | }); 535 | 536 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 537 | { 538 | b.Property("UserId") 539 | .HasColumnType("nvarchar(450)"); 540 | 541 | b.Property("LoginProvider") 542 | .HasColumnType("nvarchar(450)"); 543 | 544 | b.Property("Name") 545 | .HasColumnType("nvarchar(450)"); 546 | 547 | b.Property("Value") 548 | .HasColumnType("nvarchar(max)"); 549 | 550 | b.HasKey("UserId", "LoginProvider", "Name"); 551 | 552 | b.ToTable("AspNetUserTokens", (string)null); 553 | }); 554 | 555 | modelBuilder.Entity("CourseLearner", b => 556 | { 557 | b.HasOne("E_Learning_Management_System.Models.Course", null) 558 | .WithMany() 559 | .HasForeignKey("CoursesId") 560 | .OnDelete(DeleteBehavior.Cascade) 561 | .IsRequired(); 562 | 563 | b.HasOne("E_Learning_Management_System.Models.Learner", null) 564 | .WithMany() 565 | .HasForeignKey("LearnersId") 566 | .OnDelete(DeleteBehavior.Cascade) 567 | .IsRequired(); 568 | }); 569 | 570 | modelBuilder.Entity("E_Learning_Management_System.Models.Adminstrator", b => 571 | { 572 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 573 | .WithMany() 574 | .HasForeignKey("AccountId"); 575 | 576 | b.HasOne("E_Learning_Management_System.Models.Content", "Content") 577 | .WithMany() 578 | .HasForeignKey("ContentId"); 579 | 580 | b.Navigation("Account"); 581 | 582 | b.Navigation("Content"); 583 | }); 584 | 585 | modelBuilder.Entity("E_Learning_Management_System.Models.ApplicationUser", b => 586 | { 587 | b.HasOne("E_Learning_Management_System.Models.Adminstrator", "Adminstrator") 588 | .WithMany() 589 | .HasForeignKey("AdminstratorId"); 590 | 591 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 592 | .WithMany() 593 | .HasForeignKey("InstructorId"); 594 | 595 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 596 | .WithMany() 597 | .HasForeignKey("LearnerId"); 598 | 599 | b.Navigation("Adminstrator"); 600 | 601 | b.Navigation("Instructor"); 602 | 603 | b.Navigation("Learner"); 604 | }); 605 | 606 | modelBuilder.Entity("E_Learning_Management_System.Models.Certificate", b => 607 | { 608 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 609 | .WithMany("Certificates") 610 | .HasForeignKey("LearnerId"); 611 | 612 | b.HasOne("E_Learning_Management_System.Models.TheQuizzes", "Quizzes") 613 | .WithOne() 614 | .HasForeignKey("E_Learning_Management_System.Models.Certificate", "QuizId"); 615 | 616 | b.Navigation("Learner"); 617 | 618 | b.Navigation("Quizzes"); 619 | }); 620 | 621 | modelBuilder.Entity("E_Learning_Management_System.Models.Content", b => 622 | { 623 | b.HasOne("E_Learning_Management_System.Models.Adminstrator", "Adminstrator") 624 | .WithMany() 625 | .HasForeignKey("AdminstratorId"); 626 | 627 | b.HasOne("E_Learning_Management_System.Models.Course", "Course") 628 | .WithMany("Contents") 629 | .HasForeignKey("CourseId"); 630 | 631 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 632 | .WithMany() 633 | .HasForeignKey("LearnerId"); 634 | 635 | b.Navigation("Adminstrator"); 636 | 637 | b.Navigation("Course"); 638 | 639 | b.Navigation("Learner"); 640 | }); 641 | 642 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 643 | { 644 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 645 | .WithMany("Coruses") 646 | .HasForeignKey("InstructorId"); 647 | 648 | b.Navigation("Instructor"); 649 | }); 650 | 651 | modelBuilder.Entity("E_Learning_Management_System.Models.Feedback", b => 652 | { 653 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 654 | .WithMany("Feedbacks") 655 | .HasForeignKey("InstructorId"); 656 | 657 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 658 | .WithMany("Feedbacks") 659 | .HasForeignKey("LearnerId"); 660 | 661 | b.HasOne("E_Learning_Management_System.Models.Quiz", "Quiz") 662 | .WithMany() 663 | .HasForeignKey("QuizId"); 664 | 665 | b.Navigation("Instructor"); 666 | 667 | b.Navigation("Learner"); 668 | 669 | b.Navigation("Quiz"); 670 | }); 671 | 672 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 673 | { 674 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 675 | .WithMany() 676 | .HasForeignKey("AccountId"); 677 | 678 | b.Navigation("Account"); 679 | }); 680 | 681 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 682 | { 683 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", "Account") 684 | .WithMany() 685 | .HasForeignKey("AccountId"); 686 | 687 | b.HasOne("E_Learning_Management_System.Models.Content", "Content") 688 | .WithMany() 689 | .HasForeignKey("ContentId"); 690 | 691 | b.HasOne("E_Learning_Management_System.Models.Quiz", "Quiz") 692 | .WithMany() 693 | .HasForeignKey("QuizId"); 694 | 695 | b.Navigation("Account"); 696 | 697 | b.Navigation("Content"); 698 | 699 | b.Navigation("Quiz"); 700 | }); 701 | 702 | modelBuilder.Entity("E_Learning_Management_System.Models.Quiz", b => 703 | { 704 | b.HasOne("E_Learning_Management_System.Models.Feedback", "Feedback") 705 | .WithMany() 706 | .HasForeignKey("FeedbackId"); 707 | 708 | b.HasOne("E_Learning_Management_System.Models.Learner", "Learner") 709 | .WithMany() 710 | .HasForeignKey("LearnerId"); 711 | 712 | b.HasOne("E_Learning_Management_System.Models.TheQuizzes", "TheQuizzes") 713 | .WithMany("Quizzes") 714 | .HasForeignKey("TheQuizzesId"); 715 | 716 | b.Navigation("Feedback"); 717 | 718 | b.Navigation("Learner"); 719 | 720 | b.Navigation("TheQuizzes"); 721 | }); 722 | 723 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 724 | { 725 | b.HasOne("E_Learning_Management_System.Models.Certificate", "Certificate") 726 | .WithMany() 727 | .HasForeignKey("CertificateId"); 728 | 729 | b.HasOne("E_Learning_Management_System.Models.Instructor", "Instructor") 730 | .WithMany("TheQuizzes") 731 | .HasForeignKey("InstructorId"); 732 | 733 | b.Navigation("Certificate"); 734 | 735 | b.Navigation("Instructor"); 736 | }); 737 | 738 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => 739 | { 740 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 741 | .WithMany() 742 | .HasForeignKey("RoleId") 743 | .OnDelete(DeleteBehavior.Cascade) 744 | .IsRequired(); 745 | }); 746 | 747 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => 748 | { 749 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 750 | .WithMany() 751 | .HasForeignKey("UserId") 752 | .OnDelete(DeleteBehavior.Cascade) 753 | .IsRequired(); 754 | }); 755 | 756 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => 757 | { 758 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 759 | .WithMany() 760 | .HasForeignKey("UserId") 761 | .OnDelete(DeleteBehavior.Cascade) 762 | .IsRequired(); 763 | }); 764 | 765 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => 766 | { 767 | b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) 768 | .WithMany() 769 | .HasForeignKey("RoleId") 770 | .OnDelete(DeleteBehavior.Cascade) 771 | .IsRequired(); 772 | 773 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 774 | .WithMany() 775 | .HasForeignKey("UserId") 776 | .OnDelete(DeleteBehavior.Cascade) 777 | .IsRequired(); 778 | }); 779 | 780 | modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => 781 | { 782 | b.HasOne("E_Learning_Management_System.Models.ApplicationUser", null) 783 | .WithMany() 784 | .HasForeignKey("UserId") 785 | .OnDelete(DeleteBehavior.Cascade) 786 | .IsRequired(); 787 | }); 788 | 789 | modelBuilder.Entity("E_Learning_Management_System.Models.Course", b => 790 | { 791 | b.Navigation("Contents"); 792 | }); 793 | 794 | modelBuilder.Entity("E_Learning_Management_System.Models.Instructor", b => 795 | { 796 | b.Navigation("Coruses"); 797 | 798 | b.Navigation("Feedbacks"); 799 | 800 | b.Navigation("TheQuizzes"); 801 | }); 802 | 803 | modelBuilder.Entity("E_Learning_Management_System.Models.Learner", b => 804 | { 805 | b.Navigation("Certificates"); 806 | 807 | b.Navigation("Feedbacks"); 808 | }); 809 | 810 | modelBuilder.Entity("E_Learning_Management_System.Models.TheQuizzes", b => 811 | { 812 | b.Navigation("Quizzes"); 813 | }); 814 | #pragma warning restore 612, 618 815 | } 816 | } 817 | } 818 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Adminstrator.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | using E_Learning_Management_System.Models; 4 | using Microsoft.AspNetCore.Http.HttpResults; 5 | using Microsoft.AspNetCore.OpenApi; 6 | using Microsoft.EntityFrameworkCore; 7 | 8 | namespace E_Learning_Management_System.Models 9 | { 10 | public class Adminstrator : IDeletable 11 | { 12 | public int id { get; set; } 13 | public string Name { get; set; } 14 | public bool IsDeleted { get; set; } = false; 15 | 16 | [ForeignKey("Account")] 17 | public string? AccountId { get; set; } 18 | public ApplicationUser? Account { get; set; } 19 | [ForeignKey("Content")] 20 | public int? ContentId { get; set; } 21 | public Content? Content { get; set; } 22 | } 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/ApplicationUser.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using Microsoft.AspNetCore.Identity; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | 5 | namespace E_Learning_Management_System.Models 6 | { 7 | public class ApplicationUser : IdentityUser, IDeletable //Account 8 | { 9 | public string Address { get; set; } 10 | public bool IsDeleted { get; set; } = false; 11 | public string AccountType { get; set; } 12 | 13 | [ForeignKey("Learner")] 14 | public int? LearnerId { get; set; } 15 | public Learner? Learner { get; set; } 16 | 17 | [ForeignKey("Instructor")] 18 | public int? InstructorId { get; set; } 19 | public Instructor? Instructor { get; set; } 20 | [ForeignKey("Adminstrator")] 21 | public int? AdminstratorId { get; set; } 22 | public Adminstrator? Adminstrator { get; set; } 23 | } 24 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Certificate.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class Certificate : IDeletable 7 | { 8 | public int Id { get; set; } 9 | public DateTime Date { get; set; } 10 | public bool IsDeleted { get; set; } = false; 11 | [ForeignKey("Quizzes")] 12 | public int? QuizId { get; set; } 13 | public TheQuizzes? Quizzes { get; set; } 14 | [ForeignKey("Learner")] 15 | public int? LearnerId { get; set; } 16 | public Learner? Learner { get; set; } 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Content.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class Content : IDeletable 7 | { 8 | public int Id { get; set; } 9 | public string Type { get; set; } 10 | public string videoPathURL { get; set; } 11 | public string content { get; set; } 12 | public bool IsDeleted { get; set; } = false; 13 | [ForeignKey("Course")] 14 | public int? CourseId { get; set; } 15 | public Course? Course { get; set; } 16 | [ForeignKey("Learner")] 17 | public int? LearnerId { get; set; } 18 | public Learner? Learner { get; set; } 19 | [ForeignKey("Adminstrator")] 20 | public int? AdminstratorId { get; set; } 21 | public Adminstrator? Adminstrator { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Context.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class Context : IdentityDbContext 7 | { 8 | public DbSet Adminstrator { get; set; } 9 | public DbSet Certificate { get; set; } 10 | public DbSet Content { get; set; } 11 | public DbSet Course { get; set; } 12 | public DbSet Feedback { get; set; } 13 | public DbSet Instructor { get; set; } 14 | public DbSet Learner { get; set; } 15 | public DbSet Quiz { get; set; } 16 | public DbSet TheQuizzes { get; set; } 17 | public Context() { } 18 | public Context(DbContextOptions options) : base(options) 19 | { 20 | 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Course.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class Course : IDeletable 7 | { 8 | public int Id { get; set; } 9 | public string Name { get; set; } 10 | public string ImgPath { get; set; } 11 | public int DurationInHours { get; set; } 12 | public bool IsDeleted { get; set; } = false; 13 | public ICollection? Learners { get; set; } 14 | public ICollection? Contents { get; set; } 15 | [ForeignKey("Instructor")] 16 | public int? InstructorId { get; set; } 17 | public Instructor? Instructor { get; set; } 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Feedback.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class Feedback : IDeletable 7 | { 8 | public int Id { get; set; } 9 | public string Message { get; set; } 10 | public bool IsDeleted { get; set; } = false; 11 | [ForeignKey("Learner")] 12 | public int? LearnerId { get; set; } 13 | public Learner? Learner { get; set; } 14 | 15 | [ForeignKey("Instructor")] 16 | public int? InstructorId { get; set; } 17 | public Instructor? Instructor { get; set; } 18 | [ForeignKey("Quiz")] 19 | public int? QuizId { get; set; } 20 | public Quiz? Quiz { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Instructor.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class Instructor : IDeletable 7 | { 8 | public int Id { get; set; } 9 | public string Name { get; set; } 10 | public bool IsDeleted { get; set; } = false; 11 | 12 | [ForeignKey("Account")] 13 | public string? AccountId { get; set; } 14 | public ApplicationUser? Account { get; set; } 15 | public ICollection? Feedbacks { get; set; } 16 | public ICollection? Coruses { get; set; } 17 | public ICollection? TheQuizzes { get; set; } 18 | 19 | 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Learner.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class Learner : IDeletable 7 | { 8 | public int Id { get; set; } 9 | public string Name { get; set; } 10 | public bool IsDeleted { get; set; } = false; 11 | 12 | [ForeignKey("Account")] 13 | public string? AccountId { get; set; } 14 | public ApplicationUser? Account { get; set; } 15 | [ForeignKey("Content")] 16 | public int? ContentId { get; set; } 17 | public Content? Content { get; set; } 18 | 19 | [ForeignKey("Quiz")] 20 | public int? QuizId { get; set; } 21 | public Quiz? Quiz { get; set; } 22 | public ICollection? Certificates { get; set; } 23 | public ICollection? Feedbacks { get; set; } 24 | public ICollection? Courses { get; set; } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/Quiz.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class Quiz : IDeletable 7 | { 8 | public int Id { get; set; } 9 | public double Mark { get; set; } 10 | public bool IsDeleted { get; set; } = false; 11 | [ForeignKey("Learner")] 12 | public int? LearnerId { get; set; } 13 | public Learner? Learner { get; set; } 14 | [ForeignKey("Feedback")] 15 | public int? FeedbackId { get; set; } 16 | public Feedback? Feedback { get; set; } 17 | [ForeignKey("TheQuizzes")] 18 | public int? TheQuizzesId { get; set; } 19 | public TheQuizzes? TheQuizzes { get; set; } 20 | 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Models/TheQuizzes.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Repository; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace E_Learning_Management_System.Models 5 | { 6 | public class TheQuizzes : IDeletable 7 | { 8 | public int Id { get; set; } 9 | public bool IsDeleted { get; set; } = false; 10 | [ForeignKey("Certificate")] 11 | public int? CertificateId { get; set; } 12 | public Certificate? Certificate { get; set; } 13 | 14 | [ForeignKey("Instructor")] 15 | public int? InstructorId { get; set; } 16 | public Instructor? Instructor { get; set; } 17 | 18 | public ICollection? Quizzes { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Program.cs: -------------------------------------------------------------------------------- 1 |  2 | using E_Learning_Management_System.Models; 3 | using E_Learning_Management_System.Repository; 4 | using Microsoft.AspNetCore.Authentication.JwtBearer; 5 | using Microsoft.AspNetCore.Identity; 6 | using Microsoft.EntityFrameworkCore; 7 | using Microsoft.IdentityModel.Tokens; 8 | using Microsoft.OpenApi.Models; 9 | using System.Text; 10 | using E_Learning_Management_System.Controllers; 11 | 12 | namespace E_Learning_Management_System 13 | { 14 | public class Program 15 | { 16 | public static void Main(string[] args) 17 | { 18 | var builder = WebApplication.CreateBuilder(args); 19 | 20 | // Add services to the container. 21 | 22 | builder.Services.AddControllers(); 23 | builder.Services.AddAutoMapper(typeof(Program)); //auto mapper 24 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle 25 | builder.Services.AddEndpointsApiExplorer(); 26 | builder.Services.AddSwaggerGen(); 27 | 28 | builder.Services.AddDbContext(options => 29 | { 30 | options.UseSqlServer(builder.Configuration.GetConnectionString("cs")); 31 | 32 | }); 33 | 34 | builder.Services.AddCors(options => 35 | { 36 | options.AddPolicy("MyPolicy", 37 | policy => policy.AllowAnyMethod() 38 | .AllowAnyOrigin() 39 | .AllowAnyHeader()); 40 | }); 41 | 42 | builder.Services.AddIdentity().AddEntityFrameworkStores(); 43 | 44 | 45 | builder.Services.AddAuthentication(options => 46 | { 47 | options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; 48 | //[authore ]:found toke or not 49 | options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; 50 | //account/loginresonse unauthorize 51 | options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; 52 | }).AddJwtBearer(options => 53 | { 54 | options.SaveToken = true; 55 | options.RequireHttpsMetadata = false; 56 | options.TokenValidationParameters = new TokenValidationParameters() 57 | { 58 | ValidateIssuer = true, 59 | ValidIssuer = builder.Configuration["JWT:ValidIss"], 60 | ValidateAudience = true, 61 | ValidAudience = builder.Configuration["JWT:ValidAud"], 62 | IssuerSigningKey = 63 | new SymmetricSecurityKey( 64 | Encoding.UTF8.GetBytes(builder.Configuration["JWT:SecritKey"])) 65 | }; 66 | }); 67 | 68 | 69 | /*-----------------------------Swagger PArt-----------------------------*/ 70 | #region Swagger REgion 71 | //builder.Services.AddSwaggerGen(); 72 | 73 | builder.Services.AddSwaggerGen(swagger => 74 | { 75 | //This is to generate the Default UI of Swagger Documentation     76 | swagger.SwaggerDoc("v1", new OpenApiInfo 77 | { 78 | Version = "v1", 79 | Title = "ASP.NET 5 Web API", 80 | Description = " ITI Projrcy" 81 | }); 82 | // To Enable authorization using Swagger (JWT)     83 | swagger.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme() 84 | { 85 | Name = "Authorization", 86 | Type = SecuritySchemeType.ApiKey, 87 | Scheme = "Bearer", 88 | BearerFormat = "JWT", 89 | In = ParameterLocation.Header, 90 | Description = "Enter 'Bearer' [space] and then your valid token in the text input below.\r\n\r\nExample: \"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9\"", 91 | }); 92 | swagger.AddSecurityRequirement(new OpenApiSecurityRequirement 93 | { 94 | { 95 | new OpenApiSecurityScheme 96 | { 97 | Reference = new OpenApiReference 98 | { 99 | Type = ReferenceType.SecurityScheme, 100 | Id = "Bearer" 101 | } 102 | }, 103 | new string[] {} 104 | } 105 | }); 106 | }); 107 | #endregion 108 | //---------------------------------------------------------- 109 | 110 | builder.Services.AddScoped(); 111 | 112 | //builder.Services.AddScoped, Repository>(); 113 | builder.Services.AddScoped, Repository>(); 114 | builder.Services.AddScoped, Repository>(); 115 | builder.Services.AddScoped, Repository>(); 116 | 117 | builder.Services.AddScoped, Repository>(); 118 | builder.Services.AddScoped, Repository>(); 119 | 120 | builder.Services.AddScoped, Repository>(); 121 | builder.Services.AddScoped, Repository>(); 122 | builder.Services.AddScoped, Repository>(); 123 | 124 | 125 | var app = builder.Build(); 126 | 127 | 128 | 129 | 130 | // Configure the HTTP request pipeline. 131 | if (app.Environment.IsDevelopment()) 132 | { 133 | app.UseSwagger(); 134 | app.UseSwaggerUI(); 135 | } 136 | 137 | app.UseCors("MyPolicy"); 138 | app.UseAuthorization(); 139 | 140 | 141 | app.MapControllers(); 142 | 143 | 144 | 145 | app.Run(); 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /E-Learning-Management-System/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:60086", 8 | "sslPort": 0 9 | } 10 | }, 11 | "profiles": { 12 | "http": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "swagger", 17 | "applicationUrl": "http://localhost:5104", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "IIS Express": { 23 | "commandName": "IISExpress", 24 | "launchBrowser": true, 25 | "launchUrl": "swagger", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Repository/CourseRepository.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Models; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace E_Learning_Management_System.Repository 5 | { 6 | public class CourseRepository : Repository, ICourseRepository 7 | { 8 | public CourseRepository(Context context) : base(context) 9 | { 10 | 11 | } 12 | public List GetAllIncludeInstructor() 13 | { 14 | return context.Course 15 | .Include(course => course.Instructor) 16 | .Where(item => item.IsDeleted == false).ToList(); 17 | } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /E-Learning-Management-System/Repository/ICourseRepository.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Models; 2 | 3 | namespace E_Learning_Management_System.Repository 4 | { 5 | public interface ICourseRepository : IRepository 6 | { 7 | public List GetAllIncludeInstructor(); 8 | } 9 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Repository/IDeletable.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.Repository 2 | { 3 | public interface IDeletable 4 | { 5 | bool IsDeleted { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Repository/IRepository.cs: -------------------------------------------------------------------------------- 1 | namespace E_Learning_Management_System.Repository 2 | { 3 | public interface IRepository where T : class, IDeletable 4 | { 5 | public void insert(T obj); 6 | public void delete(T obj); 7 | public void update(T obj); 8 | public List GetAll(); 9 | public T Get(Func predicate); 10 | public int save(); 11 | } 12 | } -------------------------------------------------------------------------------- /E-Learning-Management-System/Repository/Repository.cs: -------------------------------------------------------------------------------- 1 | using E_Learning_Management_System.Models; 2 | 3 | namespace E_Learning_Management_System.Repository 4 | { 5 | public class Repository : IRepository where T : class, IDeletable 6 | { 7 | public readonly Context context; 8 | public Repository(Context context) 9 | { 10 | this.context = context; 11 | } 12 | public void insert(T obj) 13 | { 14 | context.Set().Add(obj); 15 | } 16 | public void delete(T obj) 17 | { 18 | obj.IsDeleted = true; 19 | update(obj); 20 | } 21 | public void update(T obj) 22 | { 23 | context.Set().Update(obj); 24 | } 25 | public List GetAll() 26 | { 27 | 28 | //return context.Set().ToList(); 29 | return context.Set().Where(e => !((IDeletable)e).IsDeleted).ToList(); 30 | } 31 | public T Get(Func predicate) //find object by name ,id anything 32 | { 33 | //return context.Set().FirstOrDefault(predicate); 34 | var entities = context.Set().Where(e => !((IDeletable)e).IsDeleted).ToList(); 35 | return entities.FirstOrDefault(predicate); 36 | } 37 | public int save() 38 | { 39 | return context.SaveChanges(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /E-Learning-Management-System/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /E-Learning-Management-System/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "cs": "Data Source=.;Initial Catalog=API-ELEARNING;Integrated Security=True;Encrypt=True;Trust Server Certificate=True" 11 | }, 12 | "JWT": { 13 | "ValidIss": "http://localhost:60086", 14 | "ValidAud": "http://localhost:4200", 15 | "SecritKey": "gfggggggggggggggggggggggggggggggggggg" 16 | } 17 | } 18 | --------------------------------------------------------------------------------