├── CoreLMS.Web ├── Pages │ ├── _ViewStart.cshtml │ ├── _ViewImports.cshtml │ ├── Privacy.cshtml │ ├── Shared │ │ ├── _ValidationScriptsPartial.cshtml │ │ └── _Layout.cshtml │ ├── Index.cshtml │ ├── Index.cshtml.cs │ ├── Privacy.cshtml.cs │ ├── Error.cshtml.cs │ └── Error.cshtml ├── Areas │ └── Admin │ │ ├── Pages │ │ ├── _ViewStart.cshtml │ │ ├── _ViewImports.cshtml │ │ ├── Shared │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ └── _Layout.cshtml │ │ ├── Index.cshtml │ │ ├── Index.cshtml.cs │ │ ├── Courses │ │ │ ├── Create.cshtml.cs │ │ │ ├── Delete.cshtml │ │ │ ├── Details.cshtml.cs │ │ │ ├── Details.cshtml │ │ │ ├── Delete.cshtml.cs │ │ │ ├── Index.cshtml.cs │ │ │ ├── Create.cshtml │ │ │ ├── Edit.cshtml │ │ │ ├── Index.cshtml │ │ │ └── Edit.cshtml.cs │ │ └── Authors │ │ │ ├── Create.cshtml.cs │ │ │ ├── Index.cshtml.cs │ │ │ ├── Details.cshtml.cs │ │ │ ├── Delete.cshtml.cs │ │ │ ├── Delete.cshtml │ │ │ ├── Edit.cshtml.cs │ │ │ ├── Details.cshtml │ │ │ ├── Index.cshtml │ │ │ ├── Create.cshtml │ │ │ └── Edit.cshtml │ │ └── Models │ │ ├── CourseViewModel.cs │ │ └── AuthorViewModel.cs ├── wwwroot │ ├── favicon.ico │ ├── js │ │ └── site.js │ ├── lib │ │ ├── jquery-validation-unobtrusive │ │ │ ├── LICENSE.txt │ │ │ └── jquery.validate.unobtrusive.min.js │ │ ├── jquery-validation │ │ │ └── LICENSE.md │ │ ├── bootstrap │ │ │ ├── LICENSE │ │ │ └── dist │ │ │ │ └── css │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ └── bootstrap-reboot.css │ │ └── jquery │ │ │ └── LICENSE.txt │ └── css │ │ ├── site.css │ │ └── admin.css ├── Properties │ ├── serviceDependencies.json │ ├── serviceDependencies.local.json │ └── launchSettings.json ├── appsettings.Development.json ├── appsettings.json ├── ScaffoldingReadMe.txt ├── Program.cs ├── CoreLMS.Web.csproj └── Startup.cs ├── CoreLMS.Persistence ├── Entity.cs ├── AppDbContextFactory.cs ├── CoreLMS.Persistence.csproj ├── Migrations │ ├── 20200729172853_InitialCourseEntityWork.cs │ ├── 20200805184515_AuthorsToCourseLessons.cs │ ├── 20200729172853_InitialCourseEntityWork.Designer.cs │ ├── 20201104181704_AuthorPersonUpdate.cs │ ├── 20200805182225_CourseLessonsAndAuthors.cs │ ├── 20200805182225_CourseLessonsAndAuthors.Designer.cs │ ├── 20201104181704_AuthorPersonUpdate.Designer.cs │ └── AppDbContextModelSnapshot.cs ├── AppDbContext.Authors.cs ├── AppDbContext.Courses.cs └── AppDbContext.cs ├── CoreLMS.Core ├── Interfaces │ ├── IAppDbContext.cs │ ├── ICourseLessonService.cs │ ├── IAuditableEntity.cs │ ├── IAppDbContext.Authors.cs │ ├── IAppDbContext.Courses.cs │ ├── IAuthorService.cs │ └── ICourseService.cs ├── Types │ ├── LessonType.cs │ ├── CourseType.cs │ └── VideoSourceType.cs ├── CoreLMS.Core.csproj ├── Entities │ ├── AuthorCourseLesson.cs │ ├── CourseLessonAttachment.cs │ ├── Course.cs │ ├── CourseLesson.cs │ └── Author.cs ├── DataTransferObjects │ ├── Courses │ │ ├── CreateCourseDto.cs │ │ ├── UpdateCourseDto.cs │ │ └── CourseLessons │ │ │ └── CreateCourseLessonDto.cs │ └── Authors │ │ ├── CreateAuthorDto.cs │ │ └── UpdateAuthorDto.cs └── Exceptions │ └── ApplicationException.cs ├── CoreLMS.Infrastructure └── CoreLMS.Infrastructure.csproj ├── CoreLMS.Tests ├── Services │ ├── Courses │ │ ├── CourseServiceTests.CourseLessons.cs │ │ ├── CourseServiceTests.Exceptions.cs │ │ └── CourseServiceTests.cs │ └── Authors │ │ ├── AuthorServiceTests.Exceptions.cs │ │ └── AuthorServiceTests.cs └── CoreLMS.Tests.csproj ├── .dockerignore ├── CoreLMS.Application ├── CoreLMS.Application.csproj ├── Services │ ├── AuthorService │ │ ├── AuthorService.Validations.cs │ │ └── AuthorService.cs │ ├── CourseLessonService │ │ └── CourseLessonService.cs │ └── CourseService │ │ ├── CourseService.Validations.cs │ │ └── CourseService.cs └── Validators │ └── ModelValidator.cs ├── LICENSE.md ├── README.md ├── CoreLMS.sln └── .gitignore /CoreLMS.Web/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/Entity.cs: -------------------------------------------------------------------------------- 1 | namespace CoreLMS.Persistence 2 | { 3 | internal class Entity 4 | { 5 | } 6 | } -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FitzyCodesThings/core-lms/HEAD/CoreLMS.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /CoreLMS.Web/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "secrets1": { 4 | "type": "secrets" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using CoreLMS.Web 2 | @namespace CoreLMS.Web.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /CoreLMS.Web/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "secrets1": { 4 | "type": "secrets.user" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /CoreLMS.Core/Interfaces/IAppDbContext.cs: -------------------------------------------------------------------------------- 1 | namespace CoreLMS.Core.Interfaces 2 | { 3 | public partial interface IAppDbContext 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using CoreLMS.Core.Types 2 | @using CoreLMS.Web.Areas.Admin 3 | @namespace CoreLMS.Web.Areas.Admin.Pages 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 5 | -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model PrivacyModel 3 | @{ 4 | ViewData["Title"] = "Privacy Policy"; 5 | } 6 |

@ViewData["Title"]

7 | 8 |

Use this page to detail your site's privacy policy.

9 | -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /CoreLMS.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model IndexModel 3 | @{ 4 | ViewData["Title"] = "CoreLMS Administration"; 5 | } 6 | 7 |
8 |

CoreLMS Administration

9 |
10 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your Javascript code. 5 | -------------------------------------------------------------------------------- /CoreLMS.Core/Types/LessonType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CoreLMS.Core.Types 6 | { 7 | public enum LessonType 8 | { 9 | Video = 1000, 10 | Text = 2000 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreLMS.Infrastructure/CoreLMS.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CoreLMS.Core/Interfaces/ICourseLessonService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CoreLMS.Core.Interfaces 8 | { 9 | public class ICourseLessonService 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /CoreLMS.Core/Types/CourseType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CoreLMS.Core.Types 6 | { 7 | public enum CourseType 8 | { 9 | OnDemandSimple = 1000, 10 | OnDemandComplex = 1001, 11 | LiveWebinar = 2000 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model IndexModel 3 | @{ 4 | ViewData["Title"] = "Home page"; 5 | } 6 | 7 |
8 |

Welcome

9 |

Learn about building Web apps with ASP.NET Core.

10 |
11 | -------------------------------------------------------------------------------- /CoreLMS.Core/Types/VideoSourceType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CoreLMS.Core.Types 6 | { 7 | public enum VideoSourceType 8 | { 9 | WistiaEmbed = 1000, 10 | 11 | YouTubeEmbed = 2000, 12 | 13 | VimeoEmbed = 3000, 14 | 15 | OtherEmbed = 10000 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreLMS.Core/CoreLMS.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /CoreLMS.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ConnectionStrings": { 11 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=CoreLMS;Trusted_Connection=True;MultipleActiveResultSets=true" 12 | } 13 | } -------------------------------------------------------------------------------- /CoreLMS.Core/Interfaces/IAuditableEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CoreLMS.Core.Interfaces 6 | { 7 | public interface IAuditableEntity 8 | { 9 | int Id { get; set; } 10 | DateTime DateCreated { get; set; } 11 | DateTime DateUpdated { get; set; } 12 | DateTime? DateDeleted { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreLMS.Tests/Services/Courses/CourseServiceTests.CourseLessons.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Entities; 2 | using Moq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Tynamix.ObjectFiller; 8 | using Xunit; 9 | 10 | namespace CoreLMS.Tests.Services.Courses 11 | { 12 | public partial class CourseServiceTests 13 | { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /CoreLMS.Core/Entities/AuthorCourseLesson.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CoreLMS.Core.Entities 6 | { 7 | public class AuthorCourseLesson 8 | { 9 | public int AuthorId { get; set; } 10 | public Author Author { get; set; } 11 | public int CourseLessonId { get; set; } 12 | public CourseLesson CourseLesson { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /CoreLMS.Application/CoreLMS.Application.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /CoreLMS.Web/ScaffoldingReadMe.txt: -------------------------------------------------------------------------------- 1 | Scaffolding has generated all the files and added the required dependencies. 2 | 3 | However the Application's Startup code may required additional changes for things to work end to end. 4 | Add the following code to the Configure method in your Application's Startup class if not already done: 5 | 6 | app.UseMvc(routes => 7 | { 8 | routes.MapRoute( 9 | name : "areas", 10 | template : "{area:exists}/{controller=Home}/{action=Index}/{id?}" 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /CoreLMS.Core/DataTransferObjects/Courses/CreateCourseDto.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Types; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Text; 6 | 7 | namespace CoreLMS.Core.DataTransferObjects 8 | { 9 | public class CreateCourseDto 10 | { 11 | [Required] 12 | public string Name { get; set; } 13 | 14 | public string Description { get; set; } 15 | public CourseType CourseType { get; set; } 16 | public string CourseImageURL { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CoreLMS.Core/Exceptions/ApplicationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CoreLMS.Core.Exceptions 6 | { 7 | public class ApplicationException : Exception 8 | { 9 | public ApplicationException() 10 | { 11 | } 12 | 13 | public ApplicationException(string message) 14 | : base(message) 15 | { 16 | } 17 | 18 | public ApplicationException(string message, Exception inner) 19 | : base(message, inner) 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CoreLMS.Core/Interfaces/IAppDbContext.Authors.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CoreLMS.Core.Interfaces 8 | { 9 | public partial interface IAppDbContext 10 | { 11 | public Task CreateAuthorAsync(Author author); 12 | public Task SelectAuthorByIdAsync(int id); 13 | public Task> SelectAuthorsAsync(); 14 | public Task UpdateAuthorAsync(Author author); 15 | public Task DeleteAuthorAsync(Author author); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreLMS.Core/Interfaces/IAppDbContext.Courses.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Entities; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CoreLMS.Core.Interfaces 8 | { 9 | public partial interface IAppDbContext 10 | { 11 | public Task CreateCourseAsync(Course course); 12 | public Task SelectCourseByIdAsync(int id); 13 | public Task> SelectCoursesAsync(); 14 | public Task UpdateCourseAsync(Course course); 15 | public Task DeleteCourseAsync(Course course); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CoreLMS.Core/DataTransferObjects/Courses/UpdateCourseDto.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Types; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Text; 6 | 7 | namespace CoreLMS.Core.DataTransferObjects 8 | { 9 | public class UpdateCourseDto 10 | { 11 | [Required] 12 | public int Id { get; set; } 13 | 14 | [Required] 15 | public string Name { get; set; } 16 | 17 | public string Description { get; set; } 18 | public CourseType CourseType { get; set; } 19 | public string CourseImageURL { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace CoreLMS.Web.Pages 10 | { 11 | public class IndexModel : PageModel 12 | { 13 | private readonly ILogger _logger; 14 | 15 | public IndexModel(ILogger logger) 16 | { 17 | _logger = logger; 18 | } 19 | 20 | public void OnGet() 21 | { 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/Privacy.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace CoreLMS.Web.Pages 10 | { 11 | public class PrivacyModel : PageModel 12 | { 13 | private readonly ILogger _logger; 14 | 15 | public PrivacyModel(ILogger logger) 16 | { 17 | _logger = logger; 18 | } 19 | 20 | public void OnGet() 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /CoreLMS.Application/Services/AuthorService/AuthorService.Validations.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Application.Validators; 2 | using CoreLMS.Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace CoreLMS.Application.Services 8 | { 9 | public partial class AuthorService 10 | { 11 | private void ValidateAuthorOnCreate(Author author) 12 | { 13 | ModelValidator.ValidateModel(author); 14 | } 15 | 16 | private void ValidateAuthorOnUpdate(Author author) 17 | { 18 | ModelValidator.ValidateModel(author); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreLMS.Core/Interfaces/IAuthorService.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.DataTransferObjects; 2 | using CoreLMS.Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace CoreLMS.Core.Interfaces 9 | { 10 | public interface IAuthorService 11 | { 12 | Task> GetAuthorsAsync(); 13 | 14 | Task GetAuthorAsync(int id); 15 | 16 | Task AddAuthorAsync(CreateAuthorDto authorDto); 17 | 18 | Task UpdateAuthorAsync(UpdateAuthorDto authorDto); 19 | 20 | Task DeleteAuthorAsync(int id); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreLMS.Core/Interfaces/ICourseService.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.DataTransferObjects; 2 | using CoreLMS.Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace CoreLMS.Core.Interfaces 9 | { 10 | public interface ICourseService 11 | { 12 | Task> GetCoursesAsync(); 13 | 14 | Task GetCourseAsync(int id); 15 | 16 | Task AddCourseAsync(CreateCourseDto courseDto); 17 | 18 | Task UpdateCourseAsync(UpdateCourseDto courseDto); 19 | 20 | Task DeleteCourseAsync(int id); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.Extensions.Logging; 8 | 9 | namespace CoreLMS.Web.Areas.Admin.Pages 10 | { 11 | public class IndexModel : PageModel 12 | { 13 | private readonly ILogger _logger; 14 | 15 | public IndexModel(ILogger logger) 16 | { 17 | _logger = logger; 18 | } 19 | 20 | public void OnGet() 21 | { 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Models/CourseViewModel.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Types; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace CoreLMS.Web.Areas.Admin.Models 9 | { 10 | public class CourseViewModel 11 | { 12 | public int Id { get; set; } 13 | public DateTime DateCreated { get; set; } 14 | public DateTime DateUpdated { get; set; } 15 | 16 | public string Name { get; set; } 17 | public string Description { get; set; } 18 | public CourseType CourseType { get; set; } 19 | public string CourseImageURL { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreLMS.Core/Entities/CourseLessonAttachment.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Interfaces; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace CoreLMS.Core.Entities 7 | { 8 | public class CourseLessonAttachment : IAuditableEntity 9 | { 10 | public int Id { get; set; } 11 | public DateTime DateCreated { get; set; } 12 | public DateTime DateUpdated { get; set; } 13 | public DateTime? DateDeleted { get; set; } 14 | 15 | public int CourseLessonId { get; set; } 16 | public CourseLesson CourseLesson { get; set; } 17 | 18 | public string Name { get; set; } 19 | public string Description { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CoreLMS.Application/Services/CourseLessonService/CourseLessonService.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Interfaces; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace CoreLMS.Application.Services.CourseLessonService 10 | { 11 | public class CourseLessonService : ICourseLessonService 12 | { 13 | private readonly IAppDbContext db; 14 | private readonly ILogger logger; 15 | 16 | public CourseLessonService(IAppDbContext db, ILogger logger) 17 | { 18 | this.db = db; 19 | this.logger = logger; 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CoreLMS.Web/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:56862", 7 | "sslPort": 44302 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "CoreLMS.Web": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Models/AuthorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace CoreLMS.Web.Areas.Admin.Models 7 | { 8 | public class AuthorViewModel 9 | { 10 | public int Id { get; set; } 11 | public DateTime DateCreated { get; set; } 12 | public DateTime DateUpdated { get; set; } 13 | 14 | public string FirstName { get; set; } 15 | public string MiddleName { get; set; } 16 | public string LastName { get; set; } 17 | public string Suffix { get; set; } 18 | public string ContactEmail { get; set; } 19 | public string ContactPhoneNumber { get; set; } 20 | public string Description { get; set; } 21 | public string WebsiteURL { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CoreLMS.Core/DataTransferObjects/Courses/CourseLessons/CreateCourseLessonDto.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Types; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Text; 6 | 7 | namespace CoreLMS.Core.DataTransferObjects 8 | { 9 | public class CreateCourseLessonDto 10 | { 11 | [Required] 12 | public int CourseId { get; set; } 13 | 14 | [Required] 15 | public string Name { get; set; } 16 | 17 | public string Description { get; set; } 18 | public LessonType LessonType { get; set; } 19 | public VideoSourceType VideoSourceType { get; set; } 20 | public string VideoSourceCode { get; set; } 21 | 22 | // TODO Add Authors to CourseLessonDtos 23 | //public ICollection Authors { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CoreLMS.Core/DataTransferObjects/Authors/CreateAuthorDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Text; 5 | 6 | namespace CoreLMS.Core.DataTransferObjects 7 | { 8 | public class CreateAuthorDto 9 | { 10 | [Required] 11 | public string FirstName { get; set; } 12 | 13 | public string MiddleName { get; set; } 14 | 15 | [Required] 16 | public string LastName { get; set; } 17 | public string Suffix { get; set; } 18 | 19 | [Required] 20 | [EmailAddress] 21 | public string ContactEmail { get; set; } 22 | 23 | [Phone] 24 | public string ContactPhoneNumber { get; set; } 25 | 26 | public string Description { get; set; } 27 | public string WebsiteURL { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /CoreLMS.Application/Validators/ModelValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Text; 5 | 6 | namespace CoreLMS.Application.Validators 7 | { 8 | public static class ModelValidator 9 | { 10 | public static void ValidateModel(object model) 11 | { 12 | var ctx = new ValidationContext(model, null, null); 13 | 14 | Validator.ValidateObject(model, ctx, true); 15 | } 16 | 17 | private static IList GetModelValidationResults(object model) 18 | { 19 | var validationResults = new List(); 20 | var ctx = new ValidationContext(model, null, null); 21 | 22 | Validator.TryValidateObject(model, ctx, validationResults, true); 23 | return validationResults; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CoreLMS.Core/DataTransferObjects/Authors/UpdateAuthorDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.Text; 5 | 6 | namespace CoreLMS.Core.DataTransferObjects 7 | { 8 | public class UpdateAuthorDto 9 | { 10 | [Required] 11 | public int Id { get; set; } 12 | 13 | [Required] 14 | public string FirstName { get; set; } 15 | 16 | public string MiddleName { get; set; } 17 | 18 | [Required] 19 | public string LastName { get; set; } 20 | 21 | public string Suffix { get; set; } 22 | 23 | [Required] 24 | [EmailAddress] 25 | public string ContactEmail { get; set; } 26 | 27 | [Phone] 28 | public string ContactPhoneNumber { get; set; } 29 | 30 | public string Description { get; set; } 31 | public string WebsiteURL { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/AppDbContextFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Design; 2 | using Microsoft.Extensions.Configuration; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Text; 7 | 8 | namespace CoreLMS.Persistence 9 | { 10 | public class AppDbContextFactory : IDesignTimeDbContextFactory 11 | { 12 | public AppDbContext CreateDbContext(string[] args) 13 | { 14 | 15 | var basePath = Directory.GetCurrentDirectory() + string.Format("{0}..{0}CoreLMS.Web", Path.DirectorySeparatorChar); 16 | 17 | var configuration = new ConfigurationBuilder() 18 | .SetBasePath(basePath) 19 | .AddJsonFile("appsettings.json") 20 | .AddJsonFile("appsettings.Development.json", optional: true) 21 | .Build(); 22 | 23 | return new AppDbContext(configuration); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Mvc.RazorPages; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace CoreLMS.Web.Pages 11 | { 12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 13 | public class ErrorModel : PageModel 14 | { 15 | public string RequestId { get; set; } 16 | 17 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 18 | 19 | private readonly ILogger _logger; 20 | 21 | public ErrorModel(ILogger logger) 22 | { 23 | _logger = logger; 24 | } 25 | 26 | public void OnGet() 27 | { 28 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /CoreLMS.Core/Entities/Course.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Interfaces; 2 | using CoreLMS.Core.Types; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.DataAnnotations; 6 | using System.Text; 7 | 8 | namespace CoreLMS.Core.Entities 9 | { 10 | public class Course : IAuditableEntity 11 | { 12 | public Course() 13 | { 14 | this.CourseLessons = new HashSet(); 15 | } 16 | 17 | public int Id { get; set; } 18 | public DateTime DateCreated { get; set; } 19 | public DateTime DateUpdated { get; set; } 20 | public DateTime? DateDeleted { get; set; } 21 | 22 | [Required] 23 | public string Name { get; set; } 24 | public string Description { get; set; } 25 | public CourseType CourseType { get; set; } 26 | public string CourseImageURL { get; set; } 27 | 28 | public ICollection CourseLessons { get; set; } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CoreLMS.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace CoreLMS.Web 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureLogging(logging => 22 | { 23 | logging.ClearProviders(); 24 | logging.AddConsole(); 25 | }) 26 | .ConfigureWebHostDefaults(webBuilder => 27 | { 28 | webBuilder.UseStartup(); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # Released Under MIT License 2 | 3 | Copyright 2020 John DeLancey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /CoreLMS.Application/Services/CourseService/CourseService.Validations.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Application.Validators; 2 | using CoreLMS.Core.Entities; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.DataAnnotations; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace CoreLMS.Application.Services 10 | { 11 | public partial class CourseService 12 | { 13 | private void ValidateCourseOnCreate(Course course) 14 | { 15 | ModelValidator.ValidateModel(course); 16 | } 17 | 18 | private void ValidateCourseOnUpdate(Course course) 19 | { 20 | // TODO Turn "minimum course lesson count" back on 21 | ModelValidator.ValidateModel(course); 22 | //ValidateCourseHasAtLeastOneLesson(course); 23 | } 24 | 25 | private void ValidateCourseHasAtLeastOneLesson(Course course) 26 | { 27 | if (course.CourseLessons == null || course.CourseLessons.Count() == 0) 28 | throw new ValidationException("Courses must contain at least one lesson."); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Create.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.AspNetCore.Mvc.RazorPages; 4 | using CoreLMS.Core.Entities; 5 | using CoreLMS.Core.Interfaces; 6 | using CoreLMS.Core.DataTransferObjects; 7 | 8 | namespace CoreLMS.Web.Areas.Admin.Pages.Courses 9 | { 10 | public class CreateModel : PageModel 11 | { 12 | private readonly ICourseService courseService; 13 | 14 | public CreateModel(ICourseService courseService) 15 | { 16 | this.courseService = courseService; 17 | } 18 | 19 | public IActionResult OnGet() 20 | { 21 | return Page(); 22 | } 23 | 24 | [BindProperty] 25 | public CreateCourseDto CourseDto { get; set; } 26 | 27 | public async Task OnPostAsync() 28 | { 29 | if (!ModelState.IsValid) 30 | { 31 | return Page(); 32 | } 33 | 34 | await courseService.AddCourseAsync(CourseDto); 35 | 36 | return RedirectToPage("./Index"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /CoreLMS.Core/Entities/CourseLesson.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Interfaces; 2 | using CoreLMS.Core.Types; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace CoreLMS.Core.Entities 8 | { 9 | public class CourseLesson : IAuditableEntity 10 | { 11 | public CourseLesson() 12 | { 13 | this.CourseLessonAttachments = new HashSet(); 14 | this.Authors = new HashSet(); 15 | } 16 | 17 | public int Id { get; set; } 18 | public DateTime DateCreated { get; set; } 19 | public DateTime DateUpdated { get; set; } 20 | public DateTime? DateDeleted { get; set; } 21 | 22 | public int CourseId { get; set; } 23 | public Course Course { get; set; } 24 | 25 | public string Name { get; set; } 26 | public string Description { get; set; } 27 | public LessonType LessonType { get; set; } 28 | public VideoSourceType VideoSourceType { get; set; } 29 | public string VideoSourceCode { get; set; } 30 | 31 | public ICollection CourseLessonAttachments { get; set; } 32 | 33 | public ICollection Authors { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /CoreLMS.Core/Entities/Author.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Interfaces; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | using System.Text; 6 | 7 | namespace CoreLMS.Core.Entities 8 | { 9 | public class Author : IAuditableEntity 10 | { 11 | public Author() 12 | { 13 | this.CourseLessons = new HashSet(); 14 | } 15 | 16 | public int Id { get; set; } 17 | public DateTime DateCreated { get; set; } 18 | public DateTime DateUpdated { get; set; } 19 | public DateTime? DateDeleted { get; set; } 20 | 21 | [Required] 22 | public string FirstName { get; set; } 23 | 24 | public string MiddleName { get; set; } 25 | 26 | [Required] 27 | public string LastName { get; set; } 28 | public string Suffix { get; set; } 29 | 30 | [Required] 31 | [EmailAddress] 32 | public string ContactEmail { get; set; } 33 | 34 | [Phone] 35 | public string ContactPhoneNumber { get; set; } 36 | 37 | public string Description { get; set; } 38 | public string WebsiteURL { get; set; } 39 | 40 | public ICollection CourseLessons { get; set; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Create.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using CoreLMS.Core.Entities; 9 | using CoreLMS.Persistence; 10 | using CoreLMS.Core.Interfaces; 11 | using CoreLMS.Core.DataTransferObjects; 12 | 13 | namespace CoreLMS.Web.Areas.Admin.Pages.Authors 14 | { 15 | public class CreateModel : PageModel 16 | { 17 | private readonly IAuthorService authorService; 18 | 19 | public CreateModel(IAuthorService authorService) 20 | { 21 | this.authorService = authorService; 22 | } 23 | 24 | public IActionResult OnGet() 25 | { 26 | return Page(); 27 | } 28 | 29 | [BindProperty] 30 | public CreateAuthorDto AuthorDto { get; set; } 31 | 32 | public async Task OnPostAsync() 33 | { 34 | if (!ModelState.IsValid) 35 | { 36 | return Page(); 37 | } 38 | 39 | await authorService.AddAuthorAsync(AuthorDto); 40 | 41 | return RedirectToPage("./Index"); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CoreLMS 2 | 3 | An online learning management system including ecommerce functionality and more developed [live, on Twitch](https://twitch.tv/fitzycodesthings), with the goal of building a clean, pragmatic system in DotNet Core. 4 | 5 | 6 | # Released Under MIT License 7 | 8 | Copyright 2020 John DeLancey 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/CoreLMS.Persistence.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | all 11 | runtime; build; native; contentfiles; analyzers; buildtransitive 12 | 13 | 14 | 15 | all 16 | runtime; build; native; contentfiles; analyzers; buildtransitive 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /CoreLMS.Tests/CoreLMS.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | all 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Courses.DeleteModel 3 | 4 | @{ 5 | ViewData["Title"] = "Delete"; 6 | } 7 | 8 |

Delete

9 | 10 |

Are you sure you want to delete this?

11 |
12 |

Course

13 |
14 |
15 |
16 | @Html.DisplayNameFor(model => model.CourseDto.Name) 17 |
18 |
19 | @Html.DisplayFor(model => model.CourseDto.Name) 20 |
21 |
22 | @Html.DisplayNameFor(model => model.CourseDto.Description) 23 |
24 |
25 | @Html.DisplayFor(model => model.CourseDto.Description) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.CourseDto.CourseType) 29 |
30 |
31 | @Html.DisplayFor(model => model.CourseDto.CourseType) 32 |
33 |
34 | @Html.DisplayNameFor(model => model.CourseDto.CourseImageURL) 35 |
36 |
37 | @Html.DisplayFor(model => model.CourseDto.CourseImageURL) 38 |
39 |
40 | 41 |
42 | 43 | | 44 | Back to List 45 |
46 |
47 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/Migrations/20200729172853_InitialCourseEntityWork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace CoreLMS.Persistence.Migrations 5 | { 6 | public partial class InitialCourseEntityWork : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.CreateTable( 11 | name: "Courses", 12 | columns: table => new 13 | { 14 | Id = table.Column(nullable: false) 15 | .Annotation("SqlServer:Identity", "1, 1"), 16 | DateCreated = table.Column(nullable: false), 17 | DateUpdated = table.Column(nullable: false), 18 | DateDeleted = table.Column(nullable: true), 19 | IsDeleted = table.Column(nullable: false), 20 | Name = table.Column(nullable: true), 21 | Description = table.Column(nullable: true), 22 | CourseType = table.Column(nullable: false), 23 | CourseImageURL = table.Column(nullable: true) 24 | }, 25 | constraints: table => 26 | { 27 | table.PrimaryKey("PK_Courses", x => x.Id); 28 | }); 29 | } 30 | 31 | protected override void Down(MigrationBuilder migrationBuilder) 32 | { 33 | migrationBuilder.DropTable( 34 | name: "Courses"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using CoreLMS.Core.Entities; 9 | using CoreLMS.Persistence; 10 | using CoreLMS.Core.Interfaces; 11 | using CoreLMS.Web.Areas.Admin.Models; 12 | 13 | namespace CoreLMS.Web.Areas.Admin.Pages.Authors 14 | { 15 | public class IndexModel : PageModel 16 | { 17 | private readonly IAuthorService authorService; 18 | 19 | public IndexModel(IAuthorService authorService) 20 | { 21 | this.authorService = authorService; 22 | } 23 | 24 | public IList Authors { get;set; } 25 | 26 | public async Task OnGetAsync() 27 | { 28 | var dbAuthors = await authorService.GetAuthorsAsync(); 29 | 30 | this.Authors = dbAuthors.Select(p => new AuthorViewModel 31 | { 32 | Id = p.Id, 33 | DateCreated = p.DateCreated, 34 | DateUpdated = p.DateUpdated, 35 | FirstName = p.FirstName, 36 | MiddleName = p.MiddleName, 37 | LastName = p.LastName, 38 | Suffix = p.Suffix, 39 | ContactEmail = p.ContactEmail, 40 | ContactPhoneNumber = p.ContactPhoneNumber, 41 | Description = p.Description, 42 | WebsiteURL = p.WebsiteURL 43 | }).ToList(); 44 | } 45 | } 46 | 47 | 48 | } 49 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Details.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using CoreLMS.Core.Entities; 9 | using CoreLMS.Persistence; 10 | using CoreLMS.Core.Interfaces; 11 | 12 | namespace CoreLMS.Web.Areas.Admin.Pages.Courses 13 | { 14 | public class DetailsModel : PageModel 15 | { 16 | private readonly ICourseService courseService; 17 | 18 | public DetailsModel(ICourseService courseService) 19 | { 20 | this.courseService = courseService; 21 | } 22 | 23 | public CourseViewModel Course { get; set; } 24 | 25 | public async Task OnGetAsync(int? id) 26 | { 27 | if (id == null) 28 | { 29 | return NotFound(); 30 | } 31 | 32 | var dbCourse = await courseService.GetCourseAsync(id.Value); 33 | 34 | Course = new CourseViewModel 35 | { 36 | Id = dbCourse.Id, 37 | DateCreated = dbCourse.DateCreated, 38 | DateUpdated = dbCourse.DateUpdated, 39 | Name = dbCourse.Name, 40 | Description = dbCourse.Description, 41 | CourseType = dbCourse.CourseType, 42 | CourseImageURL = dbCourse.CourseImageURL 43 | }; 44 | 45 | if (Course == null) 46 | { 47 | return NotFound(); 48 | } 49 | return Page(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/AppDbContext.Authors.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.ChangeTracking; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace CoreLMS.Persistence 10 | { 11 | public partial class AppDbContext 12 | { 13 | public DbSet Authors { get; set; } 14 | 15 | public async Task CreateAuthorAsync(Author author) 16 | { 17 | EntityEntry authorEntry = await this.Authors.AddAsync(author); 18 | await this.SaveChangesAsync(); 19 | return authorEntry.Entity; 20 | } 21 | 22 | public async Task SelectAuthorByIdAsync(int id) => 23 | await this.Authors 24 | .AsNoTracking() 25 | .FirstOrDefaultAsync(p => p.Id == id); 26 | 27 | public async Task> SelectAuthorsAsync() 28 | { 29 | return await this.Authors 30 | .ToListAsync(); 31 | } 32 | 33 | public async Task UpdateAuthorAsync(Author author) 34 | { 35 | EntityEntry authorEntry = this.Authors.Update(author); 36 | await this.SaveChangesAsync(); 37 | return authorEntry.Entity; 38 | } 39 | public async Task DeleteAuthorAsync(Author author) 40 | { 41 | EntityEntry authorEntry = this.Authors.Remove(author); 42 | await this.SaveChangesAsync(); 43 | return authorEntry.Entity; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Details.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Courses.DetailsModel 3 | 4 | @{ 5 | ViewData["Title"] = "Details"; 6 | } 7 | 8 |

Details

9 | 10 |
11 |

Course

12 |
13 |
14 | 15 |
16 | @Html.DisplayNameFor(model => model.Course.Name) 17 |
18 |
19 | @Html.DisplayFor(model => model.Course.Name) 20 |
21 |
22 | @Html.DisplayNameFor(model => model.Course.Description) 23 |
24 |
25 | @Html.DisplayFor(model => model.Course.Description) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.Course.CourseType) 29 |
30 |
31 | @Html.DisplayFor(model => model.Course.CourseType) 32 |
33 |
34 | @Html.DisplayNameFor(model => model.Course.CourseImageURL) 35 |
36 |
37 | @Html.DisplayFor(model => model.Course.CourseImageURL) 38 |
39 |
40 | @Html.DisplayNameFor(model => model.Course.DateCreated) 41 |
42 |
43 | @Html.DisplayFor(model => model.Course.DateCreated) 44 |
45 |
46 | @Html.DisplayNameFor(model => model.Course.DateUpdated) 47 |
48 |
49 | @Html.DisplayFor(model => model.Course.DateUpdated) 50 |
51 | 52 |
53 |
54 |
55 | Edit | 56 | Back to List 57 |
58 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Details.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using CoreLMS.Core.Entities; 9 | using CoreLMS.Persistence; 10 | using CoreLMS.Core.Interfaces; 11 | using CoreLMS.Web.Areas.Admin.Models; 12 | 13 | namespace CoreLMS.Web.Areas.Admin.Pages.Authors 14 | { 15 | public class DetailsModel : PageModel 16 | { 17 | private readonly IAuthorService authorService; 18 | 19 | public DetailsModel(IAuthorService authorService) 20 | { 21 | this.authorService = authorService; 22 | } 23 | 24 | public AuthorViewModel Author { get; set; } 25 | 26 | public async Task OnGetAsync(int? id) 27 | { 28 | if (id == null) 29 | { 30 | return NotFound(); 31 | } 32 | 33 | var dbAuthor = await authorService.GetAuthorAsync(id.Value); 34 | 35 | Author = new AuthorViewModel 36 | { 37 | Id = dbAuthor.Id, 38 | DateCreated = dbAuthor.DateCreated, 39 | DateUpdated = dbAuthor.DateUpdated, 40 | FirstName = dbAuthor.FirstName, 41 | MiddleName = dbAuthor.MiddleName, 42 | LastName = dbAuthor.LastName, 43 | Suffix = dbAuthor.Suffix, 44 | ContactEmail = dbAuthor.ContactEmail, 45 | ContactPhoneNumber = dbAuthor.ContactPhoneNumber, 46 | Description = dbAuthor.Description, 47 | WebsiteURL = dbAuthor.WebsiteURL 48 | }; 49 | 50 | if (Author == null) 51 | { 52 | return NotFound(); 53 | } 54 | return Page(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /CoreLMS.Web/CoreLMS.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | cbf90f8d-f8a2-4bd2-91bf-24d985c7b106 6 | Linux 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Delete.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using CoreLMS.Core.Entities; 9 | using CoreLMS.Persistence; 10 | using CoreLMS.Core.Interfaces; 11 | using CoreLMS.Core.DataTransferObjects; 12 | 13 | namespace CoreLMS.Web.Areas.Admin.Pages.Courses 14 | { 15 | public class DeleteModel : PageModel 16 | { 17 | private readonly ICourseService courseService; 18 | 19 | public DeleteModel(ICourseService courseService) 20 | { 21 | this.courseService = courseService; 22 | } 23 | 24 | [BindProperty] 25 | public UpdateCourseDto CourseDto { get; set; } 26 | 27 | public async Task OnGetAsync(int? id) 28 | { 29 | if (id == null) 30 | { 31 | return NotFound(); 32 | } 33 | 34 | Course course = await courseService.GetCourseAsync(id.Value); 35 | 36 | if (course == null) 37 | { 38 | return NotFound(); 39 | } 40 | 41 | CourseDto = new UpdateCourseDto 42 | { 43 | Id = course.Id, 44 | Name = course.Name, 45 | Description = course.Description, 46 | CourseType = course.CourseType, 47 | CourseImageURL = course.CourseImageURL 48 | }; 49 | 50 | return Page(); 51 | } 52 | 53 | public async Task OnPostAsync() 54 | { 55 | if (CourseDto == null) 56 | { 57 | return NotFound(); 58 | } 59 | 60 | await courseService.DeleteCourseAsync(CourseDto.Id); 61 | 62 | return RedirectToPage("./Index"); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/Migrations/20200805184515_AuthorsToCourseLessons.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace CoreLMS.Persistence.Migrations 4 | { 5 | public partial class AuthorsToCourseLessons : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.CreateTable( 10 | name: "AuthorCourseLessons", 11 | columns: table => new 12 | { 13 | AuthorId = table.Column(nullable: false), 14 | CourseLessonId = table.Column(nullable: false) 15 | }, 16 | constraints: table => 17 | { 18 | table.PrimaryKey("PK_AuthorCourseLessons", x => new { x.AuthorId, x.CourseLessonId }); 19 | table.ForeignKey( 20 | name: "FK_AuthorCourseLessons_Authors_AuthorId", 21 | column: x => x.AuthorId, 22 | principalTable: "Authors", 23 | principalColumn: "Id", 24 | onDelete: ReferentialAction.Cascade); 25 | table.ForeignKey( 26 | name: "FK_AuthorCourseLessons_CourseLessons_CourseLessonId", 27 | column: x => x.CourseLessonId, 28 | principalTable: "CourseLessons", 29 | principalColumn: "Id", 30 | onDelete: ReferentialAction.Cascade); 31 | }); 32 | 33 | migrationBuilder.CreateIndex( 34 | name: "IX_AuthorCourseLessons_CourseLessonId", 35 | table: "AuthorCourseLessons", 36 | column: "CourseLessonId"); 37 | } 38 | 39 | protected override void Down(MigrationBuilder migrationBuilder) 40 | { 41 | migrationBuilder.DropTable( 42 | name: "AuthorCourseLessons"); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Index.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using CoreLMS.Core.Entities; 9 | using CoreLMS.Persistence; 10 | using CoreLMS.Core.Interfaces; 11 | using System.ComponentModel.DataAnnotations; 12 | using CoreLMS.Core.Types; 13 | 14 | namespace CoreLMS.Web.Areas.Admin.Pages.Courses 15 | { 16 | public class IndexModel : PageModel 17 | { 18 | private readonly ICourseService courseService; 19 | 20 | public IndexModel(ICourseService courseService) 21 | { 22 | this.courseService = courseService; 23 | } 24 | 25 | public List Courses { get; set; } 26 | 27 | public async Task OnGetAsync() 28 | { 29 | // 1. Get Course List from Service 30 | // 2. Map to "ViewModel" 31 | // 3. Return View 32 | 33 | var dbCourses = await courseService.GetCoursesAsync(); 34 | 35 | this.Courses = dbCourses.Select(p => new CourseViewModel 36 | { 37 | Id = p.Id, 38 | DateCreated = p.DateCreated, 39 | DateUpdated = p.DateUpdated, 40 | Name = p.Name, 41 | Description = p.Description, 42 | CourseType = p.CourseType, 43 | CourseImageURL = p.CourseImageURL 44 | }).ToList(); 45 | } 46 | } 47 | 48 | public class CourseViewModel 49 | { 50 | public int Id { get; set; } 51 | public DateTime DateCreated { get; set; } 52 | public DateTime DateUpdated { get; set; } 53 | 54 | [Required] 55 | public string Name { get; set; } 56 | public string Description { get; set; } 57 | public CourseType CourseType { get; set; } 58 | public string CourseImageURL { get; set; } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Create.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Courses.CreateModel 3 | 4 | @{ 5 | ViewData["Title"] = "Create"; 6 | } 7 | 8 |

Create a Course

9 |
10 |
11 |
12 |
13 |
14 |
15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 |
29 |
30 | 31 | 32 | 33 |
34 |
35 | 36 |
37 |
38 |
39 |
40 | 41 |
42 | Back to List 43 |
44 | 45 | @section Scripts { 46 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 47 | } 48 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/css/admin.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: .875rem; 3 | } 4 | 5 | .feather { 6 | width: 16px; 7 | height: 16px; 8 | vertical-align: text-bottom; 9 | } 10 | 11 | /* 12 | * Sidebar 13 | */ 14 | 15 | .sidebar { 16 | position: fixed; 17 | top: 0; 18 | bottom: 0; 19 | left: 0; 20 | z-index: 100; /* Behind the navbar */ 21 | padding: 0; 22 | box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); 23 | } 24 | 25 | .sidebar-sticky { 26 | position: -webkit-sticky; 27 | position: sticky; 28 | top: 48px; /* Height of navbar */ 29 | height: calc(100vh - 48px); 30 | padding-top: .5rem; 31 | overflow-x: hidden; 32 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ 33 | } 34 | 35 | .sidebar .nav-link { 36 | font-weight: 500; 37 | color: #333; 38 | } 39 | 40 | .sidebar .nav-link .feather { 41 | margin-right: 4px; 42 | color: #999; 43 | } 44 | 45 | .sidebar .nav-link.active { 46 | color: #007bff; 47 | } 48 | 49 | .sidebar .nav-link:hover .feather, 50 | .sidebar .nav-link.active .feather { 51 | color: inherit; 52 | } 53 | 54 | .sidebar-heading { 55 | font-size: .75rem; 56 | text-transform: uppercase; 57 | } 58 | 59 | /* 60 | * Navbar 61 | */ 62 | 63 | .navbar-brand { 64 | padding-top: .75rem; 65 | padding-bottom: .75rem; 66 | font-size: 1rem; 67 | background-color: rgba(0, 0, 0, .25); 68 | box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25); 69 | } 70 | 71 | .navbar .form-control { 72 | padding: .75rem 1rem; 73 | border-width: 0; 74 | border-radius: 0; 75 | } 76 | 77 | .form-control-dark { 78 | color: #fff; 79 | background-color: rgba(255, 255, 255, .1); 80 | border-color: rgba(255, 255, 255, .1); 81 | } 82 | 83 | .form-control-dark:focus { 84 | border-color: transparent; 85 | box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); 86 | } 87 | 88 | /* 89 | * Utilities 90 | */ 91 | 92 | .border-top { 93 | border-top: 1px solid #e5e5e5; 94 | } 95 | 96 | .border-bottom { 97 | border-bottom: 1px solid #e5e5e5; 98 | } 99 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Courses.EditModel 3 | 4 | @{ 5 | ViewData["Title"] = "Edit"; 6 | } 7 | 8 |

Edit

9 | 10 |

Course

11 |
12 |
13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 | 35 | 36 |
37 |
38 | 39 |
40 |
41 |
42 |
43 | 44 |
45 | Back to List 46 |
47 | 48 | @section Scripts { 49 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 50 | } 51 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Courses.IndexModel 3 | 4 | @{ 5 | ViewData["Title"] = "All Courses"; 6 | } 7 | 8 |

Courses

9 | 10 | 11 | 12 | 13 | 16 | 19 | 22 | 25 | 28 | 31 | 32 | 33 | 34 | 35 | @foreach (var item in Model.Courses) { 36 | 37 | 38 | 41 | 44 | 47 | 52 | 55 | 56 | 61 | 62 | } 63 | 64 |
14 | @Html.DisplayNameFor(model => model.Courses[0].Name) 15 | 17 | @Html.DisplayNameFor(model => model.Courses[0].Description) 18 | 20 | @Html.DisplayNameFor(model => model.Courses[0].CourseType) 21 | 23 | @Html.DisplayNameFor(model => model.Courses[0].CourseImageURL) 24 | 26 | @Html.DisplayNameFor(model => model.Courses[0].DateCreated) 27 | 29 | @Html.DisplayNameFor(model => model.Courses[0].DateUpdated) 30 |
39 | @Html.DisplayFor(modelItem => item.Name) 40 | 42 | @Html.DisplayFor(modelItem => item.Description) 43 | 45 | @Html.DisplayFor(modelItem => item.CourseType) 46 | 48 | @Html.DisplayFor(modelItem => item.CourseImageURL) 49 | 50 | @Html.DisplayFor(modelItem => item.DateCreated) 51 | 53 | @Html.DisplayFor(modelItem => item.DateUpdated) 54 | 57 | Edit | 58 | Details | 59 | Delete 60 |
65 | 66 |

67 | Create New Course 68 |

69 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Delete.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.EntityFrameworkCore; 8 | using CoreLMS.Core.Entities; 9 | using CoreLMS.Persistence; 10 | using CoreLMS.Core.Interfaces; 11 | using CoreLMS.Core.DataTransferObjects; 12 | 13 | namespace CoreLMS.Web.Areas.Admin.Pages.Authors 14 | { 15 | public class DeleteModel : PageModel 16 | { 17 | private readonly IAuthorService authorService; 18 | 19 | public DeleteModel(IAuthorService authorService) 20 | { 21 | this.authorService = authorService; 22 | } 23 | 24 | [BindProperty] 25 | public UpdateAuthorDto AuthorDto { get; set; } 26 | 27 | public async Task OnGetAsync(int? id) 28 | { 29 | if (id == null) 30 | { 31 | return NotFound(); 32 | } 33 | 34 | Author author; 35 | 36 | try 37 | { 38 | author = await authorService.GetAuthorAsync(id.Value); 39 | } 40 | catch (ApplicationException) 41 | { 42 | return NotFound(); 43 | } 44 | 45 | AuthorDto = new UpdateAuthorDto 46 | { 47 | Id = author.Id, 48 | FirstName = author.FirstName, 49 | MiddleName = author.MiddleName, 50 | LastName = author.LastName, 51 | Suffix = author.Suffix, 52 | ContactEmail = author.ContactEmail, 53 | ContactPhoneNumber = author.ContactPhoneNumber, 54 | Description = author.Description, 55 | WebsiteURL = author.WebsiteURL 56 | }; 57 | 58 | return Page(); 59 | } 60 | 61 | public async Task OnPostAsync(int? id) 62 | { 63 | if (id == null) 64 | { 65 | return NotFound(); 66 | } 67 | 68 | await authorService.DeleteAuthorAsync(AuthorDto.Id); 69 | 70 | return RedirectToPage("./Index"); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /CoreLMS.Web/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - CoreLMS.Web 7 | 8 | 9 | 10 | 11 |
12 | 31 |
32 |
33 |
34 | @RenderBody() 35 |
36 |
37 | 38 |
39 |
40 | © 2020 - CoreLMS.Web - Privacy 41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | @RenderSection("Scripts", required: false) 49 | 50 | 51 | -------------------------------------------------------------------------------- /CoreLMS.Web/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using CoreLMS.Core.Interfaces; 6 | using CoreLMS.Persistence; 7 | using Microsoft.AspNetCore.Builder; 8 | using Microsoft.AspNetCore.Hosting; 9 | using Microsoft.AspNetCore.HttpsPolicy; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.DependencyInjection; 12 | using Microsoft.Extensions.Hosting; 13 | using Microsoft.EntityFrameworkCore; 14 | using CoreLMS.Application.Services; 15 | 16 | namespace CoreLMS.Web 17 | { 18 | public class Startup 19 | { 20 | public Startup(IConfiguration configuration) 21 | { 22 | Configuration = configuration; 23 | } 24 | 25 | public IConfiguration Configuration { get; } 26 | 27 | // This method gets called by the runtime. Use this method to add services to the container. 28 | public void ConfigureServices(IServiceCollection services) 29 | { 30 | services.AddRazorPages().AddRazorRuntimeCompilation(); 31 | 32 | services.AddDbContext(); 33 | 34 | services.AddScoped(); 35 | 36 | services.AddTransient(); 37 | services.AddTransient(); 38 | } 39 | 40 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 41 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 42 | { 43 | if (env.IsDevelopment()) 44 | { 45 | app.UseDeveloperExceptionPage(); 46 | } 47 | else 48 | { 49 | app.UseExceptionHandler("/Error"); 50 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 51 | app.UseHsts(); 52 | } 53 | 54 | app.UseHttpsRedirection(); 55 | app.UseStaticFiles(); 56 | 57 | app.UseRouting(); 58 | 59 | app.UseAuthorization(); 60 | 61 | app.UseEndpoints(endpoints => 62 | { 63 | endpoints.MapRazorPages(); 64 | }); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/AppDbContext.Courses.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Entities; 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.ChangeTracking; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace CoreLMS.Persistence 10 | { 11 | // TODO Update SelectCoursesAsync to use custom predicate/where clause 12 | 13 | public partial class AppDbContext 14 | { 15 | public DbSet Courses { get; set; } 16 | public DbSet CourseLessons { get; set; } 17 | public DbSet CourseLessonAttachments { get; set; } 18 | 19 | public async Task CreateCourseAsync(Course course) 20 | { 21 | EntityEntry courseEntry = await this.Courses.AddAsync(course); 22 | await this.SaveChangesAsync(); 23 | return courseEntry.Entity; 24 | } 25 | 26 | public async Task UpdateCourseAsync(Course course) 27 | { 28 | EntityEntry courseEntry = this.Courses.Update(course); 29 | await this.SaveChangesAsync(); 30 | return courseEntry.Entity; 31 | } 32 | 33 | public async Task DeleteCourseAsync(Course course) 34 | { 35 | EntityEntry courseEntry = this.Courses.Remove(course); 36 | await this.SaveChangesAsync(); 37 | return courseEntry.Entity; 38 | } 39 | 40 | public async Task SelectCourseByIdAsync(int id) => 41 | await this.Courses 42 | .Include(p => p.CourseLessons) 43 | .ThenInclude(p => p.CourseLessonAttachments) 44 | .Include(p => p.CourseLessons) 45 | .ThenInclude(p => p.Authors) 46 | .ThenInclude(p => p.Author) 47 | .FirstOrDefaultAsync(p => p.Id == id); 48 | 49 | public async Task> SelectCoursesAsync() 50 | { 51 | return await this.Courses 52 | .Include(p => p.CourseLessons) 53 | .ThenInclude(p => p.CourseLessonAttachments) 54 | .Include(p => p.CourseLessons) 55 | .ThenInclude(p => p.Authors) 56 | .ThenInclude(p => p.Author) 57 | .ToListAsync(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Courses/Edit.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using Microsoft.EntityFrameworkCore; 9 | using CoreLMS.Core.Entities; 10 | using CoreLMS.Persistence; 11 | using CoreLMS.Core.DataTransferObjects; 12 | using CoreLMS.Core.Interfaces; 13 | using System.ComponentModel.DataAnnotations; 14 | 15 | namespace CoreLMS.Web.Areas.Admin.Pages.Courses 16 | { 17 | public class EditModel : PageModel 18 | { 19 | private readonly ICourseService courseService; 20 | 21 | public EditModel(ICourseService courseService) 22 | { 23 | this.courseService = courseService; 24 | } 25 | 26 | [BindProperty] 27 | public UpdateCourseDto CourseDto { get; set; } 28 | 29 | public async Task OnGetAsync(int? id) 30 | { 31 | if (id == null) 32 | { 33 | return NotFound(); 34 | } 35 | 36 | Course course; 37 | 38 | try 39 | { 40 | course = await courseService.GetCourseAsync(id.Value); 41 | } 42 | catch (ApplicationException) 43 | { 44 | 45 | return NotFound(); 46 | } 47 | 48 | CourseDto = new UpdateCourseDto 49 | { 50 | Id = course.Id, 51 | Name = course.Name, 52 | Description = course.Description, 53 | CourseType = course.CourseType, 54 | CourseImageURL = course.CourseImageURL 55 | }; 56 | 57 | return Page(); 58 | } 59 | 60 | public async Task OnPostAsync() 61 | { 62 | if (!ModelState.IsValid) 63 | { 64 | return Page(); 65 | } 66 | 67 | try 68 | { 69 | await courseService.UpdateCourseAsync(CourseDto); 70 | } 71 | catch (ValidationException ex) 72 | { 73 | ModelState.AddModelError("", ex.Message); 74 | return Page(); 75 | } 76 | catch (Exception) 77 | { 78 | return Page(); 79 | } 80 | 81 | return RedirectToPage("./Index"); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/Migrations/20200729172853_InitialCourseEntityWork.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using CoreLMS.Persistence; 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 | namespace CoreLMS.Persistence.Migrations 11 | { 12 | [DbContext(typeof(AppDbContext))] 13 | [Migration("20200729172853_InitialCourseEntityWork")] 14 | partial class InitialCourseEntityWork 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "3.1.6") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("CoreLMS.Core.Entities.Course", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("int") 29 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 30 | 31 | b.Property("CourseImageURL") 32 | .HasColumnType("nvarchar(max)"); 33 | 34 | b.Property("CourseType") 35 | .HasColumnType("int"); 36 | 37 | b.Property("DateCreated") 38 | .HasColumnType("datetime2"); 39 | 40 | b.Property("DateDeleted") 41 | .HasColumnType("datetime2"); 42 | 43 | b.Property("DateUpdated") 44 | .HasColumnType("datetime2"); 45 | 46 | b.Property("Description") 47 | .HasColumnType("nvarchar(max)"); 48 | 49 | b.Property("IsDeleted") 50 | .HasColumnType("bit"); 51 | 52 | b.Property("Name") 53 | .HasColumnType("nvarchar(max)"); 54 | 55 | b.HasKey("Id"); 56 | 57 | b.ToTable("Courses"); 58 | }); 59 | #pragma warning restore 612, 618 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | @ViewData["Title"] - CoreLMS.Web Admin 7 | 8 | 9 | 10 | 11 |
12 | 21 |
22 |
23 |
24 | 45 | 46 |
47 | @RenderBody() 48 |
49 |
50 |
51 | 52 | 53 | 54 | 55 | 56 | @RenderSection("Scripts", required: false) 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Authors.DeleteModel 3 | 4 | @{ 5 | ViewData["Title"] = "Delete"; 6 | } 7 | 8 |

Delete

9 | 10 |

Are you sure you want to delete this?

11 |
12 |

Author

13 |
14 |
15 |
16 | @Html.DisplayNameFor(model => model.AuthorDto.FirstName) 17 |
18 |
19 | @Html.DisplayFor(model => model.AuthorDto.FirstName) 20 |
21 |
22 | @Html.DisplayNameFor(model => model.AuthorDto.MiddleName) 23 |
24 |
25 | @Html.DisplayFor(model => model.AuthorDto.MiddleName) 26 |
27 |
28 | @Html.DisplayNameFor(model => model.AuthorDto.LastName) 29 |
30 |
31 | @Html.DisplayFor(model => model.AuthorDto.LastName) 32 |
33 |
34 | @Html.DisplayNameFor(model => model.AuthorDto.Suffix) 35 |
36 |
37 | @Html.DisplayFor(model => model.AuthorDto.Suffix) 38 |
39 |
40 | @Html.DisplayNameFor(model => model.AuthorDto.ContactEmail) 41 |
42 |
43 | @Html.DisplayFor(model => model.AuthorDto.ContactEmail) 44 |
45 |
46 | @Html.DisplayNameFor(model => model.AuthorDto.ContactPhoneNumber) 47 |
48 |
49 | @Html.DisplayFor(model => model.AuthorDto.ContactPhoneNumber) 50 |
51 |
52 | @Html.DisplayNameFor(model => model.AuthorDto.Description) 53 |
54 |
55 | @Html.DisplayFor(model => model.AuthorDto.Description) 56 |
57 |
58 | @Html.DisplayNameFor(model => model.AuthorDto.WebsiteURL) 59 |
60 |
61 | @Html.DisplayFor(model => model.AuthorDto.WebsiteURL) 62 |
63 |
64 | 65 |
66 | 67 | | 68 | Back to List 69 |
70 |
71 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Edit.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Mvc.RazorPages; 7 | using Microsoft.AspNetCore.Mvc.Rendering; 8 | using Microsoft.EntityFrameworkCore; 9 | using CoreLMS.Core.Entities; 10 | using CoreLMS.Persistence; 11 | using CoreLMS.Core.Interfaces; 12 | using CoreLMS.Core.DataTransferObjects; 13 | using System.ComponentModel.DataAnnotations; 14 | 15 | namespace CoreLMS.Web.Areas.Admin.Pages.Authors 16 | { 17 | public class EditModel : PageModel 18 | { 19 | private readonly IAuthorService authorService; 20 | 21 | public EditModel(IAuthorService authorService) 22 | { 23 | this.authorService = authorService; 24 | } 25 | 26 | [BindProperty] 27 | public UpdateAuthorDto AuthorDto { get; set; } 28 | 29 | public async Task OnGetAsync(int? id) 30 | { 31 | if (id == null) 32 | { 33 | return NotFound(); 34 | } 35 | 36 | Author author; 37 | 38 | try 39 | { 40 | author = await authorService.GetAuthorAsync(id.Value); 41 | } 42 | catch (ApplicationException) 43 | { 44 | return NotFound(); 45 | } 46 | 47 | AuthorDto = new UpdateAuthorDto 48 | { 49 | Id = author.Id, 50 | FirstName = author.FirstName, 51 | MiddleName = author.MiddleName, 52 | LastName = author.LastName, 53 | Suffix = author.Suffix, 54 | ContactEmail = author.ContactEmail, 55 | ContactPhoneNumber = author.ContactPhoneNumber, 56 | Description = author.Description, 57 | WebsiteURL = author.WebsiteURL 58 | }; 59 | 60 | return Page(); 61 | } 62 | 63 | // To protect from overposting attacks, enable the specific properties you want to bind to. 64 | // For more details, see https://aka.ms/RazorPagesCRUD. 65 | public async Task OnPostAsync() 66 | { 67 | if (!ModelState.IsValid) 68 | { 69 | return Page(); 70 | } 71 | 72 | try 73 | { 74 | await authorService.UpdateAuthorAsync(AuthorDto); 75 | } 76 | catch (ValidationException ex) 77 | { 78 | ModelState.AddModelError("", ex.Message); 79 | return Page(); 80 | } 81 | catch (Exception) 82 | { 83 | return Page(); 84 | } 85 | 86 | return RedirectToPage("./Index"); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Details.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Authors.DetailsModel 3 | 4 | @{ 5 | ViewData["Title"] = "Details"; 6 | } 7 | 8 |

Author Details

9 | 10 |
11 |

Author

12 |
13 |
14 |
15 | @Html.DisplayFor(model => model.Author.DateUpdated) 16 |
17 |
18 | @Html.DisplayNameFor(model => model.Author.FirstName) 19 |
20 |
21 | @Html.DisplayFor(model => model.Author.FirstName) 22 |
23 |
24 | @Html.DisplayNameFor(model => model.Author.MiddleName) 25 |
26 |
27 | @Html.DisplayFor(model => model.Author.MiddleName) 28 |
29 |
30 | @Html.DisplayNameFor(model => model.Author.LastName) 31 |
32 |
33 | @Html.DisplayFor(model => model.Author.LastName) 34 |
35 |
36 | @Html.DisplayNameFor(model => model.Author.Suffix) 37 |
38 |
39 | @Html.DisplayFor(model => model.Author.Suffix) 40 |
41 |
42 | @Html.DisplayNameFor(model => model.Author.ContactEmail) 43 |
44 |
45 | @Html.DisplayFor(model => model.Author.ContactEmail) 46 |
47 |
48 | @Html.DisplayNameFor(model => model.Author.ContactPhoneNumber) 49 |
50 |
51 | @Html.DisplayFor(model => model.Author.ContactPhoneNumber) 52 |
53 |
54 | @Html.DisplayNameFor(model => model.Author.Description) 55 |
56 |
57 | @Html.DisplayFor(model => model.Author.Description) 58 |
59 |
60 | @Html.DisplayNameFor(model => model.Author.WebsiteURL) 61 |
62 |
63 | @Html.DisplayFor(model => model.Author.WebsiteURL) 64 |
65 |
66 | @Html.DisplayNameFor(model => model.Author.DateCreated) 67 |
68 |
69 | @Html.DisplayFor(model => model.Author.DateCreated) 70 |
71 |
72 | @Html.DisplayNameFor(model => model.Author.DateUpdated) 73 |
74 |
75 |
76 |
77 | Edit | 78 | Back to List 79 |
80 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Index.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Authors.IndexModel 3 | 4 | @{ 5 | ViewData["Title"] = "All Authors"; 6 | } 7 | 8 |

Authors

9 | 10 | 11 | 12 | 13 | 16 | 19 | 22 | 25 | 28 | 31 | 34 | 37 | 40 | 43 | 44 | 45 | 46 | 47 | @foreach (var item in Model.Authors) { 48 | 49 | 52 | 55 | 58 | 61 | 64 | 67 | 70 | 73 | 76 | 79 | 84 | 85 | } 86 | 87 |
14 | @Html.DisplayNameFor(model => model.Authors[0].FirstName) 15 | 17 | @Html.DisplayNameFor(model => model.Authors[0].MiddleName) 18 | 20 | @Html.DisplayNameFor(model => model.Authors[0].LastName) 21 | 23 | @Html.DisplayNameFor(model => model.Authors[0].Suffix) 24 | 26 | @Html.DisplayNameFor(model => model.Authors[0].ContactEmail) 27 | 29 | @Html.DisplayNameFor(model => model.Authors[0].ContactPhoneNumber) 30 | 32 | @Html.DisplayNameFor(model => model.Authors[0].Description) 33 | 35 | @Html.DisplayNameFor(model => model.Authors[0].WebsiteURL) 36 | 38 | @Html.DisplayNameFor(model => model.Authors[0].DateCreated) 39 | 41 | @Html.DisplayNameFor(model => model.Authors[0].DateUpdated) 42 |
50 | @Html.DisplayFor(modelItem => item.FirstName) 51 | 53 | @Html.DisplayFor(modelItem => item.MiddleName) 54 | 56 | @Html.DisplayFor(modelItem => item.LastName) 57 | 59 | @Html.DisplayFor(modelItem => item.Suffix) 60 | 62 | @Html.DisplayFor(modelItem => item.ContactEmail) 63 | 65 | @Html.DisplayFor(modelItem => item.ContactPhoneNumber) 66 | 68 | @Html.DisplayFor(modelItem => item.Description) 69 | 71 | @Html.DisplayFor(modelItem => item.WebsiteURL) 72 | 74 | @Html.DisplayFor(modelItem => item.DateCreated) 75 | 77 | @Html.DisplayFor(modelItem => item.DateUpdated) 78 | 80 | Edit | 81 | Details | 82 | Delete 83 |
88 | 89 |

90 | Create New Author 91 |

92 | -------------------------------------------------------------------------------- /CoreLMS.Tests/Services/Authors/AuthorServiceTests.Exceptions.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.DataTransferObjects; 2 | using CoreLMS.Core.Entities; 3 | using Moq; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.ComponentModel.DataAnnotations; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using Tynamix.ObjectFiller; 10 | using Xunit; 11 | 12 | namespace CoreLMS.Tests.Services.Authors 13 | { 14 | public partial class AuthorServiceTests 15 | { 16 | [Fact] 17 | public async Task GetAuthorAsync_ShouldThrowApplicationExceptionWhenIdIsNotFound() 18 | { 19 | // given (arrange) 20 | int invalidId = 100; 21 | Author invalidAuthor = null; 22 | 23 | this.appDbContextMock.Setup(db => 24 | db.SelectAuthorByIdAsync(invalidId)) 25 | .ReturnsAsync(invalidAuthor); 26 | 27 | // when (act) 28 | var subjectTask = subject.GetAuthorAsync(invalidId); 29 | 30 | // then (assert) 31 | await Assert.ThrowsAsync(() => subjectTask); 32 | appDbContextMock.Verify(db => db.SelectAuthorByIdAsync(invalidId), Times.Once); 33 | appDbContextMock.VerifyNoOtherCalls(); 34 | } 35 | 36 | [Fact] 37 | public async Task AddAuthorAsync_ShouldThrowExceptionForInvalidDataAnnotationRequirement() 38 | { 39 | // given (arrange) 40 | Filler authorFiller = new Filler(); 41 | 42 | CreateAuthorDto invalidAuthorToAddDto = authorFiller.Create(); 43 | 44 | invalidAuthorToAddDto.ContactEmail = "badaddress"; 45 | 46 | // when (act) 47 | var actualAuthorTask = subject.AddAuthorAsync(invalidAuthorToAddDto); 48 | 49 | // then (assert) 50 | await Assert.ThrowsAsync(() => actualAuthorTask); 51 | appDbContextMock.VerifyNoOtherCalls(); 52 | } 53 | 54 | [Fact] 55 | public async Task UpdateAuthorAsync_ShouldThrowExceptionForInvalidDataAnnotationRequirement() 56 | { 57 | // given (arrange) 58 | Filler authorFiller = new Filler(); 59 | 60 | UpdateAuthorDto invalidAuthorToUpdateDto = authorFiller.Create(); 61 | 62 | Author invalidAuthorToUpdate = this.mapper.Map(invalidAuthorToUpdateDto); 63 | 64 | // Object filler will create an invalid email address by default, so we'll use that // 65 | 66 | this.appDbContextMock.Setup(db => 67 | db.SelectAuthorByIdAsync(invalidAuthorToUpdateDto.Id)) 68 | .ReturnsAsync(invalidAuthorToUpdate); 69 | 70 | // when (act) 71 | var actualAuthorTask = subject.UpdateAuthorAsync(invalidAuthorToUpdateDto); 72 | 73 | // then (assert) 74 | await Assert.ThrowsAsync(() => actualAuthorTask); 75 | appDbContextMock.Verify(db => db.SelectAuthorByIdAsync(invalidAuthorToUpdateDto.Id), Times.Once); 76 | appDbContextMock.VerifyNoOtherCalls(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /CoreLMS.Application/Services/CourseService/CourseService.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.DataTransferObjects; 2 | using CoreLMS.Core.Entities; 3 | using CoreLMS.Core.Interfaces; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace CoreLMS.Application.Services 12 | { 13 | public partial class CourseService : ICourseService 14 | { 15 | private readonly IAppDbContext db; 16 | private readonly ILogger logger; 17 | 18 | public CourseService(IAppDbContext db, ILogger logger) 19 | { 20 | this.db = db; 21 | this.logger = logger; 22 | } 23 | 24 | public async Task AddCourseAsync(CreateCourseDto courseDto) 25 | { 26 | var course = new Course 27 | { 28 | Name = courseDto.Name, 29 | Description = courseDto.Description, 30 | CourseType = courseDto.CourseType, 31 | CourseImageURL = courseDto.CourseImageURL 32 | }; 33 | 34 | try 35 | { 36 | this.ValidateCourseOnCreate(course); 37 | } 38 | catch (Exception ex) 39 | { 40 | logger.LogError(ex, "Attempted to add invalid course."); 41 | throw; 42 | } 43 | 44 | return await this.db.CreateCourseAsync(course); 45 | } 46 | 47 | public async Task UpdateCourseAsync(UpdateCourseDto courseDto) 48 | { 49 | var course = await db.SelectCourseByIdAsync(courseDto.Id); 50 | 51 | course.Name = courseDto.Name; 52 | course.Description = courseDto.Description; 53 | course.CourseType = courseDto.CourseType; 54 | course.CourseImageURL = courseDto.CourseImageURL; 55 | 56 | try 57 | { 58 | this.ValidateCourseOnUpdate(course); 59 | } 60 | catch (Exception ex) 61 | { 62 | logger.LogError(ex, "Attempted to update invalid course."); 63 | throw; 64 | } 65 | 66 | return await db.UpdateCourseAsync(course); 67 | } 68 | 69 | public async Task DeleteCourseAsync(int id) 70 | { 71 | var course = await db.SelectCourseByIdAsync(id); 72 | 73 | if (course == null) 74 | { 75 | logger.LogWarning($"Course {id} not found for deletion."); 76 | throw new ApplicationException($"Course {id} not found for deletion."); 77 | } 78 | 79 | return await this.db.DeleteCourseAsync(course); 80 | } 81 | 82 | public async Task GetCourseAsync(int id) 83 | { 84 | var course = await this.db.SelectCourseByIdAsync(id); 85 | 86 | if (course == null) 87 | { 88 | logger.LogWarning($"Course {id} not found."); 89 | throw new ApplicationException($"Course {id} not found."); 90 | } 91 | 92 | return course; 93 | } 94 | 95 | public async Task> GetCoursesAsync() => await db.SelectCoursesAsync(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Create.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Authors.CreateModel 3 | 4 | @{ 5 | ViewData["Title"] = "Create"; 6 | } 7 | 8 |

Add an Author

9 |
10 |
11 |
12 |
13 |
14 | 15 |
16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 |
25 |
26 | 27 | 28 | 29 |
30 |
31 | 32 | 33 | 34 |
35 |
36 | 37 | 38 | 39 |
40 |
41 | 42 | 43 | 44 |
45 |
46 | 47 | 48 | 49 |
50 |
51 | 52 | 53 | 54 |
55 |
56 | 57 |
58 |
59 |
60 |
61 | 62 |
63 | Back to List 64 |
65 | 66 | @section Scripts { 67 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 68 | } 69 | -------------------------------------------------------------------------------- /CoreLMS.Web/Areas/Admin/Pages/Authors/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model CoreLMS.Web.Areas.Admin.Pages.Authors.EditModel 3 | 4 | @{ 5 | ViewData["Title"] = "Edit"; 6 | } 7 | 8 |

Edit

9 | 10 |

Author

11 |
12 |
13 |
14 |
15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 | 35 | 36 |
37 |
38 | 39 | 40 | 41 |
42 |
43 | 44 | 45 | 46 |
47 |
48 | 49 | 50 | 51 |
52 |
53 | 54 | 55 | 56 |
57 |
58 | 59 |
60 |
61 |
62 |
63 | 64 |
65 | Back to List 66 |
67 | 68 | @section Scripts { 69 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 70 | } 71 | -------------------------------------------------------------------------------- /CoreLMS.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30225.117 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreLMS.Core", "CoreLMS.Core\CoreLMS.Core.csproj", "{7C1CC6D3-C856-4B51-9686-0D3E242D4946}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreLMS.Infrastructure", "CoreLMS.Infrastructure\CoreLMS.Infrastructure.csproj", "{A3B6CC5C-FA65-40B2-983D-3D9DB5978DB4}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreLMS.Persistence", "CoreLMS.Persistence\CoreLMS.Persistence.csproj", "{2B5FE5DF-F1D8-485C-A97C-96A500A8C1C3}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreLMS.Tests", "CoreLMS.Tests\CoreLMS.Tests.csproj", "{7A7F6AE3-A805-4DD7-93DC-691AF345B88E}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreLMS.Application", "CoreLMS.Application\CoreLMS.Application.csproj", "{1A4C0230-3A9F-4CCE-BD2C-7E75CF6770DF}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreLMS.Web", "CoreLMS.Web\CoreLMS.Web.csproj", "{C80DA6B8-3825-45FE-B4D7-874531B4B26D}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {7C1CC6D3-C856-4B51-9686-0D3E242D4946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {7C1CC6D3-C856-4B51-9686-0D3E242D4946}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {7C1CC6D3-C856-4B51-9686-0D3E242D4946}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {7C1CC6D3-C856-4B51-9686-0D3E242D4946}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {A3B6CC5C-FA65-40B2-983D-3D9DB5978DB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {A3B6CC5C-FA65-40B2-983D-3D9DB5978DB4}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {A3B6CC5C-FA65-40B2-983D-3D9DB5978DB4}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {A3B6CC5C-FA65-40B2-983D-3D9DB5978DB4}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {2B5FE5DF-F1D8-485C-A97C-96A500A8C1C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {2B5FE5DF-F1D8-485C-A97C-96A500A8C1C3}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {2B5FE5DF-F1D8-485C-A97C-96A500A8C1C3}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {2B5FE5DF-F1D8-485C-A97C-96A500A8C1C3}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {7A7F6AE3-A805-4DD7-93DC-691AF345B88E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {7A7F6AE3-A805-4DD7-93DC-691AF345B88E}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {7A7F6AE3-A805-4DD7-93DC-691AF345B88E}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {7A7F6AE3-A805-4DD7-93DC-691AF345B88E}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {1A4C0230-3A9F-4CCE-BD2C-7E75CF6770DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {1A4C0230-3A9F-4CCE-BD2C-7E75CF6770DF}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {1A4C0230-3A9F-4CCE-BD2C-7E75CF6770DF}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {1A4C0230-3A9F-4CCE-BD2C-7E75CF6770DF}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {C80DA6B8-3825-45FE-B4D7-874531B4B26D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {C80DA6B8-3825-45FE-B4D7-874531B4B26D}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {C80DA6B8-3825-45FE-B4D7-874531B4B26D}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {C80DA6B8-3825-45FE-B4D7-874531B4B26D}.Release|Any CPU.Build.0 = Release|Any CPU 48 | EndGlobalSection 49 | GlobalSection(SolutionProperties) = preSolution 50 | HideSolutionNode = FALSE 51 | EndGlobalSection 52 | GlobalSection(ExtensibilityGlobals) = postSolution 53 | SolutionGuid = {ED365886-8235-4F0A-9C4E-E9456F6364DE} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.3.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2019 The Bootstrap Authors 4 | * Copyright 2011-2019 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /CoreLMS.Persistence/AppDbContext.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.Entities; 2 | using CoreLMS.Core.Interfaces; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.Extensions.Configuration; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading; 10 | using System.Threading.Tasks; 11 | 12 | namespace CoreLMS.Persistence 13 | { 14 | public partial class AppDbContext : DbContext, IAppDbContext 15 | { 16 | private readonly IConfiguration configuration; 17 | 18 | public DbSet AuthorCourseLessons { get; set; } 19 | 20 | public AppDbContext(IConfiguration configuration) 21 | { 22 | this.configuration = configuration; 23 | 24 | // TODO GET THIS OUTTA HERE // 25 | //this.Database.Migrate(); 26 | } 27 | 28 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 29 | { 30 | optionsBuilder.UseSqlServer(configuration.GetConnectionString("DefaultConnection")); 31 | } 32 | 33 | protected override void OnModelCreating(ModelBuilder modelBuilder) 34 | { 35 | // TODO Define indexes 36 | 37 | #region Many to Manys 38 | modelBuilder.Entity() 39 | .HasKey(p => new { p.AuthorId, p.CourseLessonId }); 40 | 41 | modelBuilder.Entity() 42 | .HasOne(p => p.Author) 43 | .WithMany(p => p.CourseLessons) 44 | .HasForeignKey(p => p.AuthorId); 45 | 46 | modelBuilder.Entity() 47 | .HasOne(p => p.CourseLesson) 48 | .WithMany(p => p.Authors) 49 | .HasForeignKey(p => p.CourseLessonId); 50 | #endregion 51 | 52 | #region Soft Deletes 53 | // TODO Investigate using IAuditableEntity 54 | modelBuilder.Entity().HasQueryFilter(e => e.DateDeleted == null); 55 | modelBuilder.Entity().HasQueryFilter(e => e.DateDeleted == null); 56 | modelBuilder.Entity().HasQueryFilter(e => e.DateDeleted == null); 57 | modelBuilder.Entity().HasQueryFilter(e => e.DateDeleted == null); 58 | #endregion 59 | } 60 | 61 | public override int SaveChanges() 62 | { 63 | HandleIAuditableEntities(); 64 | 65 | return base.SaveChanges(); 66 | } 67 | 68 | public override async Task SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken()) 69 | { 70 | HandleIAuditableEntities(); 71 | 72 | return await base.SaveChangesAsync(cancellationToken); 73 | } 74 | 75 | private void HandleIAuditableEntities() 76 | { 77 | var entities = ChangeTracker.Entries().Where(x => (x.State == EntityState.Added || x.State == EntityState.Modified || x.State == EntityState.Deleted)); 78 | 79 | foreach (var entity in entities) 80 | { 81 | if (typeof(IAuditableEntity).IsAssignableFrom(entity.Entity.GetType())) 82 | { 83 | var dateModified = DateTime.UtcNow; 84 | 85 | if (entity.State == EntityState.Added) 86 | { 87 | entity.CurrentValues["DateCreated"] = dateModified; 88 | } 89 | 90 | if (entity.State == EntityState.Deleted) 91 | { 92 | entity.State = EntityState.Modified; 93 | entity.CurrentValues["DateDeleted"] = dateModified; 94 | } 95 | 96 | entity.CurrentValues["DateUpdated"] = dateModified; 97 | } 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /CoreLMS.Application/Services/AuthorService/AuthorService.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.DataTransferObjects; 2 | using CoreLMS.Core.Entities; 3 | using CoreLMS.Core.Interfaces; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.ComponentModel.DataAnnotations; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace CoreLMS.Application.Services 13 | { 14 | public partial class AuthorService : IAuthorService 15 | { 16 | private readonly IAppDbContext db; 17 | private readonly ILogger logger; 18 | 19 | public AuthorService(IAppDbContext db, ILogger logger) 20 | { 21 | this.db = db; 22 | this.logger = logger; 23 | } 24 | 25 | public async Task AddAuthorAsync(CreateAuthorDto authorDto) 26 | { 27 | var author = new Author 28 | { 29 | FirstName = authorDto.FirstName, 30 | MiddleName = authorDto.MiddleName, 31 | LastName = authorDto.LastName, 32 | Suffix = authorDto.Suffix, 33 | ContactEmail = authorDto.ContactEmail, 34 | ContactPhoneNumber = authorDto.ContactPhoneNumber, 35 | Description = authorDto.Description, 36 | WebsiteURL = authorDto.WebsiteURL 37 | }; 38 | 39 | try 40 | { 41 | this.ValidateAuthorOnCreate(author); 42 | } 43 | catch (Exception ex) 44 | { 45 | logger.LogError(ex, "Attempted to add invalid author."); 46 | throw; 47 | } 48 | 49 | return await this.db.CreateAuthorAsync(author); 50 | } 51 | 52 | public async Task DeleteAuthorAsync(int id) 53 | { 54 | var author = await db.SelectAuthorByIdAsync(id); 55 | 56 | // TODO Add test case for invalid course/author/etc. on deletion attempt // 57 | if (author == null) 58 | { 59 | logger.LogWarning($"Author {id} not found for deletion."); 60 | throw new ApplicationException($"Author {id} not found for deletion."); 61 | } 62 | 63 | return await this.db.DeleteAuthorAsync(author); 64 | } 65 | 66 | public async Task GetAuthorAsync(int id) 67 | { 68 | var author = await db.SelectAuthorByIdAsync(id); 69 | 70 | // TODO Test logging / exception logging for efficiency // 71 | if (author == null) 72 | { 73 | logger.LogWarning($"Course {id} not found."); 74 | throw new ApplicationException($"Course {id} not found."); 75 | } 76 | 77 | return author; 78 | } 79 | 80 | public async Task> GetAuthorsAsync() => await this.db.SelectAuthorsAsync(); 81 | 82 | public async Task UpdateAuthorAsync(UpdateAuthorDto authorDto) 83 | { 84 | var author = await this.db.SelectAuthorByIdAsync(authorDto.Id); 85 | 86 | author.FirstName = authorDto.FirstName; 87 | author.MiddleName = authorDto.MiddleName; 88 | author.LastName = authorDto.LastName; 89 | author.Suffix = authorDto.Suffix; 90 | author.ContactEmail = authorDto.ContactEmail; 91 | author.ContactPhoneNumber = authorDto.ContactPhoneNumber; 92 | author.Description = authorDto.Description; 93 | author.WebsiteURL = authorDto.WebsiteURL; 94 | 95 | try 96 | { 97 | this.ValidateAuthorOnUpdate(author); 98 | } 99 | catch (Exception ex) 100 | { 101 | logger.LogError(ex, "Attempted to add invalid author."); 102 | throw; 103 | } 104 | 105 | return await db.UpdateAuthorAsync(author); 106 | } 107 | 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /CoreLMS.Tests/Services/Courses/CourseServiceTests.Exceptions.cs: -------------------------------------------------------------------------------- 1 | using CoreLMS.Core.DataTransferObjects; 2 | using CoreLMS.Core.Entities; 3 | using Moq; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.ComponentModel.DataAnnotations; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using Tynamix.ObjectFiller; 10 | using Xunit; 11 | 12 | namespace CoreLMS.Tests.Services.Courses 13 | { 14 | public partial class CourseServiceTests 15 | { 16 | [Fact] 17 | public async Task GetCourseAsync_ShouldThrowApplicationExceptionWhenIdIsNotFound() 18 | { 19 | // given (arrange) 20 | int invalidId = 100; 21 | Course invalidCourse = null; 22 | 23 | this.appDbContextMock.Setup(db => 24 | db.SelectCourseByIdAsync(invalidId)) 25 | .ReturnsAsync(invalidCourse); 26 | 27 | // when (act) 28 | var subjectTask = subject.GetCourseAsync(invalidId); 29 | 30 | // then (assert) 31 | await Assert.ThrowsAsync(() => subjectTask); 32 | appDbContextMock.Verify(db => db.SelectCourseByIdAsync(invalidId), Times.Once); 33 | appDbContextMock.VerifyNoOtherCalls(); 34 | } 35 | 36 | [Fact] 37 | public async Task AddCourseAsync_ShouldThrowExceptionForInvalidDataAnnotationRequirement() 38 | { 39 | // given (arrange) 40 | Filler courseFiller = new Filler(); 41 | 42 | CreateCourseDto invalidCourseToAddDto = courseFiller.Create(); 43 | 44 | invalidCourseToAddDto.Name = null; 45 | 46 | // when (act) 47 | var actualCourseTask = subject.AddCourseAsync(invalidCourseToAddDto); 48 | 49 | // then (assert) 50 | await Assert.ThrowsAsync(() => actualCourseTask); 51 | appDbContextMock.VerifyNoOtherCalls(); 52 | } 53 | 54 | [Fact] 55 | public async Task UpdateCourseAsync_ShouldThrowExceptionForInvalidDataAnnotationRequirement() 56 | { 57 | // given (arrange) 58 | Filler courseFiller = new Filler(); 59 | 60 | UpdateCourseDto invalidCourseToUpdateDto = courseFiller.Create(); 61 | 62 | Course invalidCourseToUpdate = this.mapper.Map(invalidCourseToUpdateDto); 63 | 64 | invalidCourseToUpdateDto.Name = null; 65 | 66 | this.appDbContextMock.Setup(db => 67 | db.SelectCourseByIdAsync(invalidCourseToUpdateDto.Id)) 68 | .ReturnsAsync(invalidCourseToUpdate); 69 | 70 | // when (act) 71 | var actualCourseTask = subject.UpdateCourseAsync(invalidCourseToUpdateDto); 72 | 73 | // then (assert) 74 | await Assert.ThrowsAsync(() => actualCourseTask); 75 | appDbContextMock.Verify(db => db.SelectCourseByIdAsync(invalidCourseToUpdateDto.Id), Times.Once); 76 | appDbContextMock.VerifyNoOtherCalls(); 77 | } 78 | 79 | /* 80 | [Fact] 81 | public async Task AddCourseAsync_ShouldThrowExceptionForInvalidBusinessLogicRequirement() 82 | { 83 | // given (arrange) 84 | Filler courseFiller = new Filler(); 85 | 86 | courseFiller.Setup() 87 | .OnProperty(p => p.Id).IgnoreIt(); 88 | 89 | Course invalidCourseToAdd = courseFiller.Create(); 90 | 91 | invalidCourseToAdd.CourseLessons = new List(); 92 | 93 | Course databaseCourse = this.mapper.Map(invalidCourseToAdd); 94 | 95 | this.appDbContextMock.Setup(db => 96 | db.CreateCourseAsync(invalidCourseToAdd)) 97 | .ReturnsAsync(databaseCourse); 98 | 99 | // when (act) 100 | var actualCourseTask = subject.AddCourseAsync(invalidCourseToAdd); 101 | 102 | // then (assert) 103 | await Assert.ThrowsAsync(() => actualCourseTask); 104 | appDbContextMock.VerifyNoOtherCalls(); 105 | } 106 | 107 | [Fact] 108 | public async Task AddCourseAsync_ShouldThrowExceptionForInvalidBusinessLogicRequirementNullList() 109 | { 110 | // given (arrange) 111 | Filler courseFiller = new Filler(); 112 | 113 | courseFiller.Setup() 114 | .OnProperty(p => p.Id).IgnoreIt(); 115 | 116 | Course invalidCourseToAdd = courseFiller.Create(); 117 | 118 | invalidCourseToAdd.CourseLessons = null; 119 | 120 | Course databaseCourse = this.mapper.Map(invalidCourseToAdd); 121 | 122 | databaseCourse.Id = 1; 123 | 124 | this.appDbContextMock.Setup(db => 125 | db.CreateCourseAsync(invalidCourseToAdd)) 126 | .ReturnsAsync(databaseCourse); 127 | 128 | // when (act) 129 | var actualCourseTask = subject.AddCourseAsync(invalidCourseToAdd); 130 | 131 | // then (assert) 132 | await Assert.ThrowsAsync(() => actualCourseTask); 133 | appDbContextMock.VerifyNoOtherCalls(); 134 | } 135 | */ 136 | 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/Migrations/20201104181704_AuthorPersonUpdate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace CoreLMS.Persistence.Migrations 5 | { 6 | public partial class AuthorPersonUpdate : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.DropForeignKey( 11 | name: "FK_Authors_People_PersonID", 12 | table: "Authors"); 13 | 14 | migrationBuilder.DropTable( 15 | name: "People"); 16 | 17 | migrationBuilder.DropIndex( 18 | name: "IX_Authors_PersonID", 19 | table: "Authors"); 20 | 21 | migrationBuilder.DropColumn( 22 | name: "PersonID", 23 | table: "Authors"); 24 | 25 | migrationBuilder.AlterColumn( 26 | name: "Name", 27 | table: "Courses", 28 | nullable: false, 29 | oldClrType: typeof(string), 30 | oldType: "nvarchar(max)", 31 | oldNullable: true); 32 | 33 | migrationBuilder.AddColumn( 34 | name: "ContactEmail", 35 | table: "Authors", 36 | nullable: false, 37 | defaultValue: ""); 38 | 39 | migrationBuilder.AddColumn( 40 | name: "ContactPhoneNumber", 41 | table: "Authors", 42 | nullable: true); 43 | 44 | migrationBuilder.AddColumn( 45 | name: "FirstName", 46 | table: "Authors", 47 | nullable: false, 48 | defaultValue: ""); 49 | 50 | migrationBuilder.AddColumn( 51 | name: "LastName", 52 | table: "Authors", 53 | nullable: false, 54 | defaultValue: ""); 55 | 56 | migrationBuilder.AddColumn( 57 | name: "MiddleName", 58 | table: "Authors", 59 | nullable: true); 60 | 61 | migrationBuilder.AddColumn( 62 | name: "Suffix", 63 | table: "Authors", 64 | nullable: true); 65 | } 66 | 67 | protected override void Down(MigrationBuilder migrationBuilder) 68 | { 69 | migrationBuilder.DropColumn( 70 | name: "ContactEmail", 71 | table: "Authors"); 72 | 73 | migrationBuilder.DropColumn( 74 | name: "ContactPhoneNumber", 75 | table: "Authors"); 76 | 77 | migrationBuilder.DropColumn( 78 | name: "FirstName", 79 | table: "Authors"); 80 | 81 | migrationBuilder.DropColumn( 82 | name: "LastName", 83 | table: "Authors"); 84 | 85 | migrationBuilder.DropColumn( 86 | name: "MiddleName", 87 | table: "Authors"); 88 | 89 | migrationBuilder.DropColumn( 90 | name: "Suffix", 91 | table: "Authors"); 92 | 93 | migrationBuilder.AlterColumn( 94 | name: "Name", 95 | table: "Courses", 96 | type: "nvarchar(max)", 97 | nullable: true, 98 | oldClrType: typeof(string)); 99 | 100 | migrationBuilder.AddColumn( 101 | name: "PersonID", 102 | table: "Authors", 103 | type: "int", 104 | nullable: false, 105 | defaultValue: 0); 106 | 107 | migrationBuilder.CreateTable( 108 | name: "People", 109 | columns: table => new 110 | { 111 | Id = table.Column(type: "int", nullable: false) 112 | .Annotation("SqlServer:Identity", "1, 1"), 113 | DateCreated = table.Column(type: "datetime2", nullable: false), 114 | DateDeleted = table.Column(type: "datetime2", nullable: true), 115 | DateUpdated = table.Column(type: "datetime2", nullable: false), 116 | Email = table.Column(type: "nvarchar(max)", nullable: true), 117 | FirstName = table.Column(type: "nvarchar(max)", nullable: true), 118 | LastName = table.Column(type: "nvarchar(max)", nullable: true), 119 | MiddleName = table.Column(type: "nvarchar(max)", nullable: true), 120 | PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true), 121 | Suffix = table.Column(type: "nvarchar(max)", nullable: true) 122 | }, 123 | constraints: table => 124 | { 125 | table.PrimaryKey("PK_People", x => x.Id); 126 | }); 127 | 128 | migrationBuilder.CreateIndex( 129 | name: "IX_Authors_PersonID", 130 | table: "Authors", 131 | column: "PersonID"); 132 | 133 | migrationBuilder.AddForeignKey( 134 | name: "FK_Authors_People_PersonID", 135 | table: "Authors", 136 | column: "PersonID", 137 | principalTable: "People", 138 | principalColumn: "Id", 139 | onDelete: ReferentialAction.Cascade); 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | // Unobtrusive validation support library for jQuery and jQuery Validate 2 | // Copyright (c) .NET Foundation. All rights reserved. 3 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 4 | // @version v3.2.11 5 | !function(a){"function"==typeof define&&define.amd?define("jquery.validate.unobtrusive",["jquery-validation"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery-validation")):jQuery.validator.unobtrusive=a(jQuery)}(function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastIndexOf(".")+1)}function i(a,e){return 0===a.indexOf("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parseJSON(i)!==!1:null;r.removeClass("field-validation-valid").addClass("field-validation-error"),e.data("unobtrusiveContainer",r),o?(r.empty(),e.removeClass("input-validation-error").appendTo(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");r&&r.length&&n.errorList.length&&(r.empty(),t.addClass("validation-summary-errors").removeClass("validation-summary-valid"),a.each(n.errorList,function(){a("
  • ").html(this.message).appendTo(r)}))}function s(e){var n=e.data("unobtrusiveContainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parseJSON(t):null;n.addClass("field-validation-valid").removeClass("field-validation-error"),e.removeData("unobtrusiveContainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetForm()}finally{n.removeData(t)}n.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),n.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function u(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=f.unobtrusive.options||{},u=function(n,t){var r=i[n];r&&a.isFunction(r)&&r.apply(e,t)};return t||(t={options:{errorClass:i.errorClass||"input-validation-error",errorElement:i.errorElement||"span",errorPlacement:function(){o.apply(e,arguments),u("errorPlacement",arguments)},invalidHandler:function(){d.apply(e,arguments),u("invalidHandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),u("success",arguments)}},attachValidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)},validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var m,f=a.validator,v="unobtrusiveValidation";return f.unobtrusive={adapters:[],parseElement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=u(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachValidation())},parse:function(e){var n=a(e),t=n.parents().addBack().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){f.unobtrusive.parseElement(this,!0)}),t.each(function(){var a=u(this);a&&a.attachValidation()})}},m=f.unobtrusive.adapters,m.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},m.addBool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},m.addMinMax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},m.addSingleVal=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},f.addMethod("__dummy__",function(a,e,n){return!0}),f.addMethod("regex",function(a,e,n){var t;return!!this.optional(e)||(t=new RegExp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),f.addMethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\W/g),t=t&&t.length>=n),t}),f.methods.extension?(m.addSingleVal("accept","mimtype"),m.addSingleVal("extension","extension")):m.addSingleVal("extension","extension","accept"),m.addSingleVal("regex","pattern"),m.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),m.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),m.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),m.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalTo",l)}),m.add("required",function(a){"INPUT"===a.element.tagName.toUpperCase()&&"CHECKBOX"===a.element.type.toUpperCase()||e(a,"required",!0)}),m.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"GET",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),m.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),m.add("fileextensions",["extensions"],function(a){e(a,"extension",a.params.extensions)}),a(function(){f.unobtrusive.parse(document)}),f.unobtrusive}); -------------------------------------------------------------------------------- /CoreLMS.Web/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.3.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2019 The Bootstrap Authors 4 | * Copyright 2011-2019 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */ 8 | *, 9 | *::before, 10 | *::after { 11 | box-sizing: border-box; 12 | } 13 | 14 | html { 15 | font-family: sans-serif; 16 | line-height: 1.15; 17 | -webkit-text-size-adjust: 100%; 18 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 19 | } 20 | 21 | article, aside, figcaption, figure, footer, header, hgroup, main, nav, section { 22 | display: block; 23 | } 24 | 25 | body { 26 | margin: 0; 27 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; 28 | font-size: 1rem; 29 | font-weight: 400; 30 | line-height: 1.5; 31 | color: #212529; 32 | text-align: left; 33 | background-color: #fff; 34 | } 35 | 36 | [tabindex="-1"]:focus { 37 | outline: 0 !important; 38 | } 39 | 40 | hr { 41 | box-sizing: content-box; 42 | height: 0; 43 | overflow: visible; 44 | } 45 | 46 | h1, h2, h3, h4, h5, h6 { 47 | margin-top: 0; 48 | margin-bottom: 0.5rem; 49 | } 50 | 51 | p { 52 | margin-top: 0; 53 | margin-bottom: 1rem; 54 | } 55 | 56 | abbr[title], 57 | abbr[data-original-title] { 58 | text-decoration: underline; 59 | -webkit-text-decoration: underline dotted; 60 | text-decoration: underline dotted; 61 | cursor: help; 62 | border-bottom: 0; 63 | -webkit-text-decoration-skip-ink: none; 64 | text-decoration-skip-ink: none; 65 | } 66 | 67 | address { 68 | margin-bottom: 1rem; 69 | font-style: normal; 70 | line-height: inherit; 71 | } 72 | 73 | ol, 74 | ul, 75 | dl { 76 | margin-top: 0; 77 | margin-bottom: 1rem; 78 | } 79 | 80 | ol ol, 81 | ul ul, 82 | ol ul, 83 | ul ol { 84 | margin-bottom: 0; 85 | } 86 | 87 | dt { 88 | font-weight: 700; 89 | } 90 | 91 | dd { 92 | margin-bottom: .5rem; 93 | margin-left: 0; 94 | } 95 | 96 | blockquote { 97 | margin: 0 0 1rem; 98 | } 99 | 100 | b, 101 | strong { 102 | font-weight: bolder; 103 | } 104 | 105 | small { 106 | font-size: 80%; 107 | } 108 | 109 | sub, 110 | sup { 111 | position: relative; 112 | font-size: 75%; 113 | line-height: 0; 114 | vertical-align: baseline; 115 | } 116 | 117 | sub { 118 | bottom: -.25em; 119 | } 120 | 121 | sup { 122 | top: -.5em; 123 | } 124 | 125 | a { 126 | color: #007bff; 127 | text-decoration: none; 128 | background-color: transparent; 129 | } 130 | 131 | a:hover { 132 | color: #0056b3; 133 | text-decoration: underline; 134 | } 135 | 136 | a:not([href]):not([tabindex]) { 137 | color: inherit; 138 | text-decoration: none; 139 | } 140 | 141 | a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus { 142 | color: inherit; 143 | text-decoration: none; 144 | } 145 | 146 | a:not([href]):not([tabindex]):focus { 147 | outline: 0; 148 | } 149 | 150 | pre, 151 | code, 152 | kbd, 153 | samp { 154 | font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; 155 | font-size: 1em; 156 | } 157 | 158 | pre { 159 | margin-top: 0; 160 | margin-bottom: 1rem; 161 | overflow: auto; 162 | } 163 | 164 | figure { 165 | margin: 0 0 1rem; 166 | } 167 | 168 | img { 169 | vertical-align: middle; 170 | border-style: none; 171 | } 172 | 173 | svg { 174 | overflow: hidden; 175 | vertical-align: middle; 176 | } 177 | 178 | table { 179 | border-collapse: collapse; 180 | } 181 | 182 | caption { 183 | padding-top: 0.75rem; 184 | padding-bottom: 0.75rem; 185 | color: #6c757d; 186 | text-align: left; 187 | caption-side: bottom; 188 | } 189 | 190 | th { 191 | text-align: inherit; 192 | } 193 | 194 | label { 195 | display: inline-block; 196 | margin-bottom: 0.5rem; 197 | } 198 | 199 | button { 200 | border-radius: 0; 201 | } 202 | 203 | button:focus { 204 | outline: 1px dotted; 205 | outline: 5px auto -webkit-focus-ring-color; 206 | } 207 | 208 | input, 209 | button, 210 | select, 211 | optgroup, 212 | textarea { 213 | margin: 0; 214 | font-family: inherit; 215 | font-size: inherit; 216 | line-height: inherit; 217 | } 218 | 219 | button, 220 | input { 221 | overflow: visible; 222 | } 223 | 224 | button, 225 | select { 226 | text-transform: none; 227 | } 228 | 229 | select { 230 | word-wrap: normal; 231 | } 232 | 233 | button, 234 | [type="button"], 235 | [type="reset"], 236 | [type="submit"] { 237 | -webkit-appearance: button; 238 | } 239 | 240 | button:not(:disabled), 241 | [type="button"]:not(:disabled), 242 | [type="reset"]:not(:disabled), 243 | [type="submit"]:not(:disabled) { 244 | cursor: pointer; 245 | } 246 | 247 | button::-moz-focus-inner, 248 | [type="button"]::-moz-focus-inner, 249 | [type="reset"]::-moz-focus-inner, 250 | [type="submit"]::-moz-focus-inner { 251 | padding: 0; 252 | border-style: none; 253 | } 254 | 255 | input[type="radio"], 256 | input[type="checkbox"] { 257 | box-sizing: border-box; 258 | padding: 0; 259 | } 260 | 261 | input[type="date"], 262 | input[type="time"], 263 | input[type="datetime-local"], 264 | input[type="month"] { 265 | -webkit-appearance: listbox; 266 | } 267 | 268 | textarea { 269 | overflow: auto; 270 | resize: vertical; 271 | } 272 | 273 | fieldset { 274 | min-width: 0; 275 | padding: 0; 276 | margin: 0; 277 | border: 0; 278 | } 279 | 280 | legend { 281 | display: block; 282 | width: 100%; 283 | max-width: 100%; 284 | padding: 0; 285 | margin-bottom: .5rem; 286 | font-size: 1.5rem; 287 | line-height: inherit; 288 | color: inherit; 289 | white-space: normal; 290 | } 291 | 292 | progress { 293 | vertical-align: baseline; 294 | } 295 | 296 | [type="number"]::-webkit-inner-spin-button, 297 | [type="number"]::-webkit-outer-spin-button { 298 | height: auto; 299 | } 300 | 301 | [type="search"] { 302 | outline-offset: -2px; 303 | -webkit-appearance: none; 304 | } 305 | 306 | [type="search"]::-webkit-search-decoration { 307 | -webkit-appearance: none; 308 | } 309 | 310 | ::-webkit-file-upload-button { 311 | font: inherit; 312 | -webkit-appearance: button; 313 | } 314 | 315 | output { 316 | display: inline-block; 317 | } 318 | 319 | summary { 320 | display: list-item; 321 | cursor: pointer; 322 | } 323 | 324 | template { 325 | display: none; 326 | } 327 | 328 | [hidden] { 329 | display: none !important; 330 | } 331 | /*# sourceMappingURL=bootstrap-reboot.css.map */ -------------------------------------------------------------------------------- /CoreLMS.Persistence/Migrations/20200805182225_CourseLessonsAndAuthors.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace CoreLMS.Persistence.Migrations 5 | { 6 | public partial class CourseLessonsAndAuthors : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.DropColumn( 11 | name: "IsDeleted", 12 | table: "Courses"); 13 | 14 | migrationBuilder.CreateTable( 15 | name: "CourseLessons", 16 | columns: table => new 17 | { 18 | Id = table.Column(nullable: false) 19 | .Annotation("SqlServer:Identity", "1, 1"), 20 | DateCreated = table.Column(nullable: false), 21 | DateUpdated = table.Column(nullable: false), 22 | DateDeleted = table.Column(nullable: true), 23 | CourseId = table.Column(nullable: false), 24 | Name = table.Column(nullable: true), 25 | Description = table.Column(nullable: true), 26 | LessonType = table.Column(nullable: false), 27 | VideoSourceType = table.Column(nullable: false), 28 | VideoSourceCode = table.Column(nullable: true) 29 | }, 30 | constraints: table => 31 | { 32 | table.PrimaryKey("PK_CourseLessons", x => x.Id); 33 | table.ForeignKey( 34 | name: "FK_CourseLessons_Courses_CourseId", 35 | column: x => x.CourseId, 36 | principalTable: "Courses", 37 | principalColumn: "Id", 38 | onDelete: ReferentialAction.Cascade); 39 | }); 40 | 41 | migrationBuilder.CreateTable( 42 | name: "People", 43 | columns: table => new 44 | { 45 | Id = table.Column(nullable: false) 46 | .Annotation("SqlServer:Identity", "1, 1"), 47 | DateCreated = table.Column(nullable: false), 48 | DateUpdated = table.Column(nullable: false), 49 | DateDeleted = table.Column(nullable: true), 50 | FirstName = table.Column(nullable: true), 51 | MiddleName = table.Column(nullable: true), 52 | LastName = table.Column(nullable: true), 53 | Suffix = table.Column(nullable: true), 54 | Email = table.Column(nullable: true), 55 | PhoneNumber = table.Column(nullable: true) 56 | }, 57 | constraints: table => 58 | { 59 | table.PrimaryKey("PK_People", x => x.Id); 60 | }); 61 | 62 | migrationBuilder.CreateTable( 63 | name: "CourseLessonAttachments", 64 | columns: table => new 65 | { 66 | Id = table.Column(nullable: false) 67 | .Annotation("SqlServer:Identity", "1, 1"), 68 | DateCreated = table.Column(nullable: false), 69 | DateUpdated = table.Column(nullable: false), 70 | DateDeleted = table.Column(nullable: true), 71 | CourseLessonId = table.Column(nullable: false), 72 | Name = table.Column(nullable: true), 73 | Description = table.Column(nullable: true) 74 | }, 75 | constraints: table => 76 | { 77 | table.PrimaryKey("PK_CourseLessonAttachments", x => x.Id); 78 | table.ForeignKey( 79 | name: "FK_CourseLessonAttachments_CourseLessons_CourseLessonId", 80 | column: x => x.CourseLessonId, 81 | principalTable: "CourseLessons", 82 | principalColumn: "Id", 83 | onDelete: ReferentialAction.Cascade); 84 | }); 85 | 86 | migrationBuilder.CreateTable( 87 | name: "Authors", 88 | columns: table => new 89 | { 90 | Id = table.Column(nullable: false) 91 | .Annotation("SqlServer:Identity", "1, 1"), 92 | DateCreated = table.Column(nullable: false), 93 | DateUpdated = table.Column(nullable: false), 94 | DateDeleted = table.Column(nullable: true), 95 | PersonID = table.Column(nullable: false), 96 | Description = table.Column(nullable: true), 97 | WebsiteURL = table.Column(nullable: true) 98 | }, 99 | constraints: table => 100 | { 101 | table.PrimaryKey("PK_Authors", x => x.Id); 102 | table.ForeignKey( 103 | name: "FK_Authors_People_PersonID", 104 | column: x => x.PersonID, 105 | principalTable: "People", 106 | principalColumn: "Id", 107 | onDelete: ReferentialAction.Cascade); 108 | }); 109 | 110 | migrationBuilder.CreateIndex( 111 | name: "IX_Authors_PersonID", 112 | table: "Authors", 113 | column: "PersonID"); 114 | 115 | migrationBuilder.CreateIndex( 116 | name: "IX_CourseLessonAttachments_CourseLessonId", 117 | table: "CourseLessonAttachments", 118 | column: "CourseLessonId"); 119 | 120 | migrationBuilder.CreateIndex( 121 | name: "IX_CourseLessons_CourseId", 122 | table: "CourseLessons", 123 | column: "CourseId"); 124 | } 125 | 126 | protected override void Down(MigrationBuilder migrationBuilder) 127 | { 128 | migrationBuilder.DropTable( 129 | name: "Authors"); 130 | 131 | migrationBuilder.DropTable( 132 | name: "CourseLessonAttachments"); 133 | 134 | migrationBuilder.DropTable( 135 | name: "People"); 136 | 137 | migrationBuilder.DropTable( 138 | name: "CourseLessons"); 139 | 140 | migrationBuilder.AddColumn( 141 | name: "IsDeleted", 142 | table: "Courses", 143 | type: "bit", 144 | nullable: false, 145 | defaultValue: false); 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /.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 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /CoreLMS.Tests/Services/Courses/CourseServiceTests.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using CoreLMS.Application.Services; 3 | using CoreLMS.Core.DataTransferObjects; 4 | using CoreLMS.Core.Entities; 5 | using CoreLMS.Core.Interfaces; 6 | using FluentAssertions; 7 | using FluentAssertions.Common; 8 | using Microsoft.Extensions.Logging; 9 | using Moq; 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Globalization; 13 | using System.Linq; 14 | using System.Text; 15 | using System.Threading.Tasks; 16 | using Tynamix.ObjectFiller; 17 | using Xunit; 18 | 19 | namespace CoreLMS.Tests.Services.Courses 20 | { 21 | public partial class CourseServiceTests 22 | { 23 | private readonly Mock appDbContextMock; 24 | private readonly Mock> loggerMock; 25 | private readonly ICourseService subject; 26 | private readonly Mapper mapper; 27 | 28 | public CourseServiceTests() 29 | { 30 | this.appDbContextMock = new Mock(); 31 | 32 | this.loggerMock = new Mock>(); 33 | 34 | this.mapper = new Mapper(new MapperConfiguration(cfg => { 35 | cfg.CreateMap(); 36 | cfg.CreateMap(); 37 | cfg.CreateMap(); 38 | cfg.CreateMap(); 39 | cfg.CreateMap(); 40 | })); 41 | 42 | this.subject = new CourseService(this.appDbContextMock.Object, this.loggerMock.Object); 43 | } 44 | 45 | [Fact] 46 | public async Task GetCoursesAsync_ShouldReturnExpectedCourseList() 47 | { 48 | // given (arrange) 49 | // TODO Limit number of generated sub types 50 | Filler> courseListFiller = new Filler>(); 51 | 52 | List databaseCourses = courseListFiller.Create(); 53 | 54 | // Important note: do NOT have the mock dbcontext just return databaseCourses (rather create a new List from the old list in the return) 55 | // Otherwise we'll get a potentially "false positive" equality check since we'll just be passing around the same list by reference 56 | this.appDbContextMock.Setup(db => 57 | db.SelectCoursesAsync()) 58 | .ReturnsAsync(new List(databaseCourses)); 59 | 60 | // when (act) 61 | List actualCourses = await subject.GetCoursesAsync(); 62 | 63 | // then (assert) 64 | // 1. Actual list of courses == expected courses 65 | // 2. DB was hit once (and no more) 66 | actualCourses.Should().BeEquivalentTo(databaseCourses); 67 | appDbContextMock.Verify(db => db.SelectCoursesAsync(), Times.Once); 68 | appDbContextMock.VerifyNoOtherCalls(); 69 | } 70 | 71 | [Fact] 72 | public async Task GetCourseAsync_ShouldReturnExpectedCourse() 73 | { 74 | // given (arrange) 75 | Filler courseFiller = new Filler(); 76 | 77 | Course expectedCourse = courseFiller.Create(); 78 | 79 | Course databaseCourse = this.mapper.Map(expectedCourse); 80 | 81 | this.appDbContextMock.Setup(db => 82 | db.SelectCourseByIdAsync(databaseCourse.Id)) 83 | .ReturnsAsync(databaseCourse); 84 | 85 | // when (act) 86 | Course actualCourse = await subject.GetCourseAsync(databaseCourse.Id); 87 | 88 | // then (assert) 89 | // 1. Actual course == expected course 90 | // 2. DB was hit once 91 | // 3. Logger was NOT hit 92 | actualCourse.Should().BeEquivalentTo(expectedCourse); 93 | appDbContextMock.Verify(db => db.SelectCourseByIdAsync(databaseCourse.Id), Times.Once); 94 | appDbContextMock.VerifyNoOtherCalls(); 95 | } 96 | 97 | 98 | [Fact] 99 | public async Task AddCourseAsync_ShouldReturnExpectedCourseWithId() 100 | { 101 | // given (arrange) 102 | Filler courseFiller = new Filler(); 103 | 104 | CreateCourseDto courseDtoToAdd = courseFiller.Create(); 105 | 106 | Course courseToAdd = this.mapper.Map(courseDtoToAdd); 107 | 108 | Course databaseCourse = this.mapper.Map(courseToAdd); 109 | 110 | databaseCourse.Id = 1; 111 | databaseCourse.DateCreated = databaseCourse.DateUpdated = DateTime.UtcNow; 112 | 113 | this.appDbContextMock 114 | .Setup(db => db.CreateCourseAsync(It.IsAny())) 115 | .ReturnsAsync(databaseCourse); 116 | 117 | // when (act) 118 | var actualCourse = await subject.AddCourseAsync(courseDtoToAdd); 119 | 120 | // then (assert) 121 | actualCourse.Should().BeEquivalentTo(databaseCourse); 122 | appDbContextMock.Verify(db => db.CreateCourseAsync(It.IsAny()), Times.Once); 123 | appDbContextMock.VerifyNoOtherCalls(); 124 | } 125 | 126 | [Fact] 127 | public async Task UpdateCourseAsync_ShouldReturnExpectedCourse() 128 | { 129 | // given (arrange) 130 | DateTime updateTime = DateTime.UtcNow; 131 | DateTime createTime = updateTime.AddDays(-5); 132 | 133 | Filler courseFiller = new Filler(); 134 | 135 | UpdateCourseDto courseToUpdateDto = courseFiller.Create(); 136 | 137 | courseToUpdateDto.Id = 1; 138 | 139 | Course courseToUpdate = this.mapper.Map(courseToUpdateDto); 140 | 141 | courseToUpdate.DateCreated = courseToUpdate.DateUpdated = createTime; 142 | 143 | Course databaseCourse = this.mapper.Map(courseToUpdate); 144 | 145 | databaseCourse.DateUpdated = updateTime; 146 | 147 | this.appDbContextMock.Setup(db => 148 | db.SelectCourseByIdAsync(courseToUpdateDto.Id)) 149 | .ReturnsAsync(courseToUpdate); 150 | 151 | this.appDbContextMock.Setup(db => 152 | db.UpdateCourseAsync(It.IsAny())) 153 | .ReturnsAsync(databaseCourse); 154 | 155 | // when (act) 156 | Course actualCourse = await subject.UpdateCourseAsync(courseToUpdateDto); 157 | 158 | // then (assert) 159 | actualCourse.Should().BeEquivalentTo(databaseCourse); 160 | Assert.Equal(actualCourse.DateUpdated, updateTime); 161 | appDbContextMock.Verify(db => db.SelectCourseByIdAsync(actualCourse.Id), Times.Once); 162 | appDbContextMock.Verify(db => db.UpdateCourseAsync(It.IsAny()), Times.Once); 163 | appDbContextMock.VerifyNoOtherCalls(); 164 | } 165 | 166 | [Fact] 167 | public async Task DeleteCourseAsync_ShouldReturnExpectedCourse() 168 | { 169 | // given (arrange) 170 | Filler courseFiller = new Filler(); 171 | 172 | Course courseToDelete = courseFiller.Create(); 173 | 174 | Course databaseCourse = this.mapper.Map(courseToDelete); 175 | 176 | DateTime updateTime = DateTime.UtcNow; 177 | 178 | databaseCourse.DateUpdated = updateTime; 179 | 180 | databaseCourse.DateDeleted = updateTime; 181 | 182 | this.appDbContextMock.Setup(db => 183 | db.SelectCourseByIdAsync(courseToDelete.Id)) 184 | .ReturnsAsync(courseToDelete); 185 | 186 | this.appDbContextMock.Setup(db => 187 | db.DeleteCourseAsync(courseToDelete)) 188 | .ReturnsAsync(databaseCourse); 189 | 190 | // when (act) 191 | Course actualCourse = await subject.DeleteCourseAsync(courseToDelete.Id); 192 | 193 | // then (assert) 194 | actualCourse.Should().BeEquivalentTo(databaseCourse); 195 | Assert.Equal(actualCourse.DateUpdated, updateTime); 196 | Assert.Equal(actualCourse.DateDeleted.GetValueOrDefault(), updateTime); 197 | appDbContextMock.Verify(db => db.SelectCourseByIdAsync(actualCourse.Id), Times.Once); 198 | appDbContextMock.Verify(db => db.DeleteCourseAsync(courseToDelete), Times.Once); 199 | appDbContextMock.VerifyNoOtherCalls(); 200 | } 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /CoreLMS.Tests/Services/Authors/AuthorServiceTests.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using CoreLMS.Application.Services; 3 | using CoreLMS.Core.DataTransferObjects; 4 | using CoreLMS.Core.Entities; 5 | using CoreLMS.Core.Interfaces; 6 | using FluentAssertions; 7 | using FluentAssertions.Common; 8 | using Microsoft.Extensions.Logging; 9 | using Moq; 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Globalization; 13 | using System.Linq; 14 | using System.Text; 15 | using System.Threading.Tasks; 16 | using Tynamix.ObjectFiller; 17 | using Xunit; 18 | 19 | namespace CoreLMS.Tests.Services.Authors 20 | { 21 | public partial class AuthorServiceTests 22 | { 23 | private readonly Mock appDbContextMock; 24 | private readonly Mock> loggerMock; 25 | private readonly IAuthorService subject; 26 | private readonly Mapper mapper; 27 | 28 | public AuthorServiceTests() 29 | { 30 | this.appDbContextMock = new Mock(); 31 | 32 | this.loggerMock = new Mock>(); 33 | 34 | this.mapper = new Mapper(new MapperConfiguration(cfg => { 35 | cfg.CreateMap(); 36 | cfg.CreateMap(); 37 | cfg.CreateMap(); 38 | cfg.CreateMap(); 39 | cfg.CreateMap(); 40 | })); 41 | 42 | this.subject = new AuthorService(this.appDbContextMock.Object, this.loggerMock.Object); 43 | } 44 | 45 | [Fact] 46 | public async Task GetAuthorsAsync_ShouldReturnExpectedAuthorList() 47 | { 48 | // given (arrange) 49 | // TODO Limit number of generated sub types 50 | Filler> authorListFiller = new Filler>(); 51 | 52 | List databaseAuthors = authorListFiller.Create(); 53 | 54 | this.appDbContextMock.Setup(db => 55 | db.SelectAuthorsAsync()) 56 | .ReturnsAsync(new List(databaseAuthors)); 57 | 58 | // when (act) 59 | List actualAuthors = await subject.GetAuthorsAsync(); 60 | 61 | // then (assert) 62 | // 1. Actual list of courses == expected courses 63 | // 2. DB was hit once (and no more) 64 | actualAuthors.Should().BeEquivalentTo(databaseAuthors); 65 | appDbContextMock.Verify(db => db.SelectAuthorsAsync(), Times.Once); 66 | appDbContextMock.VerifyNoOtherCalls(); 67 | } 68 | 69 | [Fact] 70 | public async Task GetAuthorAsync_ShouldReturnExpectedAuthor() 71 | { 72 | // given (arrange) 73 | Filler authorFiller = new Filler(); 74 | 75 | Author expectedAuthor = authorFiller.Create(); 76 | 77 | Author databaseAuthor = this.mapper.Map(expectedAuthor); 78 | 79 | this.appDbContextMock.Setup(db => 80 | db.SelectAuthorByIdAsync(databaseAuthor.Id)) 81 | .ReturnsAsync(databaseAuthor); 82 | 83 | // when (act) 84 | Author actualAuthor = await subject.GetAuthorAsync(expectedAuthor.Id); 85 | 86 | // then (assert) 87 | // 1. Actual course == expected course 88 | // 2. DB was hit once 89 | // 3. Logger was NOT hit 90 | actualAuthor.Should().BeEquivalentTo(expectedAuthor); 91 | appDbContextMock.Verify(db => db.SelectAuthorByIdAsync(databaseAuthor.Id), Times.Once); 92 | appDbContextMock.VerifyNoOtherCalls(); 93 | } 94 | 95 | [Fact] 96 | public async Task AddAuthorAsync_ShouldReturnExpectedAuthorWithId() 97 | { 98 | // given (arrange) 99 | Filler authorFiller = new Filler(); 100 | 101 | authorFiller.Setup() 102 | .OnProperty(x => x.ContactEmail) 103 | .Use(new EmailAddresses(".com")) 104 | .OnProperty(x => x.ContactPhoneNumber) 105 | .Use("555-555-5555"); 106 | 107 | CreateAuthorDto authorDtoToAdd = authorFiller.Create(); 108 | 109 | Author authorToAdd = this.mapper.Map(authorDtoToAdd); 110 | 111 | Author databaseAuthor = this.mapper.Map(authorToAdd); 112 | 113 | databaseAuthor.Id = 1; 114 | databaseAuthor.DateCreated = databaseAuthor.DateUpdated = DateTime.UtcNow; 115 | 116 | this.appDbContextMock 117 | .Setup(db => db.CreateAuthorAsync(It.IsAny())) 118 | .ReturnsAsync(databaseAuthor); 119 | 120 | // when (act) 121 | var actualAuthor = await subject.AddAuthorAsync(authorDtoToAdd); 122 | 123 | // then (assert) 124 | actualAuthor.Should().BeEquivalentTo(databaseAuthor); 125 | appDbContextMock.Verify(db => db.CreateAuthorAsync(It.IsAny()), Times.Once); 126 | appDbContextMock.VerifyNoOtherCalls(); 127 | } 128 | 129 | [Fact] 130 | public async Task UpdateAuthorAsync_ShouldReturnExpectedAuthor() 131 | { 132 | // given (arrange) 133 | DateTime updateTime = DateTime.UtcNow; 134 | DateTime createTime = updateTime.AddDays(-5); 135 | 136 | Filler authorFiller = new Filler(); 137 | 138 | authorFiller.Setup() 139 | .OnProperty(x => x.ContactEmail) 140 | .Use(new EmailAddresses(".com")) 141 | .OnProperty(x => x.ContactPhoneNumber) 142 | .Use("555-555-5555"); 143 | 144 | UpdateAuthorDto authorToUpdateDto = authorFiller.Create(); 145 | 146 | authorToUpdateDto.Id = 1; 147 | 148 | Author authorToUpdate = this.mapper.Map(authorToUpdateDto); 149 | 150 | authorToUpdate.DateCreated = createTime; 151 | authorToUpdate.DateUpdated = updateTime; 152 | 153 | Author databaseAuthor = this.mapper.Map(authorToUpdate); 154 | 155 | databaseAuthor.DateUpdated = updateTime; 156 | 157 | this.appDbContextMock.Setup(db => 158 | db.SelectAuthorByIdAsync(authorToUpdateDto.Id)) 159 | .ReturnsAsync(authorToUpdate); 160 | 161 | this.appDbContextMock.Setup(db => 162 | db.UpdateAuthorAsync(It.IsAny())) 163 | .ReturnsAsync(databaseAuthor); 164 | 165 | // when (act) 166 | Author actualAuthor = await subject.UpdateAuthorAsync(authorToUpdateDto); 167 | 168 | // then (assert) 169 | actualAuthor.Should().BeEquivalentTo(databaseAuthor); 170 | Assert.Equal(actualAuthor.DateUpdated, updateTime); 171 | appDbContextMock.Verify(db => db.SelectAuthorByIdAsync(actualAuthor.Id), Times.Once); 172 | appDbContextMock.Verify(db => db.UpdateAuthorAsync(It.IsAny()), Times.Once); 173 | appDbContextMock.VerifyNoOtherCalls(); 174 | } 175 | 176 | [Fact] 177 | public async Task DeleteAuthorAsync_ShouldReturnExpectedAuthor() 178 | { 179 | // given (arrange) 180 | Filler authorFiller = new Filler(); 181 | 182 | Author authorToDelete = authorFiller.Create(); 183 | 184 | Author databaseAuthor = this.mapper.Map(authorToDelete); 185 | 186 | DateTime updateTime = DateTime.UtcNow; 187 | 188 | databaseAuthor.DateUpdated = updateTime; 189 | 190 | databaseAuthor.DateDeleted = updateTime; 191 | 192 | this.appDbContextMock.Setup(db => 193 | db.SelectAuthorByIdAsync(authorToDelete.Id)) 194 | .ReturnsAsync(authorToDelete); 195 | 196 | this.appDbContextMock.Setup(db => 197 | db.DeleteAuthorAsync(authorToDelete)) 198 | .ReturnsAsync(databaseAuthor); 199 | 200 | // when (act) 201 | Author actualAuthor = await subject.DeleteAuthorAsync(authorToDelete.Id); 202 | 203 | // then (assert) 204 | actualAuthor.Should().BeEquivalentTo(databaseAuthor); 205 | Assert.Equal(actualAuthor.DateUpdated, updateTime); 206 | Assert.Equal(actualAuthor.DateDeleted.GetValueOrDefault(), updateTime); 207 | appDbContextMock.Verify(db => db.SelectAuthorByIdAsync(actualAuthor.Id), Times.Once); 208 | appDbContextMock.Verify(db => db.DeleteAuthorAsync(authorToDelete), Times.Once); 209 | appDbContextMock.VerifyNoOtherCalls(); 210 | } 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/Migrations/20200805182225_CourseLessonsAndAuthors.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using CoreLMS.Persistence; 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 | namespace CoreLMS.Persistence.Migrations 11 | { 12 | [DbContext(typeof(AppDbContext))] 13 | [Migration("20200805182225_CourseLessonsAndAuthors")] 14 | partial class CourseLessonsAndAuthors 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "3.1.6") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("CoreLMS.Core.Entities.Author", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("int") 29 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 30 | 31 | b.Property("DateCreated") 32 | .HasColumnType("datetime2"); 33 | 34 | b.Property("DateDeleted") 35 | .HasColumnType("datetime2"); 36 | 37 | b.Property("DateUpdated") 38 | .HasColumnType("datetime2"); 39 | 40 | b.Property("Description") 41 | .HasColumnType("nvarchar(max)"); 42 | 43 | b.Property("PersonID") 44 | .HasColumnType("int"); 45 | 46 | b.Property("WebsiteURL") 47 | .HasColumnType("nvarchar(max)"); 48 | 49 | b.HasKey("Id"); 50 | 51 | b.HasIndex("PersonID"); 52 | 53 | b.ToTable("Authors"); 54 | }); 55 | 56 | modelBuilder.Entity("CoreLMS.Core.Entities.Course", b => 57 | { 58 | b.Property("Id") 59 | .ValueGeneratedOnAdd() 60 | .HasColumnType("int") 61 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 62 | 63 | b.Property("CourseImageURL") 64 | .HasColumnType("nvarchar(max)"); 65 | 66 | b.Property("CourseType") 67 | .HasColumnType("int"); 68 | 69 | b.Property("DateCreated") 70 | .HasColumnType("datetime2"); 71 | 72 | b.Property("DateDeleted") 73 | .HasColumnType("datetime2"); 74 | 75 | b.Property("DateUpdated") 76 | .HasColumnType("datetime2"); 77 | 78 | b.Property("Description") 79 | .HasColumnType("nvarchar(max)"); 80 | 81 | b.Property("Name") 82 | .HasColumnType("nvarchar(max)"); 83 | 84 | b.HasKey("Id"); 85 | 86 | b.ToTable("Courses"); 87 | }); 88 | 89 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLesson", b => 90 | { 91 | b.Property("Id") 92 | .ValueGeneratedOnAdd() 93 | .HasColumnType("int") 94 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 95 | 96 | b.Property("CourseId") 97 | .HasColumnType("int"); 98 | 99 | b.Property("DateCreated") 100 | .HasColumnType("datetime2"); 101 | 102 | b.Property("DateDeleted") 103 | .HasColumnType("datetime2"); 104 | 105 | b.Property("DateUpdated") 106 | .HasColumnType("datetime2"); 107 | 108 | b.Property("Description") 109 | .HasColumnType("nvarchar(max)"); 110 | 111 | b.Property("LessonType") 112 | .HasColumnType("int"); 113 | 114 | b.Property("Name") 115 | .HasColumnType("nvarchar(max)"); 116 | 117 | b.Property("VideoSourceCode") 118 | .HasColumnType("nvarchar(max)"); 119 | 120 | b.Property("VideoSourceType") 121 | .HasColumnType("int"); 122 | 123 | b.HasKey("Id"); 124 | 125 | b.HasIndex("CourseId"); 126 | 127 | b.ToTable("CourseLessons"); 128 | }); 129 | 130 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLessonAttachment", b => 131 | { 132 | b.Property("Id") 133 | .ValueGeneratedOnAdd() 134 | .HasColumnType("int") 135 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 136 | 137 | b.Property("CourseLessonId") 138 | .HasColumnType("int"); 139 | 140 | b.Property("DateCreated") 141 | .HasColumnType("datetime2"); 142 | 143 | b.Property("DateDeleted") 144 | .HasColumnType("datetime2"); 145 | 146 | b.Property("DateUpdated") 147 | .HasColumnType("datetime2"); 148 | 149 | b.Property("Description") 150 | .HasColumnType("nvarchar(max)"); 151 | 152 | b.Property("Name") 153 | .HasColumnType("nvarchar(max)"); 154 | 155 | b.HasKey("Id"); 156 | 157 | b.HasIndex("CourseLessonId"); 158 | 159 | b.ToTable("CourseLessonAttachments"); 160 | }); 161 | 162 | modelBuilder.Entity("CoreLMS.Core.Entities.Person", b => 163 | { 164 | b.Property("Id") 165 | .ValueGeneratedOnAdd() 166 | .HasColumnType("int") 167 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 168 | 169 | b.Property("DateCreated") 170 | .HasColumnType("datetime2"); 171 | 172 | b.Property("DateDeleted") 173 | .HasColumnType("datetime2"); 174 | 175 | b.Property("DateUpdated") 176 | .HasColumnType("datetime2"); 177 | 178 | b.Property("Email") 179 | .HasColumnType("nvarchar(max)"); 180 | 181 | b.Property("FirstName") 182 | .HasColumnType("nvarchar(max)"); 183 | 184 | b.Property("LastName") 185 | .HasColumnType("nvarchar(max)"); 186 | 187 | b.Property("MiddleName") 188 | .HasColumnType("nvarchar(max)"); 189 | 190 | b.Property("PhoneNumber") 191 | .HasColumnType("nvarchar(max)"); 192 | 193 | b.Property("Suffix") 194 | .HasColumnType("nvarchar(max)"); 195 | 196 | b.HasKey("Id"); 197 | 198 | b.ToTable("People"); 199 | }); 200 | 201 | modelBuilder.Entity("CoreLMS.Core.Entities.Author", b => 202 | { 203 | b.HasOne("CoreLMS.Core.Entities.Person", "Person") 204 | .WithMany() 205 | .HasForeignKey("PersonID") 206 | .OnDelete(DeleteBehavior.Cascade) 207 | .IsRequired(); 208 | }); 209 | 210 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLesson", b => 211 | { 212 | b.HasOne("CoreLMS.Core.Entities.Course", "Course") 213 | .WithMany("CourseLessons") 214 | .HasForeignKey("CourseId") 215 | .OnDelete(DeleteBehavior.Cascade) 216 | .IsRequired(); 217 | }); 218 | 219 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLessonAttachment", b => 220 | { 221 | b.HasOne("CoreLMS.Core.Entities.CourseLesson", "CourseLesson") 222 | .WithMany("CourseLessonAttachments") 223 | .HasForeignKey("CourseLessonId") 224 | .OnDelete(DeleteBehavior.Cascade) 225 | .IsRequired(); 226 | }); 227 | #pragma warning restore 612, 618 228 | } 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/Migrations/20201104181704_AuthorPersonUpdate.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using CoreLMS.Persistence; 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 | namespace CoreLMS.Persistence.Migrations 11 | { 12 | [DbContext(typeof(AppDbContext))] 13 | [Migration("20201104181704_AuthorPersonUpdate")] 14 | partial class AuthorPersonUpdate 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "3.1.8") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("CoreLMS.Core.Entities.Author", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("int") 29 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 30 | 31 | b.Property("ContactEmail") 32 | .IsRequired() 33 | .HasColumnType("nvarchar(max)"); 34 | 35 | b.Property("ContactPhoneNumber") 36 | .HasColumnType("nvarchar(max)"); 37 | 38 | b.Property("DateCreated") 39 | .HasColumnType("datetime2"); 40 | 41 | b.Property("DateDeleted") 42 | .HasColumnType("datetime2"); 43 | 44 | b.Property("DateUpdated") 45 | .HasColumnType("datetime2"); 46 | 47 | b.Property("Description") 48 | .HasColumnType("nvarchar(max)"); 49 | 50 | b.Property("FirstName") 51 | .IsRequired() 52 | .HasColumnType("nvarchar(max)"); 53 | 54 | b.Property("LastName") 55 | .IsRequired() 56 | .HasColumnType("nvarchar(max)"); 57 | 58 | b.Property("MiddleName") 59 | .HasColumnType("nvarchar(max)"); 60 | 61 | b.Property("Suffix") 62 | .HasColumnType("nvarchar(max)"); 63 | 64 | b.Property("WebsiteURL") 65 | .HasColumnType("nvarchar(max)"); 66 | 67 | b.HasKey("Id"); 68 | 69 | b.ToTable("Authors"); 70 | }); 71 | 72 | modelBuilder.Entity("CoreLMS.Core.Entities.AuthorCourseLesson", b => 73 | { 74 | b.Property("AuthorId") 75 | .HasColumnType("int"); 76 | 77 | b.Property("CourseLessonId") 78 | .HasColumnType("int"); 79 | 80 | b.HasKey("AuthorId", "CourseLessonId"); 81 | 82 | b.HasIndex("CourseLessonId"); 83 | 84 | b.ToTable("AuthorCourseLessons"); 85 | }); 86 | 87 | modelBuilder.Entity("CoreLMS.Core.Entities.Course", b => 88 | { 89 | b.Property("Id") 90 | .ValueGeneratedOnAdd() 91 | .HasColumnType("int") 92 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 93 | 94 | b.Property("CourseImageURL") 95 | .HasColumnType("nvarchar(max)"); 96 | 97 | b.Property("CourseType") 98 | .HasColumnType("int"); 99 | 100 | b.Property("DateCreated") 101 | .HasColumnType("datetime2"); 102 | 103 | b.Property("DateDeleted") 104 | .HasColumnType("datetime2"); 105 | 106 | b.Property("DateUpdated") 107 | .HasColumnType("datetime2"); 108 | 109 | b.Property("Description") 110 | .HasColumnType("nvarchar(max)"); 111 | 112 | b.Property("Name") 113 | .IsRequired() 114 | .HasColumnType("nvarchar(max)"); 115 | 116 | b.HasKey("Id"); 117 | 118 | b.ToTable("Courses"); 119 | }); 120 | 121 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLesson", b => 122 | { 123 | b.Property("Id") 124 | .ValueGeneratedOnAdd() 125 | .HasColumnType("int") 126 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 127 | 128 | b.Property("CourseId") 129 | .HasColumnType("int"); 130 | 131 | b.Property("DateCreated") 132 | .HasColumnType("datetime2"); 133 | 134 | b.Property("DateDeleted") 135 | .HasColumnType("datetime2"); 136 | 137 | b.Property("DateUpdated") 138 | .HasColumnType("datetime2"); 139 | 140 | b.Property("Description") 141 | .HasColumnType("nvarchar(max)"); 142 | 143 | b.Property("LessonType") 144 | .HasColumnType("int"); 145 | 146 | b.Property("Name") 147 | .HasColumnType("nvarchar(max)"); 148 | 149 | b.Property("VideoSourceCode") 150 | .HasColumnType("nvarchar(max)"); 151 | 152 | b.Property("VideoSourceType") 153 | .HasColumnType("int"); 154 | 155 | b.HasKey("Id"); 156 | 157 | b.HasIndex("CourseId"); 158 | 159 | b.ToTable("CourseLessons"); 160 | }); 161 | 162 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLessonAttachment", b => 163 | { 164 | b.Property("Id") 165 | .ValueGeneratedOnAdd() 166 | .HasColumnType("int") 167 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 168 | 169 | b.Property("CourseLessonId") 170 | .HasColumnType("int"); 171 | 172 | b.Property("DateCreated") 173 | .HasColumnType("datetime2"); 174 | 175 | b.Property("DateDeleted") 176 | .HasColumnType("datetime2"); 177 | 178 | b.Property("DateUpdated") 179 | .HasColumnType("datetime2"); 180 | 181 | b.Property("Description") 182 | .HasColumnType("nvarchar(max)"); 183 | 184 | b.Property("Name") 185 | .HasColumnType("nvarchar(max)"); 186 | 187 | b.HasKey("Id"); 188 | 189 | b.HasIndex("CourseLessonId"); 190 | 191 | b.ToTable("CourseLessonAttachments"); 192 | }); 193 | 194 | modelBuilder.Entity("CoreLMS.Core.Entities.AuthorCourseLesson", b => 195 | { 196 | b.HasOne("CoreLMS.Core.Entities.Author", "Author") 197 | .WithMany("CourseLessons") 198 | .HasForeignKey("AuthorId") 199 | .OnDelete(DeleteBehavior.Cascade) 200 | .IsRequired(); 201 | 202 | b.HasOne("CoreLMS.Core.Entities.CourseLesson", "CourseLesson") 203 | .WithMany("Authors") 204 | .HasForeignKey("CourseLessonId") 205 | .OnDelete(DeleteBehavior.Cascade) 206 | .IsRequired(); 207 | }); 208 | 209 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLesson", b => 210 | { 211 | b.HasOne("CoreLMS.Core.Entities.Course", "Course") 212 | .WithMany("CourseLessons") 213 | .HasForeignKey("CourseId") 214 | .OnDelete(DeleteBehavior.Cascade) 215 | .IsRequired(); 216 | }); 217 | 218 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLessonAttachment", b => 219 | { 220 | b.HasOne("CoreLMS.Core.Entities.CourseLesson", "CourseLesson") 221 | .WithMany("CourseLessonAttachments") 222 | .HasForeignKey("CourseLessonId") 223 | .OnDelete(DeleteBehavior.Cascade) 224 | .IsRequired(); 225 | }); 226 | #pragma warning restore 612, 618 227 | } 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /CoreLMS.Persistence/Migrations/AppDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using CoreLMS.Persistence; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.EntityFrameworkCore.Infrastructure; 6 | using Microsoft.EntityFrameworkCore.Metadata; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | 9 | namespace CoreLMS.Persistence.Migrations 10 | { 11 | [DbContext(typeof(AppDbContext))] 12 | partial class AppDbContextModelSnapshot : ModelSnapshot 13 | { 14 | protected override void BuildModel(ModelBuilder modelBuilder) 15 | { 16 | #pragma warning disable 612, 618 17 | modelBuilder 18 | .UseIdentityColumns() 19 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 20 | .HasAnnotation("ProductVersion", "3.1.8"); 21 | 22 | modelBuilder.Entity("CoreLMS.Core.Entities.Author", b => 23 | { 24 | b.Property("Id") 25 | .ValueGeneratedOnAdd() 26 | .HasColumnType("int") 27 | .UseIdentityColumn(); 28 | 29 | b.Property("ContactEmail") 30 | .IsRequired() 31 | .HasColumnType("nvarchar(max)"); 32 | 33 | b.Property("ContactPhoneNumber") 34 | .HasColumnType("nvarchar(max)"); 35 | 36 | b.Property("DateCreated") 37 | .HasColumnType("datetime2"); 38 | 39 | b.Property("DateDeleted") 40 | .HasColumnType("datetime2"); 41 | 42 | b.Property("DateUpdated") 43 | .HasColumnType("datetime2"); 44 | 45 | b.Property("Description") 46 | .HasColumnType("nvarchar(max)"); 47 | 48 | b.Property("FirstName") 49 | .IsRequired() 50 | .HasColumnType("nvarchar(max)"); 51 | 52 | b.Property("LastName") 53 | .IsRequired() 54 | .HasColumnType("nvarchar(max)"); 55 | 56 | b.Property("MiddleName") 57 | .HasColumnType("nvarchar(max)"); 58 | 59 | b.Property("Suffix") 60 | .HasColumnType("nvarchar(max)"); 61 | 62 | b.Property("WebsiteURL") 63 | .HasColumnType("nvarchar(max)"); 64 | 65 | b.HasKey("Id"); 66 | 67 | b.ToTable("Authors"); 68 | }); 69 | 70 | modelBuilder.Entity("CoreLMS.Core.Entities.AuthorCourseLesson", b => 71 | { 72 | b.Property("AuthorId") 73 | .HasColumnType("int"); 74 | 75 | b.Property("CourseLessonId") 76 | .HasColumnType("int"); 77 | 78 | b.HasKey("AuthorId", "CourseLessonId"); 79 | 80 | b.HasIndex("CourseLessonId"); 81 | 82 | b.ToTable("AuthorCourseLessons"); 83 | }); 84 | 85 | modelBuilder.Entity("CoreLMS.Core.Entities.Course", b => 86 | { 87 | b.Property("Id") 88 | .ValueGeneratedOnAdd() 89 | .HasColumnType("int") 90 | .UseIdentityColumn(); 91 | 92 | b.Property("CourseImageURL") 93 | .HasColumnType("nvarchar(max)"); 94 | 95 | b.Property("CourseType") 96 | .HasColumnType("int"); 97 | 98 | b.Property("DateCreated") 99 | .HasColumnType("datetime2"); 100 | 101 | b.Property("DateDeleted") 102 | .HasColumnType("datetime2"); 103 | 104 | b.Property("DateUpdated") 105 | .HasColumnType("datetime2"); 106 | 107 | b.Property("Description") 108 | .HasColumnType("nvarchar(max)"); 109 | 110 | b.Property("Name") 111 | .IsRequired() 112 | .HasColumnType("nvarchar(max)"); 113 | 114 | b.HasKey("Id"); 115 | 116 | b.ToTable("Courses"); 117 | }); 118 | 119 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLesson", b => 120 | { 121 | b.Property("Id") 122 | .ValueGeneratedOnAdd() 123 | .HasColumnType("int") 124 | .UseIdentityColumn(); 125 | 126 | b.Property("CourseId") 127 | .HasColumnType("int"); 128 | 129 | b.Property("DateCreated") 130 | .HasColumnType("datetime2"); 131 | 132 | b.Property("DateDeleted") 133 | .HasColumnType("datetime2"); 134 | 135 | b.Property("DateUpdated") 136 | .HasColumnType("datetime2"); 137 | 138 | b.Property("Description") 139 | .HasColumnType("nvarchar(max)"); 140 | 141 | b.Property("LessonType") 142 | .HasColumnType("int"); 143 | 144 | b.Property("Name") 145 | .HasColumnType("nvarchar(max)"); 146 | 147 | b.Property("VideoSourceCode") 148 | .HasColumnType("nvarchar(max)"); 149 | 150 | b.Property("VideoSourceType") 151 | .HasColumnType("int"); 152 | 153 | b.HasKey("Id"); 154 | 155 | b.HasIndex("CourseId"); 156 | 157 | b.ToTable("CourseLessons"); 158 | }); 159 | 160 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLessonAttachment", b => 161 | { 162 | b.Property("Id") 163 | .ValueGeneratedOnAdd() 164 | .HasColumnType("int") 165 | .UseIdentityColumn(); 166 | 167 | b.Property("CourseLessonId") 168 | .HasColumnType("int"); 169 | 170 | b.Property("DateCreated") 171 | .HasColumnType("datetime2"); 172 | 173 | b.Property("DateDeleted") 174 | .HasColumnType("datetime2"); 175 | 176 | b.Property("DateUpdated") 177 | .HasColumnType("datetime2"); 178 | 179 | b.Property("Description") 180 | .HasColumnType("nvarchar(max)"); 181 | 182 | b.Property("Name") 183 | .HasColumnType("nvarchar(max)"); 184 | 185 | b.HasKey("Id"); 186 | 187 | b.HasIndex("CourseLessonId"); 188 | 189 | b.ToTable("CourseLessonAttachments"); 190 | }); 191 | 192 | modelBuilder.Entity("CoreLMS.Core.Entities.AuthorCourseLesson", b => 193 | { 194 | b.HasOne("CoreLMS.Core.Entities.Author", "Author") 195 | .WithMany("CourseLessons") 196 | .HasForeignKey("AuthorId") 197 | .OnDelete(DeleteBehavior.Cascade) 198 | .IsRequired(); 199 | 200 | b.HasOne("CoreLMS.Core.Entities.CourseLesson", "CourseLesson") 201 | .WithMany("Authors") 202 | .HasForeignKey("CourseLessonId") 203 | .OnDelete(DeleteBehavior.Cascade) 204 | .IsRequired(); 205 | 206 | b.Navigation("Author"); 207 | 208 | b.Navigation("CourseLesson"); 209 | }); 210 | 211 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLesson", b => 212 | { 213 | b.HasOne("CoreLMS.Core.Entities.Course", "Course") 214 | .WithMany("CourseLessons") 215 | .HasForeignKey("CourseId") 216 | .OnDelete(DeleteBehavior.Cascade) 217 | .IsRequired(); 218 | 219 | b.Navigation("Course"); 220 | }); 221 | 222 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLessonAttachment", b => 223 | { 224 | b.HasOne("CoreLMS.Core.Entities.CourseLesson", "CourseLesson") 225 | .WithMany("CourseLessonAttachments") 226 | .HasForeignKey("CourseLessonId") 227 | .OnDelete(DeleteBehavior.Cascade) 228 | .IsRequired(); 229 | 230 | b.Navigation("CourseLesson"); 231 | }); 232 | 233 | modelBuilder.Entity("CoreLMS.Core.Entities.Author", b => 234 | { 235 | b.Navigation("CourseLessons"); 236 | }); 237 | 238 | modelBuilder.Entity("CoreLMS.Core.Entities.Course", b => 239 | { 240 | b.Navigation("CourseLessons"); 241 | }); 242 | 243 | modelBuilder.Entity("CoreLMS.Core.Entities.CourseLesson", b => 244 | { 245 | b.Navigation("Authors"); 246 | 247 | b.Navigation("CourseLessonAttachments"); 248 | }); 249 | #pragma warning restore 612, 618 250 | } 251 | } 252 | } 253 | --------------------------------------------------------------------------------