diff --git a/README.md b/README.md index 28afc38..2e0492f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # VietNamHistory
The project is in the development stage
+## You can get all my materials for this project here : https://drive.google.com/drive/folders/1EUq5xxeMOWacea59xSQnLhdyWzs5yzZZ?usp=sharing +
+## Description project at youtube: https://www.youtube.com/watch?v=NqTf46UVhHc diff --git a/VNH.Application/Common/Contants/ConstantNofication.cs b/VNH.Application/Common/Contants/ConstantNofication.cs new file mode 100644 index 0000000..7d3e573 --- /dev/null +++ b/VNH.Application/Common/Contants/ConstantNofication.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VNH.Application.Common.Contants +{ + public static class ConstantNofication + { + // Post + public static string CommentPost(string name) + { + return "[ "+name+" ]" + " đã bình luận một bài viết của bạn"; + } + public static string LikePost(string name) + { + return "[ " + name + " ]" + " đã thích một bài viết của bạn"; + } + + // Forum + public static string CommentAnswer(string name) + { + return "[ " + name + " ]" + " đã bình luận trong câu hỏi của bạn"; + } + public static string AnswerTheQuestion(string name) + { + return "[ " + name + " ]" + " đã 'trả lời' một câu hỏi của bạn"; + } + public static string LikeQuestion(string name) + { + return "[ " + name + " ]" + " đã tán thành một câu hỏi của bạn"; + } + public static string LikeAnswer(string name) + { + return "[ " + name + " ]" + " đã 'tán thành' một câu trả lời của bạn"; + } + } +} diff --git a/VNH.Application/Common/Contants/ConstantUrl.cs b/VNH.Application/Common/Contants/ConstantUrl.cs new file mode 100644 index 0000000..6be1838 --- /dev/null +++ b/VNH.Application/Common/Contants/ConstantUrl.cs @@ -0,0 +1,9 @@ + +namespace VNH.Application.Common.Contants +{ + public static class ConstantUrl + { + public const string UrlPostDetail = "/discover/"; + public const string UrlQuestionDetail = "/forum/"; + } +} diff --git a/VNH.Application/Common/Contants/SystemConstants.cs b/VNH.Application/Common/Contants/SystemConstants.cs index 0daafcf..b965aad 100644 --- a/VNH.Application/Common/Contants/SystemConstants.cs +++ b/VNH.Application/Common/Contants/SystemConstants.cs @@ -5,10 +5,13 @@ public static class SystemConstants public const string Token = "Token"; public const string BaseAddress = "BaseAddress"; + public const string UrlWeb = "https://tyls.fun/"; + public const string ConnectString = "Data Source=202.92.7.204\\MSSQLSERVER2022, 1438;Initial Catalog=tyls;User Id=toiyeulichsu;Password=MheZDu9$oGbrYlL#S%ApJ^qf;TrustServerCertificate=true; "; + //public const string UrlWeb = "https://vuanhpham25-001-site1.gtempurl.com/"; - //public const string ConnectString = "Data Source=SQL5106.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;User Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai"; + //public const string ConnectString = "Data Source=SQL5112.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;User Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai"; - public const string UrlWeb = "https://localhost:7138/"; - public const string ConnectString = "Data Source=.;Initial Catalog=VietNamHistory;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;"; + //public const string UrlWeb = "https://localhost:7138/"; + //public const string ConnectString = "Data Source=.;Initial Catalog=tyls;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;"; } } diff --git a/VNH.Application/DTOs/Catalog/ExamHistoryDto/CreateExamHistoryDto.cs b/VNH.Application/DTOs/Catalog/ExamHistoryDto/CreateExamHistoryDto.cs index f400307..95b986f 100644 --- a/VNH.Application/DTOs/Catalog/ExamHistoryDto/CreateExamHistoryDto.cs +++ b/VNH.Application/DTOs/Catalog/ExamHistoryDto/CreateExamHistoryDto.cs @@ -13,7 +13,7 @@ public class CreateExamHistoryDto public Guid MultipleChoiceId { get; set; } public Guid UserId { get; set; } - public int Scores { get; set; } + public float Scores { get; set; } public int CompletionTime { get; set; } diff --git a/VNH.Application/DTOs/Catalog/ExamHistoryDto/ExamHistoryResponseDto.cs b/VNH.Application/DTOs/Catalog/ExamHistoryDto/ExamHistoryResponseDto.cs index 2e0394f..04e1455 100644 --- a/VNH.Application/DTOs/Catalog/ExamHistoryDto/ExamHistoryResponseDto.cs +++ b/VNH.Application/DTOs/Catalog/ExamHistoryDto/ExamHistoryResponseDto.cs @@ -15,7 +15,9 @@ public class ExamHistoryResponseDto public UserShortDto? UserShortDto { get; set; } = new UserShortDto(); - public int Scores { get; set; } + public int numberQuiz { get; set; } = 0; + + public float Scores { get; set; } public int CompletionTime { get; set; } diff --git a/VNH.Application/DTOs/Catalog/MultipleChoiceDto/CreateQuizDto.cs b/VNH.Application/DTOs/Catalog/MultipleChoiceDto/CreateQuizDto.cs index 581558d..f52f648 100644 --- a/VNH.Application/DTOs/Catalog/MultipleChoiceDto/CreateQuizDto.cs +++ b/VNH.Application/DTOs/Catalog/MultipleChoiceDto/CreateQuizDto.cs @@ -10,7 +10,7 @@ namespace VNH.Application.DTOs.Catalog.MultipleChoiceDto public class CreateQuizDto { public string? Id { get; set; } = Guid.NewGuid().ToString(); - + public string Title { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; diff --git a/VNH.Application/DTOs/Catalog/MultipleChoiceDto/MultipleChoiceResponseDto.cs b/VNH.Application/DTOs/Catalog/MultipleChoiceDto/MultipleChoiceResponseDto.cs index 8f0d1a4..9ca7dbd 100644 --- a/VNH.Application/DTOs/Catalog/MultipleChoiceDto/MultipleChoiceResponseDto.cs +++ b/VNH.Application/DTOs/Catalog/MultipleChoiceDto/MultipleChoiceResponseDto.cs @@ -20,6 +20,9 @@ public class MultipleChoiceResponseDto public DateTime? UpdatedAt { get; set; } public int WorkTime { get; set; } + public int NumberQuiz { get; set; } = 0; + + public UserShortDto? UserShort { get; set; } = new UserShortDto(); public List Quizs { get; set; } = new List(); diff --git a/VNH.Application/DTOs/Catalog/Notifications/NotificationDto.cs b/VNH.Application/DTOs/Catalog/Notifications/NotificationDto.cs new file mode 100644 index 0000000..41fea2c --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Notifications/NotificationDto.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VNH.Application.DTOs.Catalog.Notifications +{ + public class NotificationDto + { + public Guid? Id { get; set; } + public Guid UserId { get; set; } + public Guid? NotificationId { get; set; } = Guid.Empty; + public Guid? IdObject { get; set; } + public string? Content { get; set; } + public DateTime? Date { get; set; } + public string? Url { get; set; } + + } +} diff --git a/VNH.Application/Interfaces/Catalog/Documents/IDocumentService.cs b/VNH.Application/Interfaces/Catalog/Documents/IDocumentService.cs index b6bda8b..9c90d6b 100644 --- a/VNH.Application/Interfaces/Catalog/Documents/IDocumentService.cs +++ b/VNH.Application/Interfaces/Catalog/Documents/IDocumentService.cs @@ -1,5 +1,6 @@ using VNH.Application.DTOs.Catalog.Document; using VNH.Application.DTOs.Catalog.Posts; +using VNH.Application.DTOs.Common; using VNH.Application.DTOs.Common.ResponseNotification; namespace VNH.Application.Interfaces.Documents @@ -12,11 +13,12 @@ public interface IDocumentService Task>> GetAll(); Task> Delete(string id, string email); - Task> GetSave(DocumentFpkDto docsFpk); + Task> GetSave(DocumentFpkDto docsFpk); - Task> AddOrRemoveSaveDocs(DocumentFpkDto docsFpk); + Task> AddOrRemoveSaveDocs(DocumentFpkDto docsFpk); Task>> Search(string keyWord); Task>> GetMyDocument(string userId); Task>> GetMySave(string userId); + Task SaveDownloads(Guid documentId); } } diff --git a/VNH.Application/Interfaces/Catalog/ExamHistory/IExamHistoryService.cs b/VNH.Application/Interfaces/Catalog/ExamHistory/IExamHistoryService.cs index e7fa8eb..d62757a 100644 --- a/VNH.Application/Interfaces/Catalog/ExamHistory/IExamHistoryService.cs +++ b/VNH.Application/Interfaces/Catalog/ExamHistory/IExamHistoryService.cs @@ -12,10 +12,9 @@ public interface IExamHistoryService { Task> Create(CreateExamHistoryDto requestDto, string name); - Task> Update(CreateExamHistoryDto requestDto, string name); + Task> Update(CreateExamHistoryDto requestDto, string name); Task>> GetMyExamHistory(string id); - - + Task>> GetExamHistory(string examId); } } diff --git a/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs b/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs index 1480c56..eb0e3db 100644 --- a/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs +++ b/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs @@ -9,7 +9,7 @@ public interface IAnswerService { Task>> GetAnswer(string questionId); - Task>> CreateAnswer(AnswerQuestionDto answer); + Task>> CreateAnswer(AnswerQuestionDto answer, string? id); Task>> UpdateAnswer(AnswerQuestionDto answer); Task> DeteleAnswer(string id); diff --git a/VNH.Application/Interfaces/Catalog/MultipleChoices/IMultipleChoiceService.cs b/VNH.Application/Interfaces/Catalog/MultipleChoices/IMultipleChoiceService.cs index 9015e5f..62c5966 100644 --- a/VNH.Application/Interfaces/Catalog/MultipleChoices/IMultipleChoiceService.cs +++ b/VNH.Application/Interfaces/Catalog/MultipleChoices/IMultipleChoiceService.cs @@ -21,6 +21,7 @@ public interface IMultipleChoiceService Task> Delete(string id, string userId); Task> DeleteQuizById(string id); + Task>> GetMyMultipleChoice(string id); Task>> Search(string keyWord); diff --git a/VNH.Application/Interfaces/Catalog/NotificationServices/INotificationService.cs b/VNH.Application/Interfaces/Catalog/NotificationServices/INotificationService.cs new file mode 100644 index 0000000..5cc4032 --- /dev/null +++ b/VNH.Application/Interfaces/Catalog/NotificationServices/INotificationService.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.DTOs.Catalog.Notifications; +using VNH.Application.DTOs.Common.ResponseNotification; +using VNH.Domain.Entities; + +namespace VNH.Application.Implement.Catalog.NotificationServices +{ + public interface INotificationService + { + Task>> GetAll(string userId); + Task> Add(string title); + Task AddNotificationDetail(NotificationDto notification); + Task> Update(NotificationDto notification); + } +} diff --git a/VNH.Application/Interfaces/Catalog/Posts/IPostService.cs b/VNH.Application/Interfaces/Catalog/Posts/IPostService.cs index b671a43..e2d781f 100644 --- a/VNH.Application/Interfaces/Catalog/Posts/IPostService.cs +++ b/VNH.Application/Interfaces/Catalog/Posts/IPostService.cs @@ -23,7 +23,7 @@ public interface IPostService Task> GetSave(PostFpkDto postFpk); Task>> GetPostByTag(string tag); Task>> GetComment(string postId); - Task>> CreateComment(CommentPostDto comment); + Task>> CreateComment(CommentPostDto comment, string userId); Task>> UpdateComment(CommentPostDto comment); Task>> DeteleComment(string id); Task>> GetMyPostSaved(string id); diff --git a/VNH.Application/Interfaces/Common/IImageService.cs b/VNH.Application/Interfaces/Common/IImageService.cs index 3414e8a..a229109 100644 --- a/VNH.Application/Interfaces/Common/IImageService.cs +++ b/VNH.Application/Interfaces/Common/IImageService.cs @@ -10,6 +10,7 @@ namespace VNH.Application.Interfaces.Common public interface IImageService { Task SaveFile(IFormFile file); + Task SaveImageArticle(IFormFile file); Task ConvertFormFileToByteArray(IFormFile formFile); string ConvertByteArrayToString(byte[]? byteArray, Encoding encoding); byte[] CompressImage(byte[] originalImage, int KbNumber); diff --git a/VNH.Application/Interfaces/Common/IStorageService.cs b/VNH.Application/Interfaces/Common/IStorageService.cs index b4978f1..06e4b20 100644 --- a/VNH.Application/Interfaces/Common/IStorageService.cs +++ b/VNH.Application/Interfaces/Common/IStorageService.cs @@ -5,6 +5,7 @@ public interface IStorageService { string GetFileUrl(string fileName); Task SaveFileAsync(Stream mediaBinaryStream, string fileName); + Task SaveImageFileAsync(Stream mediaBinaryStream, string fileName); Task DeleteFileAsync(string fileName); Task SaveDocFileAsync(Stream mediaBinaryStream, string fileName); Task DeleteDocFileAsync(string fileName); diff --git a/VNH.Application/Mappers/NotifiMapper.cs b/VNH.Application/Mappers/NotifiMapper.cs new file mode 100644 index 0000000..581f0b2 --- /dev/null +++ b/VNH.Application/Mappers/NotifiMapper.cs @@ -0,0 +1,20 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.DTOs.Catalog.MultipleChoiceDto; +using VNH.Domain.Entities; +using VNH.Domain; +using VNH.Application.DTOs.Catalog.Notifications; + +namespace VNH.Application.Mappers +{ + public class NotifiMapper : Profile + { + public NotifiMapper() { + CreateMap().ReverseMap(); + } + } +} diff --git a/VNH.Application/VNH.Application.csproj b/VNH.Application/VNH.Application.csproj index ced845f..44a16ec 100644 --- a/VNH.Application/VNH.Application.csproj +++ b/VNH.Application/VNH.Application.csproj @@ -16,7 +16,6 @@ - diff --git a/VNH.Domain/Entities/Document.cs b/VNH.Domain/Entities/Document.cs index 460a268..1cecb55 100644 --- a/VNH.Domain/Entities/Document.cs +++ b/VNH.Domain/Entities/Document.cs @@ -18,10 +18,7 @@ public Document() [Key] public Guid Id { get; set; } - [Required] - [StringLength(255)] public string Title { get; set; } - [StringLength(500)] public string Description { get; set; } public string SubId { get; set; } public bool IsDeleted { get; set; } = false; @@ -32,6 +29,8 @@ public Document() public DateTime CreatedAt { get; set; } [Column(TypeName = "datetime")] public DateTime? UpdatedAt { get; set; } + public long ViewNumber { get; set; } + public int DownloadNumber { get; set; } [ForeignKey("UserId")] [InverseProperty("Documents")] diff --git a/VNH.Domain/Entities/ExamHistory.cs b/VNH.Domain/Entities/ExamHistory.cs index cd10938..264bd40 100644 --- a/VNH.Domain/Entities/ExamHistory.cs +++ b/VNH.Domain/Entities/ExamHistory.cs @@ -20,24 +20,14 @@ public partial class ExamHistory public Guid UserId { get; set; } - public int Scores { get; set; } - + public float Scores { get; set; } public int CompletionTime { get; set; } [Column(TypeName = "datetime")] public DateTime StarDate { get; set; } - - - [ForeignKey("MultipleChoiceId")] + [InverseProperty("ExamHistory")] public virtual MultipleChoice MultipleChoice { get; set; } - - - - - - - } } diff --git a/VNH.Domain/Entities/ExamHistoryMultipleChoice.cs b/VNH.Domain/Entities/ExamHistoryMultipleChoice.cs new file mode 100644 index 0000000..e3391ef --- /dev/null +++ b/VNH.Domain/Entities/ExamHistoryMultipleChoice.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VNH.Domain.Entities +{ + public class ExamHistoryMultipleChoice + { + [Key] + public Guid Id { get; set; } + public Guid ExamHistoryId { get; set; } + public ExamHistory ExamHistory { get; set; } + + public Guid MultipleChoiceId { get; set; } + public MultipleChoice MultipleChoice { get; set; } + } +} diff --git a/VNH.Domain/Entities/MultipleChoice.cs b/VNH.Domain/Entities/MultipleChoice.cs index de83823..adbbf76 100644 --- a/VNH.Domain/Entities/MultipleChoice.cs +++ b/VNH.Domain/Entities/MultipleChoice.cs @@ -12,42 +12,29 @@ namespace VNH.Domain.Entities [Table("MultipleChoise")] public partial class MultipleChoice { - [Key] public Guid Id { get; set; } public string Title { get; set; } - [StringLength(500)] public string Description { get; set; } - [StringLength(500)] [Column(TypeName = "datetime")] public DateTime CreatedAt { get; set; } = DateTime.Now; - [Column(TypeName = "datetime")] public DateTime? UpdatedAt { get; set; } public int WorkTime { get; set; } - public Guid UserId { get; set; } - - - [InverseProperty("MultipleChoice")] public virtual ICollection Quiz { get; set; } - [ForeignKey("UserId")] public virtual User User { get; set; } [InverseProperty("MultipleChoice")] - public virtual ExamHistory ExamHistories { get; set; } - - - - + public virtual ICollection ExamHistory { get; set; } } } diff --git a/VNH.Domain/Entities/NotificationDetail.cs b/VNH.Domain/Entities/NotificationDetail.cs index 143b3db..a01e9b1 100644 --- a/VNH.Domain/Entities/NotificationDetail.cs +++ b/VNH.Domain/Entities/NotificationDetail.cs @@ -15,8 +15,10 @@ public class NotificationDetail public Guid Id { get; set; } public Guid NotificationId { get; set; } public Guid UserId { get; set; } + public Guid? IdObject { get; set; } public string? Content { get; set; } public DateTime Date { get; set; } + public string? Url { get; set; } public Confirm IsRead { get; set; } diff --git a/VNH.Domain/Entities/Post.cs b/VNH.Domain/Entities/Post.cs index 55eac0e..93714b1 100644 --- a/VNH.Domain/Entities/Post.cs +++ b/VNH.Domain/Entities/Post.cs @@ -20,7 +20,7 @@ public Post() [Key] [StringLength(255)] public string Id { get; set; } - [StringLength(300)] + [StringLength(500)] public string SubId { get; set; } = string.Empty; [StringLength(255)] public string Title { get; set; } diff --git a/VNH.Domain/Entities/Question.cs b/VNH.Domain/Entities/Question.cs index 795e5b1..a00a004 100644 --- a/VNH.Domain/Entities/Question.cs +++ b/VNH.Domain/Entities/Question.cs @@ -17,7 +17,6 @@ public Question() [Key] public Guid Id { get; set; } - [StringLength(500)] public string Title { get; set; } public string SubId { get; set; } public string Content { get; set; } diff --git a/VNH.Infrastructure/DependencyInjectionInfrastructure.cs b/VNH.Infrastructure/DependencyInjectionInfrastructure.cs index 5e07495..7aa7ad0 100644 --- a/VNH.Infrastructure/DependencyInjectionInfrastructure.cs +++ b/VNH.Infrastructure/DependencyInjectionInfrastructure.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using VNH.Application.Services.Catalog.Users; @@ -38,6 +37,8 @@ using VNH.Infrastructure.Implement.Catalog.ExamHistorys; using VNH.Application.Interfaces.Catalog.NewsHistory; using VNH.Infrastructure.Implement.Catalog.NewsHistory; +using VNH.Application.Implement.Catalog.NotificationServices; +using VNH.Infrastructure.Implement.Catalog.NotificationServices; namespace VNH.Infrastructure { @@ -127,6 +128,7 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); services.AddSignalR(); diff --git a/VNH.Infrastructure/Implement/Catalog/Documents/DocumentService.cs b/VNH.Infrastructure/Implement/Catalog/Documents/DocumentService.cs index de7a457..5fa1964 100644 --- a/VNH.Infrastructure/Implement/Catalog/Documents/DocumentService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Documents/DocumentService.cs @@ -14,6 +14,7 @@ using VNH.Infrastructure.Implement.Common; using DocumentFormat.OpenXml.Office2010.Excel; using VNH.Application.DTOs.Catalog.Posts; +using VNH.Application.DTOs.Common; namespace VNH.Infrastructure.Implement.Catalog.Documents { @@ -78,25 +79,23 @@ public async Task> Update(CreateDocumentDto reques { var user = await _userManager.FindByEmailAsync(name); - var updateDocument = _dataContext.Documents - .FirstOrDefault(x => x.SubId.Equals(requestDto.SubId)); + var updateDocument = _dataContext.Documents.FirstOrDefault(x => x.SubId.Equals(requestDto.SubId)); if (updateDocument is null) { return new ApiErrorResult("Lỗi :Tài liệu không được cập nhập (không tìm thấy tài liệu)"); } - if (updateDocument.FileName != string.Empty) - { - await _storageService.DeleteDocFileAsync(updateDocument.FileName); - } updateDocument.Title = requestDto.Title; string formattedDateTime = DateTime.Now.ToString("HHmmss.fff") + HandleCommon.GenerateRandomNumber().ToString(); var Id = HandleCommon.SanitizeString(updateDocument.Title); updateDocument.SubId = Id.Trim().Replace(" ", "-") + "-" + formattedDateTime; - updateDocument.FilePath = await _document.SaveFile(requestDto.FileName, updateDocument.SubId); + if (requestDto.FileName is not null) + { + await _storageService.DeleteDocFileAsync(updateDocument.FileName); + updateDocument.FilePath = await _document.SaveFile(requestDto.FileName, updateDocument.SubId); + } updateDocument.UpdatedAt = DateTime.Now; updateDocument.Description = requestDto.Description; updateDocument.FileName = updateDocument.SubId; - try { _dataContext.Documents.Update(updateDocument); @@ -159,16 +158,21 @@ public async Task> Detail(string Id) } var user = await _userManager.FindByIdAsync(document .UserId.ToString()); + var documentResponse = _mapper.Map(document); documentResponse.FileName = document.FileName; - documentResponse - .UserShort = new() + + documentResponse.ViewNumber += 1; + document.ViewNumber += 1; + + documentResponse.UserShort = new() { FullName = user.Fullname, Id = user.Id, Image = user.Image }; + _dataContext.Documents.Update(document); await _dataContext.SaveChangesAsync(); return new ApiSuccessResult(documentResponse); } @@ -193,20 +197,25 @@ await _storageService.DeleteFileAsync(document.FileName return new ApiSuccessResult("Đã xóa tài liệu"); } - public async Task> GetSave(DocumentFpkDto docsFpk) + public async Task> GetSave(DocumentFpkDto docsFpk) { var docs = _dataContext.Documents.First(x => x.SubId.Equals(docsFpk.DocumentId)); var check = await _dataContext.DocumentSaves.Where(x => x.DocumentId.Equals(docs.Id) && x.UserId == Guid.Parse(docsFpk.UserId)).FirstOrDefaultAsync(); - var reuslt = check != null; - return new ApiSuccessResult(reuslt); + var numberSave = await _dataContext.DocumentSaves.Where(x => x.DocumentId.Equals(docs.Id)).CountAsync(); + + if (check != null) + { + return new ApiSuccessResult(new() { Check = true, Quantity = numberSave }); + } + return new ApiSuccessResult(new() { Check = false, Quantity = numberSave}); } - public async Task> AddOrRemoveSaveDocs(DocumentFpkDto docsFpk) + public async Task> AddOrRemoveSaveDocs(DocumentFpkDto docsFpk) { var docs = await _dataContext.Documents.FirstOrDefaultAsync(x => x.SubId.Equals(docsFpk.DocumentId)); if (docs is null) { - return new ApiErrorResult("Không tìm thấy bài viết"); + return new ApiErrorResult("Không tìm thấy bài viết"); } var check = _dataContext.DocumentSaves.Where(x => x.DocumentId == docs.Id && x.UserId == Guid.Parse(docsFpk.UserId)).FirstOrDefault(); var mess = ""; @@ -221,13 +230,13 @@ public async Task> AddOrRemoveSaveDocs(DocumentFpkDto docsFpk) }; _dataContext.DocumentSaves.Add(save); await _dataContext.SaveChangesAsync(); - return new ApiSuccessResult(saveNumber+1); + return new ApiSuccessResult(new() { Check = true, Quantity = saveNumber + 1 }); } else { _dataContext.DocumentSaves.Remove(check); await _dataContext.SaveChangesAsync(); - return new ApiSuccessResult(saveNumber-1); + return new ApiSuccessResult(new() { Check = false, Quantity = saveNumber - 1 }); } @@ -248,10 +257,12 @@ orderby matchCount descending select new Document() { Id = document.Id, + UserId = document.UserId, SubId = document.SubId, Title = document.Title, CreatedAt = document.CreatedAt, UpdatedAt = document.UpdatedAt, + Description = document.Description }; foreach (var document in result) @@ -311,5 +322,18 @@ select post } return new ApiSuccessResult>(result); } + + public async Task SaveDownloads(Guid documentId) + { + var document = await _dataContext.Documents.FirstOrDefaultAsync(x=>!x.IsDeleted && x.Id == documentId); + if(document is null) + { + return; + } + + document.ViewNumber += 1; + _dataContext.Documents.Update(document); + await _dataContext.SaveChangesAsync(); + } } } diff --git a/VNH.Infrastructure/Implement/Catalog/ExamHistorys/ExamHistoryService.cs b/VNH.Infrastructure/Implement/Catalog/ExamHistorys/ExamHistoryService.cs index ca2efba..1046bcf 100644 --- a/VNH.Infrastructure/Implement/Catalog/ExamHistorys/ExamHistoryService.cs +++ b/VNH.Infrastructure/Implement/Catalog/ExamHistorys/ExamHistoryService.cs @@ -36,13 +36,18 @@ public ExamHistoryService(UserManager userManager, VietNamHistoryContext d public async Task> Create(CreateExamHistoryDto requestDto,string name) { var user = await _userManager.FindByEmailAsync(name); + var check = await _dataContext.ExamHistories.Where(x => x.UserId.Equals(user.Id) && x.MultipleChoiceId == requestDto.MultipleChoiceId ).FirstOrDefaultAsync(); + if (check != null) + { + return await Update(requestDto, name); + } var examhistory = _mapper.Map(requestDto); var multiples = await _dataContext.MultipleChoices.FirstOrDefaultAsync(x => x.Id.Equals(requestDto.MultipleChoiceId)); examhistory.Id = Guid.NewGuid(); examhistory.MultipleChoiceId = requestDto.MultipleChoiceId; examhistory.UserId = requestDto.UserId; examhistory.StarDate = requestDto.StarDate; - examhistory.Scores = requestDto.Scores; + examhistory.Scores = float.Parse(requestDto.Scores.ToString()); examhistory.CompletionTime = requestDto.CompletionTime; try { @@ -72,31 +77,25 @@ public async Task> Create(CreateExamHistoryDt } }; - - return new ApiSuccessResult(response); - - + return new ApiSuccessResult(response); } catch (Exception ex) { - return new ApiErrorResult("Có lỗi xãy ra : " + ex.Message); - + return new ApiErrorResult("Có lỗi xảy ra : " + ex.Message); } - - } - public async Task> Update(CreateExamHistoryDto requestDto,string name) + public async Task> Update(CreateExamHistoryDto requestDto,string name) { var user = await _userManager.FindByEmailAsync(name); - var updateExamHistory = _dataContext.ExamHistories.First(x => x.Id.Equals(requestDto.Id)); + var updateExamHistory = await _dataContext.ExamHistories.FirstOrDefaultAsync(x => x.MultipleChoiceId.Equals(requestDto.MultipleChoiceId) && x.UserId.Equals(requestDto.UserId)); if (updateExamHistory is null) { - return new ApiErrorResult("Có lỗi xảy ra !!!"); + return new ApiErrorResult("Có lỗi xảy ra khi cập nhập kết quả!"); } updateExamHistory.StarDate = DateTime.Now; - updateExamHistory.Scores = requestDto.Scores; + updateExamHistory.Scores = float.Parse(requestDto.Scores.ToString()); updateExamHistory.CompletionTime = requestDto.CompletionTime; try @@ -105,14 +104,11 @@ public async Task> Update(CreateExamHistoryDto requestDto,stri await _dataContext.SaveChangesAsync(); var response = _mapper.Map(updateExamHistory); - return new ApiSuccessResult("Lưu Thành công !!!"); - + return new ApiSuccessResult(response); } catch (Exception ex) { - - return new ApiErrorResult("Lỗi : " + ex.Message); - + return new ApiErrorResult("Lỗi : " + ex.Message); } } @@ -120,40 +116,69 @@ public async Task> Update(CreateExamHistoryDto requestDto,stri public async Task>> GetMyExamHistory(string id) { Guid userId = Guid.Parse(id); - var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); - var examHistories = await( - from examhis in _dataContext.ExamHistories - join ex in _dataContext.ExamHistories on examhis.UserId equals userId - where examhis.UserId == userId - select ex - ).ToListAsync(); - - + var user = await _dataContext.User.Where(x => !x.IsDeleted && x.Id == userId).FirstOrDefaultAsync(); + if(user == null) + { + return new ApiErrorResult>("Tài khoản không tồn tại"); + } + var examHistories = await _dataContext.ExamHistories.Where(x=>x.UserId.Equals(userId)).ToListAsync(); + //var examHistories = await ( + // from examhis in _dataContext.ExamHistories + // join ex in _dataContext.ExamHistories on examhis.UserId equals userId + // where examhis.UserId == userId + // select ex + // ).ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); var result = new List(); foreach(var item in examHistories) { - var exs = _mapper.Map(item); - var userShort = users.First(x=>x.Id == item.UserId); + var examhistory = _mapper.Map(item); + var userShort = users.FirstOrDefault(x=>x.Id == item.UserId); var multis = await _dataContext.MultipleChoices.FirstOrDefaultAsync(x => x.Id.Equals(item.MultipleChoiceId)); - var rsp = _mapper.Map(multis); + + var exam = _mapper.Map(multis); if (userShort is not null) { - exs.UserShortDto.FullName = userShort.Fullname; - exs.UserShortDto.Id = userShort.Id; - exs.UserShortDto.Image = userShort.Image; + examhistory.UserShortDto.FullName = userShort.Fullname; + examhistory.UserShortDto.Id = userShort.Id; + examhistory.UserShortDto.Image = userShort.Image; } - exs.multipleChoiceResponseDto = rsp; - - - result.Add(exs); - + examhistory.numberQuiz = await _dataContext.Quizzes.Where(x=>x.MultipleChoiceId == multis.Id).CountAsync(); + examhistory.multipleChoiceResponseDto = exam; + result.Add(examhistory); } return new ApiSuccessResult>(result); } + public async Task>> GetExamHistory(string examId) + { + var examhistories = await _dataContext.ExamHistories.Where(x => x.MultipleChoiceId.ToString().Equals(examId)).ToListAsync(); + + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); + var result = new List(); + foreach (var item in examhistories) + { + var examhistory = _mapper.Map(item); + var userShort = users.FirstOrDefault(x => x.Id == item.UserId); + var multis = await _dataContext.MultipleChoices.FirstOrDefaultAsync(x => x.Id.Equals(item.MultipleChoiceId)); + var exam = _mapper.Map(multis); + if (userShort is not null) + { + examhistory.UserShortDto.FullName = userShort.Fullname; + examhistory.UserShortDto.Id = userShort.Id; + examhistory.UserShortDto.Image = userShort.Image; + } + examhistory.numberQuiz = await _dataContext.Quizzes.Where(x => x.MultipleChoiceId == multis.Id).CountAsync(); + examhistory.multipleChoiceResponseDto = exam; + + result.Add(examhistory); + } + + return new ApiSuccessResult>(result); + } } } diff --git a/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs b/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs index d44516d..ade44e5 100644 --- a/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs @@ -1,11 +1,16 @@ using AutoMapper; +using DocumentFormat.OpenXml.Office2010.Excel; +using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; +using VNH.Application.Common.Contants; using VNH.Application.DTOs.Catalog.Forum.Answer; +using VNH.Application.DTOs.Catalog.Notifications; using VNH.Application.DTOs.Catalog.Users; using VNH.Application.DTOs.Common; using VNH.Application.DTOs.Common.ResponseNotification; +using VNH.Application.Implement.Catalog.NotificationServices; using VNH.Application.Interfaces.Catalog.Forum; using VNH.Domain; using VNH.Infrastructure.Presenters; @@ -19,16 +24,16 @@ public class AnswerService : IAnswerService private readonly VietNamHistoryContext _dataContext; private readonly IHubContext _answerHubContext; private readonly IMapper _mapper; - + private readonly INotificationService _notificationService; public AnswerService(UserManager userManager, IHubContext answerHubContext, - IMapper mapper, - VietNamHistoryContext vietNamHistoryContext) + IMapper mapper, VietNamHistoryContext vietNamHistoryContext, INotificationService notificationService) { _userManager = userManager; _dataContext = vietNamHistoryContext; _mapper = mapper; _answerHubContext = answerHubContext; + _notificationService = notificationService; } private UserShortDto? GetUserShort(List users, Guid? IdUser) @@ -111,7 +116,7 @@ public async Task>> GetAnswer(string questionI - public async Task>> CreateAnswer(AnswerQuestionDto answer) + public async Task>> CreateAnswer(AnswerQuestionDto answer, string? id) { var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(answer.QuestionId)) && !x.IsDeleted); if (question == null) @@ -121,10 +126,23 @@ public async Task>> CreateAnswer(AnswerQuestio Answer answerQuestion = _mapper.Map(answer); answerQuestion.QuestionId = question.Id; - answerQuestion.CreatedAt = DateTime.Now; + _dataContext.Answers.Add(answerQuestion); await _dataContext.SaveChangesAsync(); + var user = await _dataContext.User.FirstOrDefaultAsync(x => x.Id.ToString().Equals(id) && !x.IsDeleted); + var noti = new NotificationDto() + { + Id = Guid.NewGuid(), + UserId = user.Id, + IdObject = question.Id, + Content = ConstantNofication.AnswerTheQuestion(user?.Fullname ?? ""), + Date = DateTime.Now, + Url = ConstantUrl.UrlQuestionDetail, + NotificationId = Guid.NewGuid() + }; + await _notificationService.AddNotificationDetail(noti); + var answers = await GetAnswer(answer.QuestionId); await _answerHubContext.Clients.All.SendAsync("ReceiveAnswer", answers); @@ -192,7 +210,6 @@ public async Task> CreateSubAnswer(SubAnswerQuestionDto subAns } SubAnswer sub = _mapper.Map(subAnswer); sub.PreAnswerId = answer.Id; - sub.CreatedAt = DateTime.Now; _dataContext.SubAnswers.Add(sub); await _dataContext.SaveChangesAsync(); @@ -287,6 +304,21 @@ public async Task> VoteConfirmByUser(AnswerFpkDto answe AnswerId = Guid.Parse(answer.AnswerId), UserId = Guid.Parse(answer.UserId) }; + + var ans = await _dataContext.Answers.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id.ToString() == answer.AnswerId); + var user = await _dataContext.User.FirstOrDefaultAsync(x => x.Id.ToString().Equals(ans.AuthorId) && !x.IsDeleted); + var noti = new NotificationDto() + { + Id = Guid.NewGuid(), + UserId = user.Id, + IdObject = Guid.Parse(answer.QuestionId), + Content = ConstantNofication.CommentAnswer(user?.Fullname ?? ""), + Date = DateTime.Now, + Url = ConstantUrl.UrlQuestionDetail, + NotificationId = Guid.NewGuid() + }; + await _notificationService.AddNotificationDetail(noti); + _dataContext.AnswerVotes.Add(answerVote); await _dataContext.SaveChangesAsync(); var numberVote = await _dataContext.AnswerVotes.Where(x => x.AnswerId == Guid.Parse(answer.AnswerId)).CountAsync(); diff --git a/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs b/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs index df1cdf7..d1ec637 100644 --- a/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs @@ -1,11 +1,16 @@ using AutoMapper; +using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Hosting; using Microsoft.IdentityModel.Tokens; +using VNH.Application.Common.Contants; using VNH.Application.DTOs.Catalog.Forum.Question; +using VNH.Application.DTOs.Catalog.Notifications; using VNH.Application.DTOs.Catalog.Posts; using VNH.Application.DTOs.Common; using VNH.Application.DTOs.Common.ResponseNotification; +using VNH.Application.Implement.Catalog.NotificationServices; using VNH.Application.Interfaces.Catalog.Forum; using VNH.Domain; using VNH.Infrastructure.Implement.Common; @@ -18,15 +23,17 @@ public class QuestionService : IQuestionService private readonly UserManager _userManager; private readonly VietNamHistoryContext _dataContext; + private readonly INotificationService _notificationService; private readonly IMapper _mapper; public QuestionService(UserManager userManager, - IMapper mapper, + IMapper mapper, INotificationService notificationService, VietNamHistoryContext vietNamHistoryContext) { _userManager = userManager; _dataContext = vietNamHistoryContext; _mapper = mapper; + _notificationService = notificationService; } @@ -167,7 +174,7 @@ public async Task> Detail(string Id) question.ViewNumber += 1; questionResponse.ViewNumber += 1; questionResponse.SaveNumber = await _dataContext.QuestionSaves.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); - questionResponse.CommentNumber = await _dataContext.Answers.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); + questionResponse.CommentNumber = await _dataContext.Answers.Where(x => x.QuestionId.Equals(question.Id) && !x.IsDeleted).CountAsync(); questionResponse.LikeNumber = await _dataContext.QuestionLikes.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); _dataContext.Questions.Update(question); @@ -184,7 +191,7 @@ public async Task>> GetAll() foreach (var item in questions) { var question = _mapper.Map(item); - question.CommentNumber = await _dataContext.Answers.Where(x => x.QuestionId.ToString() == question.Id).CountAsync(); + question.CommentNumber = await _dataContext.Answers.Where(x => x.QuestionId.ToString() == question.Id && !x.IsDeleted).CountAsync(); question.SaveNumber = await _dataContext.QuestionSaves.Where(x => x.QuestionId.ToString() == question.Id).CountAsync(); question.LikeNumber = await _dataContext.QuestionLikes.Where(x => x.QuestionId.ToString() == question.Id).CountAsync(); @@ -248,7 +255,7 @@ public async Task> AddOrRemoveSaveQuestion(QuestionFpkD } - public async Task> GetSave(QuestionFpkDto questionFpk) + public async Task> GetSave(QuestionFpkDto questionFpk) { var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(questionFpk.QuestionId)) && !x.IsDeleted); var number = await _dataContext.QuestionSaves.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); @@ -355,12 +362,25 @@ public async Task> AddOrUnLikeQuestion(QuestionFpkDto q var likeNumber = await _dataContext.QuestionLikes.Where(x => x.QuestionId == question.Id).CountAsync(); if (check is null) { + var user = await _dataContext.User.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == question.AuthorId); var like = new QuestionLike() { Id = Guid.NewGuid(), QuestionId = question.Id, UserId = Guid.Parse(questionFpk.UserId) }; + var noti = new NotificationDto() + { + Id = Guid.NewGuid(), + UserId = question.AuthorId ?? Guid.NewGuid(), + IdObject = question.Id, + Content = ConstantNofication.LikeQuestion(user?.Fullname ?? ""), + Date = DateTime.Now, + Url = ConstantUrl.UrlQuestionDetail, + NotificationId = Guid.NewGuid() + }; + await _notificationService.AddNotificationDetail(noti); + _dataContext.QuestionLikes.Add(like); await _dataContext.SaveChangesAsync(); return new ApiSuccessResult(new() { Check = true, Quantity = likeNumber + 1 }); @@ -377,6 +397,7 @@ public async Task> AddOrUnLikeQuestion(QuestionFpkDto q public async Task>> GetMyQuestion(string id) { var questions = await _dataContext.Questions.Where(x => x.AuthorId.Equals(Guid.Parse(id)) && !x.IsDeleted).ToListAsync(); + var user = await _dataContext.User.Where(x => !x.IsDeleted && x.Id.ToString().Equals(id)).FirstOrDefaultAsync(); var result = new List(); foreach (var item in questions) { @@ -384,6 +405,12 @@ public async Task>> GetMyQuestion(string id) question.SaveNumber = await _dataContext.QuestionSaves.Where(x => x.QuestionId.Equals(item.Id)).CountAsync(); question.CommentNumber = await _dataContext.Answers.Where(x => x.QuestionId.Equals(item.Id)).CountAsync(); question.LikeNumber = await _dataContext.QuestionLikes.Where(x => x.QuestionId.Equals(item.Id)).CountAsync(); + if (user is not null) + { + question.UserShort.FullName = user.Fullname; + question.UserShort.Id = user.Id; + question.UserShort.Image = user.Image; + } result.Add(question); } @@ -459,18 +486,18 @@ orderby matchCount descending item.UserShort.Image = userShort.Image; } questions.Add(item); - } + } return new ApiSuccessResult>(questions); } public async Task>> GetMyQuestionSaved(string id) { Guid userId = Guid.Parse(id); - var users = await _dataContext.User.ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); var questions = await( from questionSave in _dataContext.QuestionSaves - join question in _dataContext.Questions on questionSave.QuestionId equals question.Id + join question in _dataContext.Questions.Where(x=>!x.IsDeleted) on questionSave.QuestionId equals question.Id where questionSave.UserId == userId select question ).ToListAsync(); @@ -486,9 +513,9 @@ select question question.UserShort.Id = userShort.Id; question.UserShort.Image = userShort.Image; } - question.SaveNumber = await _dataContext.QuestionSaves.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); - question.CommentNumber = await _dataContext.Answers.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); - question.LikeNumber = await _dataContext.QuestionLikes.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); + question.SaveNumber = await _dataContext.QuestionSaves.Where(x => x.QuestionId.Equals(item.Id)).CountAsync(); + question.CommentNumber = await _dataContext.Answers.Where(x => x.QuestionId.Equals(item.Id) && !x.IsDeleted).CountAsync(); + question.LikeNumber = await _dataContext.QuestionLikes.Where(x => x.QuestionId.Equals(item.Id)).CountAsync(); result.Add(question); } diff --git a/VNH.Infrastructure/Implement/Catalog/MultipleChoices/MultipleChoiceService.cs b/VNH.Infrastructure/Implement/Catalog/MultipleChoices/MultipleChoiceService.cs index ff93fb4..fbd54d4 100644 --- a/VNH.Infrastructure/Implement/Catalog/MultipleChoices/MultipleChoiceService.cs +++ b/VNH.Infrastructure/Implement/Catalog/MultipleChoices/MultipleChoiceService.cs @@ -37,7 +37,7 @@ public MultipleChoiceService(UserManager userManager, VietNamHistoryContex _mapper = mapper; } - public async Task> Create(CreateQuizDto requestDto,string name) + public async Task> Create(CreateQuizDto requestDto, string name) { var user = await _userManager.FindByEmailAsync(name); var multipleChoice = new MultipleChoice(); @@ -51,7 +51,7 @@ public async Task> Create(CreateQuizDto requestDto,string name { _dataContext.MultipleChoices.Add(multipleChoice); await _dataContext.SaveChangesAsync(); - foreach(var quiestion in quiz) + foreach (var quiestion in quiz) { var quizz = new Quiz() { @@ -70,19 +70,19 @@ public async Task> Create(CreateQuizDto requestDto,string name QuizId = quizz.Id, isCorrect = quizanswer.isCorrect }; - + _dataContext.QuizAnswers.Add(answer); } } await _dataContext.SaveChangesAsync(); return new ApiSuccessResult("Tạo thành công"); } - catch(Exception ex) + catch (Exception ex) { return new ApiErrorResult("Lỗi lưu : " + ex.Message); } - + } @@ -268,32 +268,32 @@ public async Task> Detail(string id) } var user = await _userManager.FindByIdAsync(multipleChoice.UserId.ToString()); var response = _mapper.Map(multipleChoice); - var quizs = await _dataContext.Quizzes.Where(x=>x.MultipleChoiceId.Equals(Guid.Parse(id))).ToListAsync(); + var quizs = await _dataContext.Quizzes.Where(x => x.MultipleChoiceId.Equals(Guid.Parse(id))).ToListAsync(); response.WorkTime = multipleChoice.WorkTime; - + foreach (var quiz in quizs) { var quizanswers = await _dataContext.QuizAnswers.Where(x => x.QuizId.Equals(quiz.Id)).ToListAsync(); - + response.Quizs.Add(new() - { - Id = quiz.Id, - Content = quiz.Content, - QuizAnswers = _mapper.Map>(quizanswers), - - }); - - - - + { + Id = quiz.Id, + Content = quiz.Content, + QuizAnswers = _mapper.Map>(quizanswers), + + }); + + + + } - foreach(var item in response.Quizs) + foreach (var item in response.Quizs) { var quizanswers = await _dataContext.QuizAnswers.Where(x => x.QuizId.Equals(item.Id)).ToListAsync(); - + } - + response.UserShort = new() { FullName = user.Fullname, @@ -301,12 +301,12 @@ public async Task> Detail(string id) Image = user.Image, }; return new ApiSuccessResult(response); - } + } public async Task>> GetAll() { - var list = await _dataContext.MultipleChoices.OrderByDescending(x=> x.CreatedAt).ToListAsync(); + var list = await _dataContext.MultipleChoices.OrderByDescending(x => x.CreatedAt).ToListAsync(); var users = await _dataContext.User.ToListAsync(); var quizlist = await _dataContext.Quizzes.ToListAsync(); var quizanswerList = await _dataContext.QuizAnswers.ToListAsync(); @@ -316,25 +316,27 @@ public async Task>> GetAll() foreach (var item in list) { var multi = _mapper.Map(item); - var userShort = users.First(x=> x.Id == item.UserId); - if(userShort is not null) + multi.NumberQuiz = quizlist.Where(x => x.MultipleChoiceId.Equals(item.Id)).Count(); + var userShort = users.First(x => x.Id == item.UserId); + if (userShort is not null) { multi.UserShort.FullName = userShort.Fullname; multi.UserShort.Id = userShort.Id; multi.UserShort.Image = userShort.Image; } + result.Add(multi); - + } return new ApiSuccessResult>(result); } - public async Task> Update(CreateQuizDto requestDto,string name) + public async Task> Update(CreateQuizDto requestDto, string name) { var user = await _userManager.FindByEmailAsync(name); - var updateMultipleChoice = _dataContext.MultipleChoices.First(x => x.Id.Equals(Guid.Parse(requestDto.Id))); - if(updateMultipleChoice is null) + var updateMultipleChoice = await _dataContext.MultipleChoices.FirstOrDefaultAsync(x => x.Id == Guid.Parse(requestDto.Id)); + if (updateMultipleChoice is null) { return new ApiErrorResult("Lỗi :Không được cập nhập (không tìm thấy bài thi nào)"); } @@ -344,11 +346,11 @@ public async Task> Update(CreateQuizDto requestDto,string name updateMultipleChoice.UpdatedAt = DateTime.Now; try { - _dataContext.MultipleChoices.Update(updateMultipleChoice); + _dataContext.MultipleChoices.Update(updateMultipleChoice); await _dataContext.SaveChangesAsync(); return new ApiSuccessResult("Cập nhập bài thi thành công"); } - catch(Exception ex) + catch (Exception ex) { return new ApiErrorResult("Lỗi lưu bài thi : " + ex.Message); @@ -358,16 +360,16 @@ public async Task> Update(CreateQuizDto requestDto,string name public async Task> UpdateQuizById(QuizDto requestDto) { - var updateQuiz = _dataContext.Quizzes.First(x => x.Id.Equals(requestDto.Id)); - if(updateQuiz is null) + var updateQuiz = _dataContext.Quizzes.First(x => x.Id.Equals(requestDto.Id)); + if (updateQuiz is null) { return new ApiErrorResult("Lỗi :Không được cập nhập (không tìm thấy câu hỏi nào)"); } updateQuiz.Content = requestDto.Content; - foreach(var item in requestDto.QuizAnswers) + foreach (var item in requestDto.QuizAnswers) { - var updateQuizAnswer = _dataContext.QuizAnswers.First(x=>x.Id.Equals(item.Id)); - if(updateQuizAnswer != null) + var updateQuizAnswer = _dataContext.QuizAnswers.First(x => x.Id.Equals(item.Id)); + if (updateQuizAnswer != null) { updateQuizAnswer.Content = item.Content; updateQuizAnswer.isCorrect = item.isCorrect; @@ -383,7 +385,7 @@ public async Task> UpdateQuizById(QuizDto requestDto) return new ApiSuccessResult(response); } - catch(Exception ex) { + catch (Exception ex) { return new ApiErrorResult("Lỗi lưu câu hỏi : " + ex.Message); } @@ -392,64 +394,106 @@ public async Task> UpdateQuizById(QuizDto requestDto) public async Task> Delete(string id, string userId) { - var multiple = await _dataContext.MultipleChoices.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id)) && x.UserId.Equals(Guid.Parse(userId))); - if(multiple is null) + var multiple = await _dataContext.MultipleChoices + .FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id)) && x.UserId.Equals(Guid.Parse(userId))); + + if (multiple is null) { return new ApiErrorResult("Không tìm thấy bài thi"); } - var quizs = await _dataContext.Quizzes.ToListAsync(); - var quizsAnswer = await _dataContext.QuizAnswers.ToListAsync(); - foreach(var item in quizs) + var multipleChoiceId = multiple.Id; + + // Xoá lịch sử bài thi + var examHistoriesToDelete = _dataContext.ExamHistories + .Where(x => x.MultipleChoiceId == multipleChoiceId) + .ToList(); + + if (examHistoriesToDelete.Any()) { - if(item.MultipleChoiceId.Equals(id)) - { - foreach(var item1 in quizsAnswer) - { - if(item1.QuizId.Equals(item.Id)) - { - _dataContext.QuizAnswers.Remove(item1); - await _dataContext.SaveChangesAsync(); - } - } - _dataContext.Quizzes.Remove(item); - await _dataContext.SaveChangesAsync(); - } + _dataContext.ExamHistories.RemoveRange(examHistoriesToDelete); } + // Xoá câu trả lời của từng câu hỏi + var quizIdsToDelete = _dataContext.Quizzes + .Where(x => x.MultipleChoiceId.Equals(multipleChoiceId)) + .Select(x => x.Id) + .ToList(); + + var quizAnswerToDelete = _dataContext.QuizAnswers + .Where(x => quizIdsToDelete.Contains(x.QuizId)) + .ToList(); + + if (quizAnswerToDelete.Any()) + { + _dataContext.QuizAnswers.RemoveRange(quizAnswerToDelete); + } + + // Xoá câu hỏi + var quizzesToDelete = _dataContext.Quizzes + .Where(x => x.MultipleChoiceId.Equals(multipleChoiceId)) + .ToList(); + + if (quizzesToDelete.Any()) + { + _dataContext.Quizzes.RemoveRange(quizzesToDelete); + } + + // Xoá bài thi _dataContext.MultipleChoices.Remove(multiple); + + // Lưu thay đổi vào cơ sở dữ liệu await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult("Xoá bài thi thành công"); - } + } + public async Task> DeleteQuizById(string id) { - var quiz = await _dataContext.Quizzes.FirstOrDefaultAsync(x=>x.Id.Equals(Guid.Parse(id))); - if(quiz == null) + var quiz = await _dataContext.Quizzes.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id))); + if (quiz == null) { return new ApiErrorResult("Không tìm thấy câu hỏi"); } var quizanswers = await _dataContext.QuizAnswers.ToListAsync(); - foreach(var item in quizanswers) + foreach (var item in quizanswers) { - if(item.QuizId.Equals(id)) + if (item.QuizId.Equals(id)) { _dataContext.QuizAnswers.Remove(item); await _dataContext.SaveChangesAsync(); } } _dataContext.Quizzes.Remove(quiz); - await _dataContext.SaveChangesAsync(); + await _dataContext.SaveChangesAsync(); return new ApiSuccessResult("Xoá câu hỏi thành công"); } + public async Task>> GetMyMultipleChoice(string id) + { + var list = await _dataContext.MultipleChoices.Where(x => x.UserId.Equals(Guid.Parse(id)) ).ToListAsync(); + + var result = new List(); + var user = await _dataContext.User.Where(x => !x.IsDeleted && x.Id.ToString().Equals(id)).FirstOrDefaultAsync(); + foreach( var item in list) + { + var multi = _mapper.Map(item); + + result.Add(multi); + } + return new ApiSuccessResult>(result); + + } + + public async Task>> Search(string keyWord) { var multiples = new List(); - var users = await _dataContext.Users.ToListAsync(); - string[] searchKeywords = keyWord.ToLower().Split(','); + var users = await _dataContext.Users.Where(x=>!x.IsDeleted).ToListAsync(); + string[] searchKeywords = keyWord.ToLower().Split(' '); var result = from multiple in _dataContext.MultipleChoices as IEnumerable let titleWords = multiple.Title.ToLower().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) let searchPhrases = HandleCommon.GenerateSearchPhrases(searchKeywords) @@ -467,17 +511,23 @@ orderby matchCount descending WorkTime = multiple.WorkTime, UserId = multiple.UserId, }; - foreach(var multi in result) + + if(result.Count() > 0 ) { - var item = _mapper.Map(multi); - var userShort = users.First(x=>x.Id == multi.UserId); - if(userShort is not null) + var quizlist = await _dataContext.Quizzes.ToListAsync(); + foreach (var multi in result) { - item.UserShort.FullName = userShort.Fullname; - item.UserShort.Id = userShort.Id; - item.UserShort.Image = userShort.Image; + var item = _mapper.Map(multi); + var userShort = users.FirstOrDefault(x => x.Id == multi.UserId); + item.NumberQuiz = quizlist.Where(x => x.MultipleChoiceId.Equals(multi.Id)).Count(); + if (userShort is not null) + { + item.UserShort.FullName = userShort.Fullname; + item.UserShort.Id = userShort.Id; + item.UserShort.Image = userShort.Image; + } + multiples.Add(item); } - multiples.Add(item); } return new ApiSuccessResult>(multiples); diff --git a/VNH.Infrastructure/Implement/Catalog/NotificationServices/NotificationService.cs b/VNH.Infrastructure/Implement/Catalog/NotificationServices/NotificationService.cs new file mode 100644 index 0000000..c9593ea --- /dev/null +++ b/VNH.Infrastructure/Implement/Catalog/NotificationServices/NotificationService.cs @@ -0,0 +1,91 @@ +using AutoMapper; +using Microsoft.AspNetCore.SignalR; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.DTOs.Catalog.Notifications; +using VNH.Application.DTOs.Common.ResponseNotification; +using VNH.Application.Implement.Catalog.NotificationServices; +using VNH.Domain.Entities; +using VNH.Domain.Enums; +using VNH.Infrastructure.Presenters; +using VNH.Infrastructure.Presenters.Migrations; + +namespace VNH.Infrastructure.Implement.Catalog.NotificationServices +{ + public class NotificationService : INotificationService + { + private readonly VietNamHistoryContext _dataContext; + private readonly IHubContext _notiHubContext; + private readonly IMapper _mapper; + public NotificationService(VietNamHistoryContext vietNamHistoryContext, IHubContext chatSignalR, + IMapper mapper ) + { + _dataContext = vietNamHistoryContext; + _notiHubContext = chatSignalR; + _mapper = mapper; + } + public async Task> Add(string title) + { + var noti = new Notification() + { + Title = title, + Id = Guid.NewGuid(), + Date = DateTime.Now, + }; + _dataContext.Notifications.Add(noti); + await _dataContext.SaveChangesAsync(); + + return new ApiSuccessResult(new()); + } + + public async Task AddNotificationDetail(NotificationDto notification) + { + var noti = await _dataContext.Notifications.FirstOrDefaultAsync(); + if (noti == null) + { + return; + } + var notificationDetail = new NotificationDetail() + { + Id = Guid.NewGuid(), + NotificationId = noti.Id, + UserId = notification.UserId, + Content = notification.Content, + Url = notification.Url, + Date = DateTime.Now, + IsRead = Confirm.No, + IdObject = notification.IdObject + }; + + _dataContext.NotificationDetails.Add(notificationDetail); + await _dataContext.SaveChangesAsync(); + await _notiHubContext.Clients.Group(notification.UserId.ToString()).SendAsync("ReceiveNoti", notification); + } + + public async Task>> GetAll(string userId) + { + var notidetails = await _dataContext.NotificationDetails.Where(x => x.UserId == Guid.Parse(userId)).ToListAsync(); + if (notidetails.Any()) + { + List result = new(); + foreach (var item in notidetails) + { + var notificationDetail = new NotificationDto(); + notificationDetail = _mapper.Map(item); + result.Add(notificationDetail); + } + return new ApiSuccessResult>(result); + } + return new ApiSuccessResult>(new()); + } + + public Task> Update(NotificationDto notification) + { + throw new NotImplementedException(); + } + } +} diff --git a/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs b/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs index 3939e22..25e496c 100644 --- a/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs @@ -1,13 +1,18 @@ using AutoMapper; +using DocumentFormat.OpenXml.Spreadsheet; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.SignalR; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; +using VNH.Application.Common.Contants; +using VNH.Application.DTOs.Catalog.Notifications; using VNH.Application.DTOs.Catalog.Posts; using VNH.Application.DTOs.Catalog.Users; using VNH.Application.DTOs.Common; using VNH.Application.DTOs.Common.ResponseNotification; +using VNH.Application.Implement.Catalog.NotificationServices; using VNH.Application.Interfaces.Common; using VNH.Application.Interfaces.Posts; using VNH.Domain; @@ -26,10 +31,11 @@ public class PostService : IPostService private readonly IStorageService _storageService; private readonly IHubContext _commentHubContext; private readonly IMapper _mapper; + private readonly INotificationService _notificationService; public PostService(UserManager userManager, IMapper mapper, IImageService image, VietNamHistoryContext vietNamHistoryContext, IStorageService storageService, - IHubContext chatSignalR) + IHubContext chatSignalR, INotificationService notificationService) { _userManager = userManager; _mapper = mapper; @@ -37,6 +43,7 @@ public PostService(UserManager userManager, IMapper mapper, IImageService _dataContext = vietNamHistoryContext; _storageService = storageService; _commentHubContext = chatSignalR; + _notificationService = notificationService; } public async Task> Create(CreatePostDto requestDto, string name) { @@ -279,14 +286,27 @@ public async Task> AddOrUnLikePost(PostFpkDto postFpk) var likeNumber = await _dataContext.PostLikes.Where(x => x.PostId == post.Id).CountAsync(); if (check is null) { + var user = await _dataContext.User.FirstOrDefaultAsync(x => !x.IsDeleted && x.Id == Guid.Parse(postFpk.UserId)); var like = new PostLike() { Id = Guid.NewGuid(), PostId = post.Id, UserId = Guid.Parse(postFpk.UserId) }; + var noti = new NotificationDto() + { + Id = Guid.NewGuid(), + UserId = post.UserId, + IdObject = Guid.Parse(post.Id), + Content = ConstantNofication.LikePost(user?.Fullname ?? ""), + Date = DateTime.Now, + Url = ConstantUrl.UrlPostDetail, + NotificationId = Guid.NewGuid() + }; + _dataContext.PostLikes.Add(like); await _dataContext.SaveChangesAsync(); + await _notificationService.AddNotificationDetail(noti); return new ApiSuccessResult(new() { Check = true, Quantity = likeNumber + 1}); } else { @@ -460,7 +480,7 @@ public async Task>> GetComment(string postId) .FirstOrDefault(); } - public async Task>> CreateComment(CommentPostDto comment) + public async Task>> CreateComment(CommentPostDto comment, string userId) { var post = await _dataContext.Posts.FirstOrDefaultAsync(x=>x.SubId.Equals(comment.PostId) && !x.IsDeleted); if (post == null) @@ -470,6 +490,25 @@ public async Task>> CreateComment(CommentPostDto PostComment postComment = _mapper.Map(comment); postComment.PostId = post.Id; postComment.UpdatedAt = DateTime.Now; + + if (userId != post.UserId.ToString()) + { + var user = await _dataContext.User.FirstOrDefaultAsync(x => x.Id.ToString().Equals(userId) && !x.IsDeleted); + var noti = new NotificationDto() + { + Id = Guid.NewGuid(), + UserId = post.UserId, + IdObject = Guid.Parse(post.Id), + Content = ConstantNofication.CommentPost(user?.Fullname ?? ""), + Date = DateTime.Now, + Url = ConstantUrl.UrlPostDetail, + NotificationId = Guid.NewGuid() + }; + + await _notificationService.AddNotificationDetail(noti); + } + + _dataContext.PostComments.Add(postComment); await _dataContext.SaveChangesAsync(); var comments = await GetComment(comment.PostId); @@ -518,6 +557,7 @@ public async Task>> GetMyPostSaved(string id) { Guid userId = Guid.Parse(id); var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); + var topics = await _dataContext.Topics.ToListAsync(); var posts = await ( from postSave in _dataContext.PostSaves @@ -537,6 +577,7 @@ select post post.UserShort.Id = userShort.Id; post.UserShort.Image = userShort.Image; } + post.TopicName = topics.FirstOrDefault(x => x.Id == item.TopicId)?.Title ?? ""; result.Add(post); } return new ApiSuccessResult>(result); @@ -545,12 +586,22 @@ public async Task>> GetMyPost(string id) { var posts = await _dataContext.Posts.Where(x=>x.UserId.Equals(Guid.Parse(id)) && !x.IsDeleted).ToListAsync(); var result = new List(); + var topics = await _dataContext.Topics.ToListAsync(); + var user = await _dataContext.User.Where(x => !x.IsDeleted && x.Id.ToString().Equals(id)).FirstOrDefaultAsync(); + foreach (var item in posts) { var post = _mapper.Map(item); post.SaveNumber = await _dataContext.PostSaves.Where(x => x.PostId.Equals(post.Id)).CountAsync(); post.CommentNumber = await _dataContext.PostComments.Where(x => x.PostId.Equals(post.Id)).CountAsync(); post.LikeNumber = await _dataContext.PostLikes.Where(x => x.PostId.Equals(post.Id)).CountAsync(); + post.TopicName = topics.FirstOrDefault(x => x.Id == item.TopicId)?.Title ?? ""; + if (user is not null) + { + post.UserShort.FullName = user.Fullname; + post.UserShort.Id = user.Id; + post.UserShort.Image = user.Image; + } result.Add(post); } diff --git a/VNH.Infrastructure/Implement/Common/ImageService.cs b/VNH.Infrastructure/Implement/Common/ImageService.cs index e79e2e1..a7d84bc 100644 --- a/VNH.Infrastructure/Implement/Common/ImageService.cs +++ b/VNH.Infrastructure/Implement/Common/ImageService.cs @@ -12,6 +12,7 @@ namespace VNH.Infrastructure.Implement.Common public class ImageService : IImageService { private const string USER_CONTENT_FOLDER_NAME = "Images"; + private const string USER_IMAGE_FOLDER_NAME = "ArticleImages"; private readonly string URL = SystemConstants.UrlWeb; private readonly IStorageService _storageService; public ImageService(IStorageService storageService) @@ -25,6 +26,13 @@ public async Task SaveFile(IFormFile file) await _storageService.SaveFileAsync(file.OpenReadStream(), fileName); return URL + USER_CONTENT_FOLDER_NAME + "/" + fileName; } + public async Task SaveImageArticle(IFormFile file) + { + var originalFileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName?.Trim('"'); + var fileName = $"{Guid.NewGuid()}{Path.GetExtension(originalFileName)}"; + await _storageService.SaveImageFileAsync(file.OpenReadStream(), fileName); + return URL + USER_IMAGE_FOLDER_NAME + "/" + fileName; + } public string ConvertByteArrayToString(byte[]? byteArray, Encoding encoding) { return byteArray is not null ? Convert.ToBase64String(byteArray) : string.Empty; diff --git a/VNH.Infrastructure/Implement/Common/StorageService.cs b/VNH.Infrastructure/Implement/Common/StorageService.cs index 722a286..2e6420c 100644 --- a/VNH.Infrastructure/Implement/Common/StorageService.cs +++ b/VNH.Infrastructure/Implement/Common/StorageService.cs @@ -6,14 +6,17 @@ namespace VNH.Infrastructure.Implement.Common public class StorageService : IStorageService { private readonly string _userContentFolder; + private readonly string _userImageFolder; private readonly string _userDocFolder; private const string USER_CONTENT_FOLDER_NAME = "Images"; private const string USER_DOC_FOLDER_NAME = "Documents"; + private const string USER_IMAGE_FOLDER_NAME = "ArticleImages"; public StorageService(IWebHostEnvironment webHostEnvironment) { _userContentFolder = Path.Combine(webHostEnvironment.WebRootPath, USER_CONTENT_FOLDER_NAME); _userDocFolder = Path.Combine(webHostEnvironment.WebRootPath, USER_DOC_FOLDER_NAME); + _userImageFolder = Path.Combine(webHostEnvironment.WebRootPath, USER_IMAGE_FOLDER_NAME); } public string GetFileUrl(string fileName) @@ -27,6 +30,12 @@ public async Task SaveFileAsync(Stream mediaBinaryStream, string fileName) using var output = new FileStream(filePath, FileMode.Create); await mediaBinaryStream.CopyToAsync(output); } + public async Task SaveImageFileAsync(Stream mediaBinaryStream, string fileName) + { + var filePath = Path.Combine(_userImageFolder, fileName); + using var output = new FileStream(filePath, FileMode.Create); + await mediaBinaryStream.CopyToAsync(output); + } public async Task SaveDocFileAsync(Stream mediaBinaryStream, string fileName) { var filePath = Path.Combine(_userDocFolder, fileName); @@ -35,8 +44,7 @@ public async Task SaveDocFileAsync(Stream mediaBinaryStream, string fileName) } public async Task DeleteFileAsync(string fileName) { - string name = Path.GetFileName(new Uri(fileName).LocalPath); - var filePath = Path.Combine(_userContentFolder, name); + var filePath = Path.Combine(_userContentFolder, fileName); if (File.Exists(filePath)) { await Task.Run(() => File.Delete(filePath)); @@ -44,8 +52,7 @@ public async Task DeleteFileAsync(string fileName) } public async Task DeleteDocFileAsync(string fileName) { - string name = Path.GetFileName(new Uri(fileName).LocalPath); - var filePath = Path.Combine(_userDocFolder, name); + var filePath = Path.Combine(_userDocFolder, fileName); if (File.Exists(filePath)) { await Task.Run(() => File.Delete(filePath)); diff --git a/VNH.Infrastructure/Migrations/20231129161341_init.Designer.cs b/VNH.Infrastructure/Migrations/20231129161341_init.Designer.cs deleted file mode 100644 index 9448718..0000000 --- a/VNH.Infrastructure/Migrations/20231129161341_init.Designer.cs +++ /dev/null @@ -1,1877 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using VNH.Infrastructure.Presenters.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231129161341_init")] - partial class init - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.13") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("AppRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("UserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId"); - - b.ToTable("AppUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "RoleId"); - - b.ToTable("UserRoles", (string)null); - - b.HasData( - new - { - UserId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - RoleId = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575") - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId"); - - b.ToTable("AppUserTokens", (string)null); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Confirm") - .HasColumnType("bit"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("MostConfirm") - .HasColumnType("bit"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.HasIndex("QuestionId"); - - b.ToTable("Answer"); - }); - - modelBuilder.Entity("VNH.Domain.AnswerVote", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AnswerId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("AnswerId"); - - b.HasIndex("UserId"); - - b.ToTable("AnswerVote"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseName") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("nvarchar(max)"); - - b.Property("Image") - .HasColumnType("nvarchar(max)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Course"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseComment"); - }); - - modelBuilder.Entity("VNH.Domain.CourseRating", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Score") - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseRating"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseSave"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSubComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PreCommentId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseSubComment"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("FileName") - .HasColumnType("nvarchar(max)"); - - b.Property("SubId") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Document"); - }); - - modelBuilder.Entity("VNH.Domain.DocumentSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("DocumentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("DocumentId"); - - b.HasIndex("UserId"); - - b.ToTable("DocumentSave"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.Notification", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("Title") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Notification"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("IsRead") - .HasColumnType("int"); - - b.Property("NotificationId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("NotificationId"); - - b.HasIndex("UserId"); - - b.ToTable("NotificationDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PostId") - .IsRequired() - .HasColumnType("nvarchar(255)"); - - b.Property("TagId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("TagId"); - - b.ToTable("PostTags"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Image") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("QuizId") - .HasColumnType("uniqueidentifier"); - - b.Property("Time") - .HasColumnType("time"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.ToTable("Exercise"); - }); - - modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("ExerciseId") - .HasColumnType("uniqueidentifier"); - - b.Property("TestMark") - .HasColumnType("float"); - - b.Property("TestTime") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ExerciseId"); - - b.HasIndex("UserId"); - - b.ToTable("ExerciseDetail"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Description") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("ExerciseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UrlVideo") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.ToTable("Lesson"); - }); - - modelBuilder.Entity("VNH.Domain.News", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Image") - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("Url") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.ToTable("News"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.Property("Id") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Image") - .HasColumnType("nvarchar(max)"); - - b.Property("SubId") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("TopicId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("ViewNumber") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("TopicId"); - - b.HasIndex("UserId"); - - b.ToTable("Post"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostComment"); - }); - - modelBuilder.Entity("VNH.Domain.PostLike", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostLike"); - }); - - modelBuilder.Entity("VNH.Domain.PostReportDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Checked") - .HasColumnType("bit"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("ReportDate") - .HasColumnType("datetime2"); - - b.Property("ReportId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("ReportId"); - - b.HasIndex("UserId"); - - b.ToTable("PostReportDetail"); - }); - - modelBuilder.Entity("VNH.Domain.PostSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostSave"); - }); - - modelBuilder.Entity("VNH.Domain.PostSubComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PreCommentId"); - - b.HasIndex("UserId"); - - b.ToTable("PostSubComment"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("SubId") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("ViewNumber") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.ToTable("Question"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionLike", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionLike"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Checked") - .HasColumnType("bit"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("ReportDate") - .HasColumnType("datetime2"); - - b.Property("ReportId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("ReportId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionReportDetail"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionSave"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionTag", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("TagId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("TagId"); - - b.ToTable("QuestionTag"); - }); - - modelBuilder.Entity("VNH.Domain.Quiz", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Answer1") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer2") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer3") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer4") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Question") - .HasColumnType("nvarchar(max)"); - - b.Property("RightAnswer") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.ToTable("Quiz"); - }); - - modelBuilder.Entity("VNH.Domain.Report", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.ToTable("Report"); - - b.HasData( - new - { - Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1878), - Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", - Title = "Nội dung vi phạm quy định về quyền riêng tư" - }, - new - { - Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1890), - Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", - Title = "Nội dung xấu, xúc phạm, hay kỳ thị" - }, - new - { - Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1892), - Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", - Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" - }, - new - { - Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1894), - Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", - Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" - }, - new - { - Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1897), - Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", - Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" - }, - new - { - Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1899), - Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", - Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" - }, - new - { - Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1905), - Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", - Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" - }); - }); - - modelBuilder.Entity("VNH.Domain.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Roles"); - - b.HasData( - new - { - Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "c998aba1-7d62-483a-a82c-dffca027ed0e", - Name = "admin", - NormalizedName = "admin" - }, - new - { - Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "ae9a8b2b-7978-448e-a405-c884869f328d", - Name = "teacher", - NormalizedName = "teacher" - }, - new - { - Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "ed14ffc7-e2d5-4165-a466-43faa539db13", - Name = "student", - NormalizedName = "student" - }); - }); - - modelBuilder.Entity("VNH.Domain.Search", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Search"); - }); - - modelBuilder.Entity("VNH.Domain.SubAnswer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreAnswerId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.HasIndex("PreAnswerId"); - - b.ToTable("SubAnswer"); - }); - - modelBuilder.Entity("VNH.Domain.Tag", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.ToTable("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.ToTable("Topic"); - }); - - modelBuilder.Entity("VNH.Domain.TopicDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasColumnType("nvarchar(255)"); - - b.Property("TopicId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("TopicId"); - - b.ToTable("TopicDetail"); - }); - - modelBuilder.Entity("VNH.Domain.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("DateOfBirth") - .HasColumnType("datetime"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("Fullname") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Gender") - .HasColumnType("int"); - - b.Property("Image") - .HasMaxLength(3145728) - .HasColumnType("nvarchar(max)"); - - b.Property("Introduction") - .HasColumnType("nvarchar(max)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedUserName") - .HasColumnType("nvarchar(max)"); - - b.Property("NumberConfirm") - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("User"); - - b.HasData( - new - { - Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - AccessFailedCount = 0, - ConcurrencyStamp = "4e2eef99-65a4-4b8a-a919-145ed60b15a2", - DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), - Email = "admin@gmail.com", - EmailConfirmed = true, - Fullname = "Lương Xuân Nhất", - Gender = 0, - Image = "", - LockoutEnabled = false, - NormalizedEmail = "onionwebdev@gmail.com", - NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAEAL81EjrI0KYNGldHCVGr6VWAAG6C3NTtw/mpPYP8v1ClFiJBnsTwh8zzWucfocLyQ==", - PhoneNumberConfirmed = false, - SecurityStamp = "", - TwoFactorEnabled = false, - UserName = "admin" - }); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Answers") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Answer__AuthorId__1AD3FDA4"); - - b.HasOne("VNH.Domain.Question", "Questions") - .WithMany("Answers") - .HasForeignKey("QuestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Answer__QuestionId__1AD3FVA4"); - - b.Navigation("Author"); - - b.Navigation("Questions"); - }); - - modelBuilder.Entity("VNH.Domain.AnswerVote", b => - { - b.HasOne("VNH.Domain.Answer", "Answer") - .WithMany("AnswerVotes") - .HasForeignKey("AnswerId") - .HasConstraintName("FK__AnswerVot__Answe__1DB06A4F"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("AnswerVotes") - .HasForeignKey("UserId") - .HasConstraintName("FK__AnswerVot__UserI__1EA48E88"); - - b.Navigation("Answer"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Courses") - .HasForeignKey("UserId") - .HasConstraintName("FK__Course__UserId__787EE5A0"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseComments") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseCom__Cours__7A672E12"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseCom__UserI__797309D9"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseRating", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseRatings") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseRat__Cours__7D439ABD"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseRatings") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseRat__UserI__7E37BEF6"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSave", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseSaves") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseSav__Cours__04E4BC85"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseSav__UserI__03F0984C"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSubComment", b => - { - b.HasOne("VNH.Domain.CourseComment", "PreComment") - .WithMany("CourseSubComments") - .HasForeignKey("PreCommentId") - .HasConstraintName("FK__CourseSub__PreCo__7C4F7684"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseSubComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseSub__UserI__7B5B524B"); - - b.Navigation("PreComment"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Documents") - .HasForeignKey("UserId") - .HasConstraintName("FK__Document__UserId__0A9D95DB"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.DocumentSave", b => - { - b.HasOne("VNH.Domain.Document", "Document") - .WithMany("DocumentSaves") - .HasForeignKey("DocumentId") - .HasConstraintName("FK__DocumentS__Docum__0C85DE4D"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("DocumentSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__DocumentS__UserI__0B91BA14"); - - b.Navigation("Document"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => - { - b.HasOne("VNH.Domain.Entities.Notification", "Notification") - .WithMany("NotificationDetails") - .HasForeignKey("NotificationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__NotificationDetail__NotificationId__1EQ48E88"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("NotificationDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__NotificationDetail__UserId__1EA48E88"); - - b.Navigation("Notification"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostTags") - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VNH.Domain.Tag", "Tag") - .WithMany("PostTags") - .HasForeignKey("TagId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.HasOne("VNH.Domain.Lesson", "IdNavigation") - .WithOne("Exercise") - .HasForeignKey("VNH.Domain.Exercise", "Id") - .IsRequired() - .HasConstraintName("FK__Exercise__Id__282DF8C2"); - - b.Navigation("IdNavigation"); - }); - - modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => - { - b.HasOne("VNH.Domain.Exercise", "Exercise") - .WithMany("ExerciseDetails") - .HasForeignKey("ExerciseId") - .HasConstraintName("FK__ExerciseD__Exerc__02084FDA"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("ExerciseDetails") - .HasForeignKey("UserId") - .HasConstraintName("FK__ExerciseD__UserI__01142BA1"); - - b.Navigation("Exercise"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("Lessons") - .HasForeignKey("CourseId") - .HasConstraintName("FK__Lesson__CourseId__7F2BE32F"); - - b.Navigation("Course"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.HasOne("VNH.Domain.Topic", "Topic") - .WithMany("Posts") - .HasForeignKey("TopicId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Post__TopicId__76969D2E"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("Posts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Post__UserId__778AC167"); - - b.Navigation("Topic"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostComments") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostComme__PostI__0F624AF8"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostComme__UserI__10566F31"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostLike", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostLikes") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostLike__PostId__1332DBDC"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostLikes") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostLike__UserId__14270015"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostReportDetail", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostReportDetails") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostRepor__PostI__17036CC0"); - - b.HasOne("VNH.Domain.Report", "Report") - .WithMany("PostReportDetails") - .HasForeignKey("ReportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__PostRepor__Repor__151B244E"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostReportDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__PostRepor__UserI__160F4887"); - - b.Navigation("Post"); - - b.Navigation("Report"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostSave", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostSaves") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostSave__PostId__08B54D69"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostSave__UserId__09A971A2"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostSubComment", b => - { - b.HasOne("VNH.Domain.PostComment", "PreComment") - .WithMany("PostSubComments") - .HasForeignKey("PreCommentId") - .HasConstraintName("FK__PostSubCo__PreCo__114A936A"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostSubComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostSubCo__UserI__123EB7A3"); - - b.Navigation("PreComment"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Questions") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Question__Author__18EBB532"); - - b.Navigation("Author"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionLike", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionLikes") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionL__Quest__1F98B2C1"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionLikes") - .HasForeignKey("UserId") - .HasConstraintName("FK__QuestionL__UserI__208CD6FA"); - - b.Navigation("Question"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionReportDetails") - .HasForeignKey("QuestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__Quest__2180FB33"); - - b.HasOne("VNH.Domain.Report", "Report") - .WithMany("QuestionReportDetails") - .HasForeignKey("ReportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__Quest__22751F6C"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionReportDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__UserI__236943A5"); - - b.Navigation("Question"); - - b.Navigation("Report"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionSave", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionSaves") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionS__Quest__25518C17"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__QuestionS__UserI__245D67DE"); - - b.Navigation("Question"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionTag", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionTag") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionTag__Id__2739D489"); - - b.HasOne("VNH.Domain.Tag", "Tag") - .WithMany("QuestionTags") - .HasForeignKey("TagId") - .HasConstraintName("FK__QuestionT__TagId__2645B050"); - - b.Navigation("Question"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Quiz", b => - { - b.HasOne("VNH.Domain.Exercise", "IdNavigation") - .WithOne("Quiz") - .HasForeignKey("VNH.Domain.Quiz", "Id") - .IsRequired() - .HasConstraintName("FK__Quiz__Id__29221CFB"); - - b.Navigation("IdNavigation"); - }); - - modelBuilder.Entity("VNH.Domain.Search", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Searches") - .HasForeignKey("UserId") - .HasConstraintName("FK__Search__UserId__17F790F9"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.SubAnswer", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("SubAnswers") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__SubAnswer__Autho__1CBC4616"); - - b.HasOne("VNH.Domain.Answer", "PreAnswer") - .WithMany("SubAnswers") - .HasForeignKey("PreAnswerId") - .HasConstraintName("FK__SubAnswer__PreAn__1BC821DD"); - - b.Navigation("Author"); - - b.Navigation("PreAnswer"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Topics") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Topic__AuthorId__05D8E0BE"); - - b.Navigation("Author"); - }); - - modelBuilder.Entity("VNH.Domain.TopicDetail", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("TopicDetails") - .HasForeignKey("PostId") - .HasConstraintName("FK__TopicDeta__TagId__07C12930"); - - b.HasOne("VNH.Domain.Topic", "Topic") - .WithMany("TopicDetails") - .HasForeignKey("TopicId") - .HasConstraintName("FK__TopicDeta__Topic__06CD04F7"); - - b.Navigation("Post"); - - b.Navigation("Topic"); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.Navigation("AnswerVotes"); - - b.Navigation("SubAnswers"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.Navigation("CourseComments"); - - b.Navigation("CourseRatings"); - - b.Navigation("CourseSaves"); - - b.Navigation("Lessons"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.Navigation("CourseSubComments"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.Navigation("DocumentSaves"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.Notification", b => - { - b.Navigation("NotificationDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.Navigation("ExerciseDetails"); - - b.Navigation("Quiz"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.Navigation("Exercise"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.Navigation("PostComments"); - - b.Navigation("PostLikes"); - - b.Navigation("PostReportDetails"); - - b.Navigation("PostSaves"); - - b.Navigation("PostTags"); - - b.Navigation("TopicDetails"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.Navigation("PostSubComments"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.Navigation("Answers"); - - b.Navigation("QuestionLikes"); - - b.Navigation("QuestionReportDetails"); - - b.Navigation("QuestionSaves"); - - b.Navigation("QuestionTag"); - }); - - modelBuilder.Entity("VNH.Domain.Report", b => - { - b.Navigation("PostReportDetails"); - - b.Navigation("QuestionReportDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Tag", b => - { - b.Navigation("PostTags"); - - b.Navigation("QuestionTags"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.Navigation("Posts"); - - b.Navigation("TopicDetails"); - }); - - modelBuilder.Entity("VNH.Domain.User", b => - { - b.Navigation("AnswerVotes"); - - b.Navigation("Answers"); - - b.Navigation("CourseComments"); - - b.Navigation("CourseRatings"); - - b.Navigation("CourseSaves"); - - b.Navigation("CourseSubComments"); - - b.Navigation("Courses"); - - b.Navigation("DocumentSaves"); - - b.Navigation("Documents"); - - b.Navigation("ExerciseDetails"); - - b.Navigation("NotificationDetails"); - - b.Navigation("PostComments"); - - b.Navigation("PostLikes"); - - b.Navigation("PostReportDetails"); - - b.Navigation("PostSaves"); - - b.Navigation("PostSubComments"); - - b.Navigation("Posts"); - - b.Navigation("QuestionLikes"); - - b.Navigation("QuestionReportDetails"); - - b.Navigation("QuestionSaves"); - - b.Navigation("Questions"); - - b.Navigation("Searches"); - - b.Navigation("SubAnswers"); - - b.Navigation("Topics"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.Designer.cs b/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.Designer.cs deleted file mode 100644 index 7ffd12e..0000000 --- a/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.Designer.cs +++ /dev/null @@ -1,1896 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using VNH.Infrastructure.Presenters.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231203134514_add_IsDeleted_Attr")] - partial class add_IsDeleted_Attr - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.13") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("AppRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("UserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId"); - - b.ToTable("AppUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "RoleId"); - - b.ToTable("UserRoles", (string)null); - - b.HasData( - new - { - UserId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - RoleId = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575") - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId"); - - b.ToTable("AppUserTokens", (string)null); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Confirm") - .HasColumnType("bit"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("MostConfirm") - .HasColumnType("bit"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.HasIndex("QuestionId"); - - b.ToTable("Answer"); - }); - - modelBuilder.Entity("VNH.Domain.AnswerVote", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AnswerId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("AnswerId"); - - b.HasIndex("UserId"); - - b.ToTable("AnswerVote"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseName") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("nvarchar(max)"); - - b.Property("Image") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Course"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseComment"); - }); - - modelBuilder.Entity("VNH.Domain.CourseRating", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Score") - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseRating"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseSave"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSubComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PreCommentId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseSubComment"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("FileName") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("SubId") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Document"); - }); - - modelBuilder.Entity("VNH.Domain.DocumentSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("DocumentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("DocumentId"); - - b.HasIndex("UserId"); - - b.ToTable("DocumentSave"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.Notification", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("Title") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Notification"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("IsRead") - .HasColumnType("int"); - - b.Property("NotificationId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("NotificationId"); - - b.HasIndex("UserId"); - - b.ToTable("NotificationDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PostId") - .IsRequired() - .HasColumnType("nvarchar(255)"); - - b.Property("TagId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("TagId"); - - b.ToTable("PostTags"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Image") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("QuizId") - .HasColumnType("uniqueidentifier"); - - b.Property("Time") - .HasColumnType("time"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.ToTable("Exercise"); - }); - - modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("ExerciseId") - .HasColumnType("uniqueidentifier"); - - b.Property("TestMark") - .HasColumnType("float"); - - b.Property("TestTime") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ExerciseId"); - - b.HasIndex("UserId"); - - b.ToTable("ExerciseDetail"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Description") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("ExerciseId") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UrlVideo") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.ToTable("Lesson"); - }); - - modelBuilder.Entity("VNH.Domain.News", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Image") - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("Url") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.ToTable("News"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.Property("Id") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Image") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("SubId") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("TopicId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("ViewNumber") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("TopicId"); - - b.HasIndex("UserId"); - - b.ToTable("Post"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostComment"); - }); - - modelBuilder.Entity("VNH.Domain.PostLike", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostLike"); - }); - - modelBuilder.Entity("VNH.Domain.PostReportDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Checked") - .HasColumnType("bit"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("ReportDate") - .HasColumnType("datetime2"); - - b.Property("ReportId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("ReportId"); - - b.HasIndex("UserId"); - - b.ToTable("PostReportDetail"); - }); - - modelBuilder.Entity("VNH.Domain.PostSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostSave"); - }); - - modelBuilder.Entity("VNH.Domain.PostSubComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PreCommentId"); - - b.HasIndex("UserId"); - - b.ToTable("PostSubComment"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("SubId") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("ViewNumber") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.ToTable("Question"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionLike", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionLike"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Checked") - .HasColumnType("bit"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("ReportDate") - .HasColumnType("datetime2"); - - b.Property("ReportId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("ReportId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionReportDetail"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionSave"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionTag", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("TagId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("TagId"); - - b.ToTable("QuestionTag"); - }); - - modelBuilder.Entity("VNH.Domain.Quiz", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Answer1") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer2") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer3") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer4") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Question") - .HasColumnType("nvarchar(max)"); - - b.Property("RightAnswer") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.ToTable("Quiz"); - }); - - modelBuilder.Entity("VNH.Domain.Report", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.ToTable("Report"); - - b.HasData( - new - { - Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 3, 20, 45, 14, 35, DateTimeKind.Local).AddTicks(988), - Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", - Title = "Nội dung vi phạm quy định về quyền riêng tư" - }, - new - { - Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 3, 20, 45, 14, 35, DateTimeKind.Local).AddTicks(1029), - Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", - Title = "Nội dung xấu, xúc phạm, hay kỳ thị" - }, - new - { - Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 3, 20, 45, 14, 35, DateTimeKind.Local).AddTicks(1036), - Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", - Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" - }, - new - { - Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 3, 20, 45, 14, 35, DateTimeKind.Local).AddTicks(1040), - Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", - Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" - }, - new - { - Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 3, 20, 45, 14, 35, DateTimeKind.Local).AddTicks(1047), - Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", - Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" - }, - new - { - Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 3, 20, 45, 14, 35, DateTimeKind.Local).AddTicks(1053), - Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", - Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" - }, - new - { - Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 3, 20, 45, 14, 35, DateTimeKind.Local).AddTicks(1059), - Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", - Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" - }); - }); - - modelBuilder.Entity("VNH.Domain.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Roles"); - - b.HasData( - new - { - Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "bea7d4e7-0d4b-4ee6-ae10-e6a5b6a3f090", - Name = "admin", - NormalizedName = "admin" - }, - new - { - Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "15fd730c-a962-4f39-b058-3b513bef05f4", - Name = "teacher", - NormalizedName = "teacher" - }, - new - { - Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "64601250-2b15-4efe-bd63-5ee3fbaf4805", - Name = "student", - NormalizedName = "student" - }); - }); - - modelBuilder.Entity("VNH.Domain.Search", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Search"); - }); - - modelBuilder.Entity("VNH.Domain.SubAnswer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreAnswerId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.HasIndex("PreAnswerId"); - - b.ToTable("SubAnswer"); - }); - - modelBuilder.Entity("VNH.Domain.Tag", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.ToTable("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.ToTable("Topic"); - }); - - modelBuilder.Entity("VNH.Domain.TopicDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasColumnType("nvarchar(255)"); - - b.Property("TopicId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("TopicId"); - - b.ToTable("TopicDetail"); - }); - - modelBuilder.Entity("VNH.Domain.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("DateOfBirth") - .HasColumnType("datetime"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("Fullname") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Gender") - .HasColumnType("int"); - - b.Property("Image") - .HasMaxLength(3145728) - .HasColumnType("nvarchar(max)"); - - b.Property("Introduction") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedUserName") - .HasColumnType("nvarchar(max)"); - - b.Property("NumberConfirm") - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("User"); - - b.HasData( - new - { - Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - AccessFailedCount = 0, - ConcurrencyStamp = "33e09550-e12b-4356-b086-fe8c396993a9", - DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), - Email = "admin@gmail.com", - EmailConfirmed = true, - Fullname = "Lương Xuân Nhất", - Gender = 0, - Image = "", - IsDeleted = false, - LockoutEnabled = false, - NormalizedEmail = "onionwebdev@gmail.com", - NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAEJLrA/7q+UsBlY615f6WqAMeBQ/T77hwKO1VLmtGX0zxhYAyBoCbeQ0Srqnq8Zk95A==", - PhoneNumberConfirmed = false, - SecurityStamp = "", - TwoFactorEnabled = false, - UserName = "admin" - }); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Answers") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Answer__AuthorId__1AD3FDA4"); - - b.HasOne("VNH.Domain.Question", "Questions") - .WithMany("Answers") - .HasForeignKey("QuestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Answer__QuestionId__1AD3FVA4"); - - b.Navigation("Author"); - - b.Navigation("Questions"); - }); - - modelBuilder.Entity("VNH.Domain.AnswerVote", b => - { - b.HasOne("VNH.Domain.Answer", "Answer") - .WithMany("AnswerVotes") - .HasForeignKey("AnswerId") - .HasConstraintName("FK__AnswerVot__Answe__1DB06A4F"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("AnswerVotes") - .HasForeignKey("UserId") - .HasConstraintName("FK__AnswerVot__UserI__1EA48E88"); - - b.Navigation("Answer"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Courses") - .HasForeignKey("UserId") - .HasConstraintName("FK__Course__UserId__787EE5A0"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseComments") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseCom__Cours__7A672E12"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseCom__UserI__797309D9"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseRating", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseRatings") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseRat__Cours__7D439ABD"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseRatings") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseRat__UserI__7E37BEF6"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSave", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseSaves") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseSav__Cours__04E4BC85"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseSav__UserI__03F0984C"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSubComment", b => - { - b.HasOne("VNH.Domain.CourseComment", "PreComment") - .WithMany("CourseSubComments") - .HasForeignKey("PreCommentId") - .HasConstraintName("FK__CourseSub__PreCo__7C4F7684"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseSubComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseSub__UserI__7B5B524B"); - - b.Navigation("PreComment"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Documents") - .HasForeignKey("UserId") - .HasConstraintName("FK__Document__UserId__0A9D95DB"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.DocumentSave", b => - { - b.HasOne("VNH.Domain.Document", "Document") - .WithMany("DocumentSaves") - .HasForeignKey("DocumentId") - .HasConstraintName("FK__DocumentS__Docum__0C85DE4D"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("DocumentSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__DocumentS__UserI__0B91BA14"); - - b.Navigation("Document"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => - { - b.HasOne("VNH.Domain.Entities.Notification", "Notification") - .WithMany("NotificationDetails") - .HasForeignKey("NotificationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__NotificationDetail__NotificationId__1EQ48E88"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("NotificationDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__NotificationDetail__UserId__1EA48E88"); - - b.Navigation("Notification"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostTags") - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VNH.Domain.Tag", "Tag") - .WithMany("PostTags") - .HasForeignKey("TagId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.HasOne("VNH.Domain.Lesson", "IdNavigation") - .WithOne("Exercise") - .HasForeignKey("VNH.Domain.Exercise", "Id") - .IsRequired() - .HasConstraintName("FK__Exercise__Id__282DF8C2"); - - b.Navigation("IdNavigation"); - }); - - modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => - { - b.HasOne("VNH.Domain.Exercise", "Exercise") - .WithMany("ExerciseDetails") - .HasForeignKey("ExerciseId") - .HasConstraintName("FK__ExerciseD__Exerc__02084FDA"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("ExerciseDetails") - .HasForeignKey("UserId") - .HasConstraintName("FK__ExerciseD__UserI__01142BA1"); - - b.Navigation("Exercise"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("Lessons") - .HasForeignKey("CourseId") - .HasConstraintName("FK__Lesson__CourseId__7F2BE32F"); - - b.Navigation("Course"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.HasOne("VNH.Domain.Topic", "Topic") - .WithMany("Posts") - .HasForeignKey("TopicId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Post__TopicId__76969D2E"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("Posts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Post__UserId__778AC167"); - - b.Navigation("Topic"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostComments") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostComme__PostI__0F624AF8"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostComme__UserI__10566F31"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostLike", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostLikes") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostLike__PostId__1332DBDC"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostLikes") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostLike__UserId__14270015"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostReportDetail", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostReportDetails") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostRepor__PostI__17036CC0"); - - b.HasOne("VNH.Domain.Report", "Report") - .WithMany("PostReportDetails") - .HasForeignKey("ReportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__PostRepor__Repor__151B244E"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostReportDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__PostRepor__UserI__160F4887"); - - b.Navigation("Post"); - - b.Navigation("Report"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostSave", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostSaves") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostSave__PostId__08B54D69"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostSave__UserId__09A971A2"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostSubComment", b => - { - b.HasOne("VNH.Domain.PostComment", "PreComment") - .WithMany("PostSubComments") - .HasForeignKey("PreCommentId") - .HasConstraintName("FK__PostSubCo__PreCo__114A936A"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostSubComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostSubCo__UserI__123EB7A3"); - - b.Navigation("PreComment"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Questions") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Question__Author__18EBB532"); - - b.Navigation("Author"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionLike", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionLikes") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionL__Quest__1F98B2C1"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionLikes") - .HasForeignKey("UserId") - .HasConstraintName("FK__QuestionL__UserI__208CD6FA"); - - b.Navigation("Question"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionReportDetails") - .HasForeignKey("QuestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__Quest__2180FB33"); - - b.HasOne("VNH.Domain.Report", "Report") - .WithMany("QuestionReportDetails") - .HasForeignKey("ReportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__Quest__22751F6C"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionReportDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__UserI__236943A5"); - - b.Navigation("Question"); - - b.Navigation("Report"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionSave", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionSaves") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionS__Quest__25518C17"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__QuestionS__UserI__245D67DE"); - - b.Navigation("Question"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionTag", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionTag") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionTag__Id__2739D489"); - - b.HasOne("VNH.Domain.Tag", "Tag") - .WithMany("QuestionTags") - .HasForeignKey("TagId") - .HasConstraintName("FK__QuestionT__TagId__2645B050"); - - b.Navigation("Question"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Quiz", b => - { - b.HasOne("VNH.Domain.Exercise", "IdNavigation") - .WithOne("Quiz") - .HasForeignKey("VNH.Domain.Quiz", "Id") - .IsRequired() - .HasConstraintName("FK__Quiz__Id__29221CFB"); - - b.Navigation("IdNavigation"); - }); - - modelBuilder.Entity("VNH.Domain.Search", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Searches") - .HasForeignKey("UserId") - .HasConstraintName("FK__Search__UserId__17F790F9"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.SubAnswer", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("SubAnswers") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__SubAnswer__Autho__1CBC4616"); - - b.HasOne("VNH.Domain.Answer", "PreAnswer") - .WithMany("SubAnswers") - .HasForeignKey("PreAnswerId") - .HasConstraintName("FK__SubAnswer__PreAn__1BC821DD"); - - b.Navigation("Author"); - - b.Navigation("PreAnswer"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Topics") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Topic__AuthorId__05D8E0BE"); - - b.Navigation("Author"); - }); - - modelBuilder.Entity("VNH.Domain.TopicDetail", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("TopicDetails") - .HasForeignKey("PostId") - .HasConstraintName("FK__TopicDeta__TagId__07C12930"); - - b.HasOne("VNH.Domain.Topic", "Topic") - .WithMany("TopicDetails") - .HasForeignKey("TopicId") - .HasConstraintName("FK__TopicDeta__Topic__06CD04F7"); - - b.Navigation("Post"); - - b.Navigation("Topic"); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.Navigation("AnswerVotes"); - - b.Navigation("SubAnswers"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.Navigation("CourseComments"); - - b.Navigation("CourseRatings"); - - b.Navigation("CourseSaves"); - - b.Navigation("Lessons"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.Navigation("CourseSubComments"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.Navigation("DocumentSaves"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.Notification", b => - { - b.Navigation("NotificationDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.Navigation("ExerciseDetails"); - - b.Navigation("Quiz"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.Navigation("Exercise"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.Navigation("PostComments"); - - b.Navigation("PostLikes"); - - b.Navigation("PostReportDetails"); - - b.Navigation("PostSaves"); - - b.Navigation("PostTags"); - - b.Navigation("TopicDetails"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.Navigation("PostSubComments"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.Navigation("Answers"); - - b.Navigation("QuestionLikes"); - - b.Navigation("QuestionReportDetails"); - - b.Navigation("QuestionSaves"); - - b.Navigation("QuestionTag"); - }); - - modelBuilder.Entity("VNH.Domain.Report", b => - { - b.Navigation("PostReportDetails"); - - b.Navigation("QuestionReportDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Tag", b => - { - b.Navigation("PostTags"); - - b.Navigation("QuestionTags"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.Navigation("Posts"); - - b.Navigation("TopicDetails"); - }); - - modelBuilder.Entity("VNH.Domain.User", b => - { - b.Navigation("AnswerVotes"); - - b.Navigation("Answers"); - - b.Navigation("CourseComments"); - - b.Navigation("CourseRatings"); - - b.Navigation("CourseSaves"); - - b.Navigation("CourseSubComments"); - - b.Navigation("Courses"); - - b.Navigation("DocumentSaves"); - - b.Navigation("Documents"); - - b.Navigation("ExerciseDetails"); - - b.Navigation("NotificationDetails"); - - b.Navigation("PostComments"); - - b.Navigation("PostLikes"); - - b.Navigation("PostReportDetails"); - - b.Navigation("PostSaves"); - - b.Navigation("PostSubComments"); - - b.Navigation("Posts"); - - b.Navigation("QuestionLikes"); - - b.Navigation("QuestionReportDetails"); - - b.Navigation("QuestionSaves"); - - b.Navigation("Questions"); - - b.Navigation("Searches"); - - b.Navigation("SubAnswers"); - - b.Navigation("Topics"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.cs b/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.cs deleted file mode 100644 index 54c71b1..0000000 --- a/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - /// - public partial class add_IsDeleted_Attr : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsDeleted", - table: "User", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "IsDeleted", - table: "Post", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "IsDeleted", - table: "Lesson", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "IsDeleted", - table: "Document", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "IsDeleted", - table: "Course", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "IsDeleted", - table: "Answer", - type: "bit", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "IsDeleted", - table: "Question", - type: "bit", - nullable: false, - defaultValue: false); - - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsDeleted", - table: "User"); - - migrationBuilder.DropColumn( - name: "IsDeleted", - table: "Post"); - - migrationBuilder.DropColumn( - name: "IsDeleted", - table: "Lesson"); - - migrationBuilder.DropColumn( - name: "IsDeleted", - table: "Document"); - - migrationBuilder.DropColumn( - name: "IsDeleted", - table: "Course"); - - migrationBuilder.DropColumn( - name: "IsDeleted", - table: "Answer"); - - migrationBuilder.DropColumn( - name: "IsDeleted", - table: "Question"); - - - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231204054827_add_qId_attr_AnswerVote.Designer.cs b/VNH.Infrastructure/Migrations/20231204054827_add_qId_attr_AnswerVote.Designer.cs deleted file mode 100644 index 9ec75c6..0000000 --- a/VNH.Infrastructure/Migrations/20231204054827_add_qId_attr_AnswerVote.Designer.cs +++ /dev/null @@ -1,1902 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using VNH.Infrastructure.Presenters.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231204054827_add_qId_attr_AnswerVote")] - partial class add_qId_attr_AnswerVote - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.13") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("AppRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("UserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId"); - - b.ToTable("AppUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "RoleId"); - - b.ToTable("UserRoles", (string)null); - - b.HasData( - new - { - UserId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - RoleId = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575") - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId"); - - b.ToTable("AppUserTokens", (string)null); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Confirm") - .HasColumnType("bit"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("MostConfirm") - .HasColumnType("bit"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.HasIndex("QuestionId"); - - b.ToTable("Answer"); - }); - - modelBuilder.Entity("VNH.Domain.AnswerVote", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AnswerId") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("AnswerId"); - - b.HasIndex("UserId"); - - b.ToTable("AnswerVote"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseName") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("nvarchar(max)"); - - b.Property("Image") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Course"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseComment"); - }); - - modelBuilder.Entity("VNH.Domain.CourseRating", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Score") - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseRating"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseSave"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSubComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PreCommentId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseSubComment"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("FileName") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("SubId") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Document"); - }); - - modelBuilder.Entity("VNH.Domain.DocumentSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("DocumentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("DocumentId"); - - b.HasIndex("UserId"); - - b.ToTable("DocumentSave"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.Notification", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("Title") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Notification"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("IsRead") - .HasColumnType("int"); - - b.Property("NotificationId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("NotificationId"); - - b.HasIndex("UserId"); - - b.ToTable("NotificationDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PostId") - .IsRequired() - .HasColumnType("nvarchar(255)"); - - b.Property("TagId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("TagId"); - - b.ToTable("PostTags"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Image") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("QuizId") - .HasColumnType("uniqueidentifier"); - - b.Property("Time") - .HasColumnType("time"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.ToTable("Exercise"); - }); - - modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("ExerciseId") - .HasColumnType("uniqueidentifier"); - - b.Property("TestMark") - .HasColumnType("float"); - - b.Property("TestTime") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ExerciseId"); - - b.HasIndex("UserId"); - - b.ToTable("ExerciseDetail"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Description") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("ExerciseId") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UrlVideo") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.ToTable("Lesson"); - }); - - modelBuilder.Entity("VNH.Domain.News", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Image") - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("Url") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.ToTable("News"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.Property("Id") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Image") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("SubId") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("TopicId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("ViewNumber") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("TopicId"); - - b.HasIndex("UserId"); - - b.ToTable("Post"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostComment"); - }); - - modelBuilder.Entity("VNH.Domain.PostLike", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostLike"); - }); - - modelBuilder.Entity("VNH.Domain.PostReportDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Checked") - .HasColumnType("bit"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("ReportDate") - .HasColumnType("datetime2"); - - b.Property("ReportId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("ReportId"); - - b.HasIndex("UserId"); - - b.ToTable("PostReportDetail"); - }); - - modelBuilder.Entity("VNH.Domain.PostSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostSave"); - }); - - modelBuilder.Entity("VNH.Domain.PostSubComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PreCommentId"); - - b.HasIndex("UserId"); - - b.ToTable("PostSubComment"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("SubId") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("ViewNumber") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.ToTable("Question"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionLike", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionLike"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Checked") - .HasColumnType("bit"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("ReportDate") - .HasColumnType("datetime2"); - - b.Property("ReportId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("ReportId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionReportDetail"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionSave"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionTag", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("TagId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("TagId"); - - b.ToTable("QuestionTag"); - }); - - modelBuilder.Entity("VNH.Domain.Quiz", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Answer1") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer2") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer3") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer4") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Question") - .HasColumnType("nvarchar(max)"); - - b.Property("RightAnswer") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.ToTable("Quiz"); - }); - - modelBuilder.Entity("VNH.Domain.Report", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.ToTable("Report"); - - b.HasData( - new - { - Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 4, 12, 48, 26, 485, DateTimeKind.Local).AddTicks(1599), - Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", - Title = "Nội dung vi phạm quy định về quyền riêng tư" - }, - new - { - Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 4, 12, 48, 26, 485, DateTimeKind.Local).AddTicks(1618), - Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", - Title = "Nội dung xấu, xúc phạm, hay kỳ thị" - }, - new - { - Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 4, 12, 48, 26, 485, DateTimeKind.Local).AddTicks(1623), - Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", - Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" - }, - new - { - Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 4, 12, 48, 26, 485, DateTimeKind.Local).AddTicks(1626), - Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", - Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" - }, - new - { - Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 4, 12, 48, 26, 485, DateTimeKind.Local).AddTicks(1631), - Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", - Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" - }, - new - { - Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 4, 12, 48, 26, 485, DateTimeKind.Local).AddTicks(1634), - Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", - Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" - }, - new - { - Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 4, 12, 48, 26, 485, DateTimeKind.Local).AddTicks(1638), - Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", - Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" - }); - }); - - modelBuilder.Entity("VNH.Domain.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Roles"); - - b.HasData( - new - { - Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "e4dbaac1-6073-4ae7-9a3e-e74aa48a0bc9", - Name = "admin", - NormalizedName = "admin" - }, - new - { - Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "2a90d4a7-20aa-4548-8078-8b408dfa04e0", - Name = "teacher", - NormalizedName = "teacher" - }, - new - { - Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "5652b6cf-30c6-46fd-a881-b7b056c1260e", - Name = "student", - NormalizedName = "student" - }); - }); - - modelBuilder.Entity("VNH.Domain.Search", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Search"); - }); - - modelBuilder.Entity("VNH.Domain.SubAnswer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreAnswerId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.HasIndex("PreAnswerId"); - - b.ToTable("SubAnswer"); - }); - - modelBuilder.Entity("VNH.Domain.Tag", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.ToTable("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.ToTable("Topic"); - }); - - modelBuilder.Entity("VNH.Domain.TopicDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasColumnType("nvarchar(255)"); - - b.Property("TopicId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("TopicId"); - - b.ToTable("TopicDetail"); - }); - - modelBuilder.Entity("VNH.Domain.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("DateOfBirth") - .HasColumnType("datetime"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("Fullname") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Gender") - .HasColumnType("int"); - - b.Property("Image") - .HasMaxLength(3145728) - .HasColumnType("nvarchar(max)"); - - b.Property("Introduction") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedUserName") - .HasColumnType("nvarchar(max)"); - - b.Property("NumberConfirm") - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("User"); - - b.HasData( - new - { - Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - AccessFailedCount = 0, - ConcurrencyStamp = "ea94306b-48e2-48a5-8194-ce2736596356", - DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), - Email = "admin@gmail.com", - EmailConfirmed = true, - Fullname = "Lương Xuân Nhất", - Gender = 0, - Image = "", - IsDeleted = false, - LockoutEnabled = false, - NormalizedEmail = "onionwebdev@gmail.com", - NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAELDviatJqenBuzfgkq/Dqy2IYozFWZincUUuK2HPczKdamA4YsECmIKYgnI1sdEG4g==", - PhoneNumberConfirmed = false, - SecurityStamp = "", - TwoFactorEnabled = false, - UserName = "admin" - }); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Answers") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Answer__AuthorId__1AD3FDA4"); - - b.HasOne("VNH.Domain.Question", "Questions") - .WithMany("Answers") - .HasForeignKey("QuestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Answer__QuestionId__1AD3FVA4"); - - b.Navigation("Author"); - - b.Navigation("Questions"); - }); - - modelBuilder.Entity("VNH.Domain.AnswerVote", b => - { - b.HasOne("VNH.Domain.Answer", "Answer") - .WithMany("AnswerVotes") - .HasForeignKey("AnswerId") - .HasConstraintName("FK__AnswerVot__Answe__1DB06A4F"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("AnswerVotes") - .HasForeignKey("UserId") - .HasConstraintName("FK__AnswerVot__UserI__1EA48E88"); - - b.Navigation("Answer"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Courses") - .HasForeignKey("UserId") - .HasConstraintName("FK__Course__UserId__787EE5A0"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseComments") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseCom__Cours__7A672E12"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseCom__UserI__797309D9"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseRating", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseRatings") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseRat__Cours__7D439ABD"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseRatings") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseRat__UserI__7E37BEF6"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSave", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseSaves") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseSav__Cours__04E4BC85"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseSav__UserI__03F0984C"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSubComment", b => - { - b.HasOne("VNH.Domain.CourseComment", "PreComment") - .WithMany("CourseSubComments") - .HasForeignKey("PreCommentId") - .HasConstraintName("FK__CourseSub__PreCo__7C4F7684"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseSubComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseSub__UserI__7B5B524B"); - - b.Navigation("PreComment"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Documents") - .HasForeignKey("UserId") - .HasConstraintName("FK__Document__UserId__0A9D95DB"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.DocumentSave", b => - { - b.HasOne("VNH.Domain.Document", "Document") - .WithMany("DocumentSaves") - .HasForeignKey("DocumentId") - .HasConstraintName("FK__DocumentS__Docum__0C85DE4D"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("DocumentSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__DocumentS__UserI__0B91BA14"); - - b.Navigation("Document"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => - { - b.HasOne("VNH.Domain.Entities.Notification", "Notification") - .WithMany("NotificationDetails") - .HasForeignKey("NotificationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__NotificationDetail__NotificationId__1EQ48E88"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("NotificationDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__NotificationDetail__UserId__1EA48E88"); - - b.Navigation("Notification"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostTags") - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VNH.Domain.Tag", "Tag") - .WithMany("PostTags") - .HasForeignKey("TagId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.HasOne("VNH.Domain.Lesson", "IdNavigation") - .WithOne("Exercise") - .HasForeignKey("VNH.Domain.Exercise", "Id") - .IsRequired() - .HasConstraintName("FK__Exercise__Id__282DF8C2"); - - b.Navigation("IdNavigation"); - }); - - modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => - { - b.HasOne("VNH.Domain.Exercise", "Exercise") - .WithMany("ExerciseDetails") - .HasForeignKey("ExerciseId") - .HasConstraintName("FK__ExerciseD__Exerc__02084FDA"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("ExerciseDetails") - .HasForeignKey("UserId") - .HasConstraintName("FK__ExerciseD__UserI__01142BA1"); - - b.Navigation("Exercise"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("Lessons") - .HasForeignKey("CourseId") - .HasConstraintName("FK__Lesson__CourseId__7F2BE32F"); - - b.Navigation("Course"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.HasOne("VNH.Domain.Topic", "Topic") - .WithMany("Posts") - .HasForeignKey("TopicId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Post__TopicId__76969D2E"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("Posts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Post__UserId__778AC167"); - - b.Navigation("Topic"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostComments") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostComme__PostI__0F624AF8"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostComme__UserI__10566F31"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostLike", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostLikes") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostLike__PostId__1332DBDC"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostLikes") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostLike__UserId__14270015"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostReportDetail", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostReportDetails") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostRepor__PostI__17036CC0"); - - b.HasOne("VNH.Domain.Report", "Report") - .WithMany("PostReportDetails") - .HasForeignKey("ReportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__PostRepor__Repor__151B244E"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostReportDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__PostRepor__UserI__160F4887"); - - b.Navigation("Post"); - - b.Navigation("Report"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostSave", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostSaves") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostSave__PostId__08B54D69"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostSave__UserId__09A971A2"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostSubComment", b => - { - b.HasOne("VNH.Domain.PostComment", "PreComment") - .WithMany("PostSubComments") - .HasForeignKey("PreCommentId") - .HasConstraintName("FK__PostSubCo__PreCo__114A936A"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostSubComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostSubCo__UserI__123EB7A3"); - - b.Navigation("PreComment"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Questions") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Question__Author__18EBB532"); - - b.Navigation("Author"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionLike", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionLikes") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionL__Quest__1F98B2C1"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionLikes") - .HasForeignKey("UserId") - .HasConstraintName("FK__QuestionL__UserI__208CD6FA"); - - b.Navigation("Question"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionReportDetails") - .HasForeignKey("QuestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__Quest__2180FB33"); - - b.HasOne("VNH.Domain.Report", "Report") - .WithMany("QuestionReportDetails") - .HasForeignKey("ReportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__Quest__22751F6C"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionReportDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__UserI__236943A5"); - - b.Navigation("Question"); - - b.Navigation("Report"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionSave", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionSaves") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionS__Quest__25518C17"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__QuestionS__UserI__245D67DE"); - - b.Navigation("Question"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionTag", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionTag") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionTag__Id__2739D489"); - - b.HasOne("VNH.Domain.Tag", "Tag") - .WithMany("QuestionTags") - .HasForeignKey("TagId") - .HasConstraintName("FK__QuestionT__TagId__2645B050"); - - b.Navigation("Question"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Quiz", b => - { - b.HasOne("VNH.Domain.Exercise", "IdNavigation") - .WithOne("Quiz") - .HasForeignKey("VNH.Domain.Quiz", "Id") - .IsRequired() - .HasConstraintName("FK__Quiz__Id__29221CFB"); - - b.Navigation("IdNavigation"); - }); - - modelBuilder.Entity("VNH.Domain.Search", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Searches") - .HasForeignKey("UserId") - .HasConstraintName("FK__Search__UserId__17F790F9"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.SubAnswer", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("SubAnswers") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__SubAnswer__Autho__1CBC4616"); - - b.HasOne("VNH.Domain.Answer", "PreAnswer") - .WithMany("SubAnswers") - .HasForeignKey("PreAnswerId") - .HasConstraintName("FK__SubAnswer__PreAn__1BC821DD"); - - b.Navigation("Author"); - - b.Navigation("PreAnswer"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Topics") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Topic__AuthorId__05D8E0BE"); - - b.Navigation("Author"); - }); - - modelBuilder.Entity("VNH.Domain.TopicDetail", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("TopicDetails") - .HasForeignKey("PostId") - .HasConstraintName("FK__TopicDeta__TagId__07C12930"); - - b.HasOne("VNH.Domain.Topic", "Topic") - .WithMany("TopicDetails") - .HasForeignKey("TopicId") - .HasConstraintName("FK__TopicDeta__Topic__06CD04F7"); - - b.Navigation("Post"); - - b.Navigation("Topic"); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.Navigation("AnswerVotes"); - - b.Navigation("SubAnswers"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.Navigation("CourseComments"); - - b.Navigation("CourseRatings"); - - b.Navigation("CourseSaves"); - - b.Navigation("Lessons"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.Navigation("CourseSubComments"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.Navigation("DocumentSaves"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.Notification", b => - { - b.Navigation("NotificationDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.Navigation("ExerciseDetails"); - - b.Navigation("Quiz"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.Navigation("Exercise"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.Navigation("PostComments"); - - b.Navigation("PostLikes"); - - b.Navigation("PostReportDetails"); - - b.Navigation("PostSaves"); - - b.Navigation("PostTags"); - - b.Navigation("TopicDetails"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.Navigation("PostSubComments"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.Navigation("Answers"); - - b.Navigation("QuestionLikes"); - - b.Navigation("QuestionReportDetails"); - - b.Navigation("QuestionSaves"); - - b.Navigation("QuestionTag"); - }); - - modelBuilder.Entity("VNH.Domain.Report", b => - { - b.Navigation("PostReportDetails"); - - b.Navigation("QuestionReportDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Tag", b => - { - b.Navigation("PostTags"); - - b.Navigation("QuestionTags"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.Navigation("Posts"); - - b.Navigation("TopicDetails"); - }); - - modelBuilder.Entity("VNH.Domain.User", b => - { - b.Navigation("AnswerVotes"); - - b.Navigation("Answers"); - - b.Navigation("CourseComments"); - - b.Navigation("CourseRatings"); - - b.Navigation("CourseSaves"); - - b.Navigation("CourseSubComments"); - - b.Navigation("Courses"); - - b.Navigation("DocumentSaves"); - - b.Navigation("Documents"); - - b.Navigation("ExerciseDetails"); - - b.Navigation("NotificationDetails"); - - b.Navigation("PostComments"); - - b.Navigation("PostLikes"); - - b.Navigation("PostReportDetails"); - - b.Navigation("PostSaves"); - - b.Navigation("PostSubComments"); - - b.Navigation("Posts"); - - b.Navigation("QuestionLikes"); - - b.Navigation("QuestionReportDetails"); - - b.Navigation("QuestionSaves"); - - b.Navigation("Questions"); - - b.Navigation("Searches"); - - b.Navigation("SubAnswers"); - - b.Navigation("Topics"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231204054827_add_qId_attr_AnswerVote.cs b/VNH.Infrastructure/Migrations/20231204054827_add_qId_attr_AnswerVote.cs deleted file mode 100644 index 58712d6..0000000 --- a/VNH.Infrastructure/Migrations/20231204054827_add_qId_attr_AnswerVote.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - /// - public partial class add_qId_attr_AnswerVote : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - migrationBuilder.AddColumn( - name: "QuestionId", - table: "AnswerVote", - type: "uniqueidentifier", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - migrationBuilder.DropColumn( - name: "QuestionId", - table: "AnswerVote"); - - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231205080409_remove_attr_news_table.Designer.cs b/VNH.Infrastructure/Migrations/20231205080409_remove_attr_news_table.Designer.cs deleted file mode 100644 index dd684f1..0000000 --- a/VNH.Infrastructure/Migrations/20231205080409_remove_attr_news_table.Designer.cs +++ /dev/null @@ -1,1897 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using VNH.Infrastructure.Presenters.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231205080409_remove_attr_news_table")] - partial class remove_attr_news_table - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.13") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("AppRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.ToTable("UserClaims"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId"); - - b.ToTable("AppUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("RoleId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("UserId", "RoleId"); - - b.ToTable("UserRoles", (string)null); - - b.HasData( - new - { - UserId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - RoleId = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575") - }); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId"); - - b.ToTable("AppUserTokens", (string)null); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Confirm") - .HasColumnType("bit"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("MostConfirm") - .HasColumnType("bit"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.HasIndex("QuestionId"); - - b.ToTable("Answer"); - }); - - modelBuilder.Entity("VNH.Domain.AnswerVote", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AnswerId") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("AnswerId"); - - b.HasIndex("UserId"); - - b.ToTable("AnswerVote"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseName") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("nvarchar(max)"); - - b.Property("Image") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Course"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseComment"); - }); - - modelBuilder.Entity("VNH.Domain.CourseRating", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Score") - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseRating"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseSave"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSubComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PreCommentId"); - - b.HasIndex("UserId"); - - b.ToTable("CourseSubComment"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("FileName") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("SubId") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Document"); - }); - - modelBuilder.Entity("VNH.Domain.DocumentSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("DocumentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("DocumentId"); - - b.HasIndex("UserId"); - - b.ToTable("DocumentSave"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.Notification", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("Title") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Notification"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("Date") - .HasColumnType("datetime2"); - - b.Property("IsRead") - .HasColumnType("int"); - - b.Property("NotificationId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("NotificationId"); - - b.HasIndex("UserId"); - - b.ToTable("NotificationDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PostId") - .IsRequired() - .HasColumnType("nvarchar(255)"); - - b.Property("TagId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("TagId"); - - b.ToTable("PostTags"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Image") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("QuizId") - .HasColumnType("uniqueidentifier"); - - b.Property("Time") - .HasColumnType("time"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.ToTable("Exercise"); - }); - - modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("ExerciseId") - .HasColumnType("uniqueidentifier"); - - b.Property("TestMark") - .HasColumnType("float"); - - b.Property("TestTime") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("ExerciseId"); - - b.HasIndex("UserId"); - - b.ToTable("ExerciseDetail"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CourseId") - .HasColumnType("uniqueidentifier"); - - b.Property("Description") - .HasMaxLength(2000) - .HasColumnType("nvarchar(2000)"); - - b.Property("ExerciseId") - .HasColumnType("uniqueidentifier"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UrlVideo") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); - - b.HasKey("Id"); - - b.HasIndex("CourseId"); - - b.ToTable("Lesson"); - }); - - modelBuilder.Entity("VNH.Domain.News", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Image") - .HasColumnType("text"); - - b.Property("Title") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Url") - .IsRequired() - .IsUnicode(false) - .HasColumnType("varchar(max)"); - - b.HasKey("Id"); - - b.ToTable("News"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.Property("Id") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Image") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("SubId") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("TopicId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.Property("ViewNumber") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("TopicId"); - - b.HasIndex("UserId"); - - b.ToTable("Post"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostComment"); - }); - - modelBuilder.Entity("VNH.Domain.PostLike", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostLike"); - }); - - modelBuilder.Entity("VNH.Domain.PostReportDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Checked") - .HasColumnType("bit"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("ReportDate") - .HasColumnType("datetime2"); - - b.Property("ReportId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("ReportId"); - - b.HasIndex("UserId"); - - b.ToTable("PostReportDetail"); - }); - - modelBuilder.Entity("VNH.Domain.PostSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("UserId"); - - b.ToTable("PostSave"); - }); - - modelBuilder.Entity("VNH.Domain.PostSubComment", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreCommentId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PreCommentId"); - - b.HasIndex("UserId"); - - b.ToTable("PostSubComment"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("SubId") - .HasColumnType("nvarchar(max)"); - - b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.Property("ViewNumber") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.ToTable("Question"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionLike", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionLike"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Checked") - .HasColumnType("bit"); - - b.Property("Description") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("ReportDate") - .HasColumnType("datetime2"); - - b.Property("ReportId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("ReportId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionReportDetail"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionSave", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("UserId"); - - b.ToTable("QuestionSave"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionTag", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("QuestionId") - .HasColumnType("uniqueidentifier"); - - b.Property("TagId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("QuestionId"); - - b.HasIndex("TagId"); - - b.ToTable("QuestionTag"); - }); - - modelBuilder.Entity("VNH.Domain.Quiz", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Answer1") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer2") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer3") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Answer4") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Question") - .HasColumnType("nvarchar(max)"); - - b.Property("RightAnswer") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.HasKey("Id"); - - b.ToTable("Quiz"); - }); - - modelBuilder.Entity("VNH.Domain.Report", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.ToTable("Report"); - - b.HasData( - new - { - Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 5, 15, 4, 9, 540, DateTimeKind.Local).AddTicks(1345), - Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", - Title = "Nội dung vi phạm quy định về quyền riêng tư" - }, - new - { - Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 5, 15, 4, 9, 540, DateTimeKind.Local).AddTicks(1357), - Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", - Title = "Nội dung xấu, xúc phạm, hay kỳ thị" - }, - new - { - Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 5, 15, 4, 9, 540, DateTimeKind.Local).AddTicks(1359), - Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", - Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" - }, - new - { - Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 5, 15, 4, 9, 540, DateTimeKind.Local).AddTicks(1362), - Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", - Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" - }, - new - { - Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 5, 15, 4, 9, 540, DateTimeKind.Local).AddTicks(1364), - Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", - Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" - }, - new - { - Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 5, 15, 4, 9, 540, DateTimeKind.Local).AddTicks(1366), - Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", - Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" - }, - new - { - Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 5, 15, 4, 9, 540, DateTimeKind.Local).AddTicks(1368), - Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", - Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" - }); - }); - - modelBuilder.Entity("VNH.Domain.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ConcurrencyStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Roles"); - - b.HasData( - new - { - Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "3182dd22-7192-40cc-bf32-ae0bb5363bba", - Name = "admin", - NormalizedName = "admin" - }, - new - { - Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "2a155be9-196e-48ad-95a4-28f7eee91b69", - Name = "teacher", - NormalizedName = "teacher" - }, - new - { - Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "7f5fc9f5-7422-4f96-8126-3a42fd7ff282", - Name = "student", - NormalizedName = "student" - }); - }); - - modelBuilder.Entity("VNH.Domain.Search", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("UserId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Search"); - }); - - modelBuilder.Entity("VNH.Domain.SubAnswer", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasColumnType("nvarchar(max)"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("PreAnswerId") - .HasColumnType("uniqueidentifier"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.HasIndex("PreAnswerId"); - - b.ToTable("SubAnswer"); - }); - - modelBuilder.Entity("VNH.Domain.Tag", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.HasKey("Id"); - - b.ToTable("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AuthorId") - .HasColumnType("uniqueidentifier"); - - b.Property("CreatedAt") - .HasColumnType("datetime"); - - b.Property("Title") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("UpdatedAt") - .HasColumnType("datetime"); - - b.HasKey("Id"); - - b.HasIndex("AuthorId"); - - b.ToTable("Topic"); - }); - - modelBuilder.Entity("VNH.Domain.TopicDetail", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("PostId") - .HasColumnType("nvarchar(255)"); - - b.Property("TopicId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("PostId"); - - b.HasIndex("TopicId"); - - b.ToTable("TopicDetail"); - }); - - modelBuilder.Entity("VNH.Domain.User", b => - { - b.Property("Id") - .HasColumnType("uniqueidentifier"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("DateOfBirth") - .HasColumnType("datetime"); - - b.Property("Email") - .HasColumnType("nvarchar(max)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("Fullname") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Gender") - .HasColumnType("int"); - - b.Property("Image") - .HasMaxLength(3145728) - .HasColumnType("nvarchar(max)"); - - b.Property("Introduction") - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeleted") - .HasColumnType("bit"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("NormalizedEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("NormalizedUserName") - .HasColumnType("nvarchar(max)"); - - b.Property("NumberConfirm") - .HasColumnType("nvarchar(max)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("User"); - - b.HasData( - new - { - Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - AccessFailedCount = 0, - ConcurrencyStamp = "8c0e4229-5e6c-4aaa-a39d-b580661ab9c2", - DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), - Email = "admin@gmail.com", - EmailConfirmed = true, - Fullname = "Lương Xuân Nhất", - Gender = 0, - Image = "", - IsDeleted = false, - LockoutEnabled = false, - NormalizedEmail = "onionwebdev@gmail.com", - NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAENntF+L92TVYiUupnD7s15ka9Nrde4KrOfDTQcYRgC+/SRv5zyA12ZH1deKOvdEbtA==", - PhoneNumberConfirmed = false, - SecurityStamp = "", - TwoFactorEnabled = false, - UserName = "admin" - }); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Answers") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Answer__AuthorId__1AD3FDA4"); - - b.HasOne("VNH.Domain.Question", "Questions") - .WithMany("Answers") - .HasForeignKey("QuestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Answer__QuestionId__1AD3FVA4"); - - b.Navigation("Author"); - - b.Navigation("Questions"); - }); - - modelBuilder.Entity("VNH.Domain.AnswerVote", b => - { - b.HasOne("VNH.Domain.Answer", "Answer") - .WithMany("AnswerVotes") - .HasForeignKey("AnswerId") - .HasConstraintName("FK__AnswerVot__Answe__1DB06A4F"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("AnswerVotes") - .HasForeignKey("UserId") - .HasConstraintName("FK__AnswerVot__UserI__1EA48E88"); - - b.Navigation("Answer"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Courses") - .HasForeignKey("UserId") - .HasConstraintName("FK__Course__UserId__787EE5A0"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseComments") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseCom__Cours__7A672E12"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseCom__UserI__797309D9"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseRating", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseRatings") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseRat__Cours__7D439ABD"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseRatings") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseRat__UserI__7E37BEF6"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSave", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("CourseSaves") - .HasForeignKey("CourseId") - .HasConstraintName("FK__CourseSav__Cours__04E4BC85"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseSav__UserI__03F0984C"); - - b.Navigation("Course"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.CourseSubComment", b => - { - b.HasOne("VNH.Domain.CourseComment", "PreComment") - .WithMany("CourseSubComments") - .HasForeignKey("PreCommentId") - .HasConstraintName("FK__CourseSub__PreCo__7C4F7684"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("CourseSubComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__CourseSub__UserI__7B5B524B"); - - b.Navigation("PreComment"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Documents") - .HasForeignKey("UserId") - .HasConstraintName("FK__Document__UserId__0A9D95DB"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.DocumentSave", b => - { - b.HasOne("VNH.Domain.Document", "Document") - .WithMany("DocumentSaves") - .HasForeignKey("DocumentId") - .HasConstraintName("FK__DocumentS__Docum__0C85DE4D"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("DocumentSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__DocumentS__UserI__0B91BA14"); - - b.Navigation("Document"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => - { - b.HasOne("VNH.Domain.Entities.Notification", "Notification") - .WithMany("NotificationDetails") - .HasForeignKey("NotificationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__NotificationDetail__NotificationId__1EQ48E88"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("NotificationDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__NotificationDetail__UserId__1EA48E88"); - - b.Navigation("Notification"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostTags") - .HasForeignKey("PostId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VNH.Domain.Tag", "Tag") - .WithMany("PostTags") - .HasForeignKey("TagId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Post"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.HasOne("VNH.Domain.Lesson", "IdNavigation") - .WithOne("Exercise") - .HasForeignKey("VNH.Domain.Exercise", "Id") - .IsRequired() - .HasConstraintName("FK__Exercise__Id__282DF8C2"); - - b.Navigation("IdNavigation"); - }); - - modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => - { - b.HasOne("VNH.Domain.Exercise", "Exercise") - .WithMany("ExerciseDetails") - .HasForeignKey("ExerciseId") - .HasConstraintName("FK__ExerciseD__Exerc__02084FDA"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("ExerciseDetails") - .HasForeignKey("UserId") - .HasConstraintName("FK__ExerciseD__UserI__01142BA1"); - - b.Navigation("Exercise"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.HasOne("VNH.Domain.Course", "Course") - .WithMany("Lessons") - .HasForeignKey("CourseId") - .HasConstraintName("FK__Lesson__CourseId__7F2BE32F"); - - b.Navigation("Course"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.HasOne("VNH.Domain.Topic", "Topic") - .WithMany("Posts") - .HasForeignKey("TopicId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Post__TopicId__76969D2E"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("Posts") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__Post__UserId__778AC167"); - - b.Navigation("Topic"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostComments") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostComme__PostI__0F624AF8"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostComme__UserI__10566F31"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostLike", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostLikes") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostLike__PostId__1332DBDC"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostLikes") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostLike__UserId__14270015"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostReportDetail", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostReportDetails") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostRepor__PostI__17036CC0"); - - b.HasOne("VNH.Domain.Report", "Report") - .WithMany("PostReportDetails") - .HasForeignKey("ReportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__PostRepor__Repor__151B244E"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostReportDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__PostRepor__UserI__160F4887"); - - b.Navigation("Post"); - - b.Navigation("Report"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostSave", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("PostSaves") - .HasForeignKey("PostId") - .HasConstraintName("FK__PostSave__PostId__08B54D69"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostSave__UserId__09A971A2"); - - b.Navigation("Post"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.PostSubComment", b => - { - b.HasOne("VNH.Domain.PostComment", "PreComment") - .WithMany("PostSubComments") - .HasForeignKey("PreCommentId") - .HasConstraintName("FK__PostSubCo__PreCo__114A936A"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("PostSubComments") - .HasForeignKey("UserId") - .HasConstraintName("FK__PostSubCo__UserI__123EB7A3"); - - b.Navigation("PreComment"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Questions") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Question__Author__18EBB532"); - - b.Navigation("Author"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionLike", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionLikes") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionL__Quest__1F98B2C1"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionLikes") - .HasForeignKey("UserId") - .HasConstraintName("FK__QuestionL__UserI__208CD6FA"); - - b.Navigation("Question"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionReportDetails") - .HasForeignKey("QuestionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__Quest__2180FB33"); - - b.HasOne("VNH.Domain.Report", "Report") - .WithMany("QuestionReportDetails") - .HasForeignKey("ReportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__Quest__22751F6C"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionReportDetails") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK__QuestionR__UserI__236943A5"); - - b.Navigation("Question"); - - b.Navigation("Report"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionSave", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionSaves") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionS__Quest__25518C17"); - - b.HasOne("VNH.Domain.User", "User") - .WithMany("QuestionSaves") - .HasForeignKey("UserId") - .HasConstraintName("FK__QuestionS__UserI__245D67DE"); - - b.Navigation("Question"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.QuestionTag", b => - { - b.HasOne("VNH.Domain.Question", "Question") - .WithMany("QuestionTag") - .HasForeignKey("QuestionId") - .HasConstraintName("FK__QuestionTag__Id__2739D489"); - - b.HasOne("VNH.Domain.Tag", "Tag") - .WithMany("QuestionTags") - .HasForeignKey("TagId") - .HasConstraintName("FK__QuestionT__TagId__2645B050"); - - b.Navigation("Question"); - - b.Navigation("Tag"); - }); - - modelBuilder.Entity("VNH.Domain.Quiz", b => - { - b.HasOne("VNH.Domain.Exercise", "IdNavigation") - .WithOne("Quiz") - .HasForeignKey("VNH.Domain.Quiz", "Id") - .IsRequired() - .HasConstraintName("FK__Quiz__Id__29221CFB"); - - b.Navigation("IdNavigation"); - }); - - modelBuilder.Entity("VNH.Domain.Search", b => - { - b.HasOne("VNH.Domain.User", "User") - .WithMany("Searches") - .HasForeignKey("UserId") - .HasConstraintName("FK__Search__UserId__17F790F9"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("VNH.Domain.SubAnswer", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("SubAnswers") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__SubAnswer__Autho__1CBC4616"); - - b.HasOne("VNH.Domain.Answer", "PreAnswer") - .WithMany("SubAnswers") - .HasForeignKey("PreAnswerId") - .HasConstraintName("FK__SubAnswer__PreAn__1BC821DD"); - - b.Navigation("Author"); - - b.Navigation("PreAnswer"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.HasOne("VNH.Domain.User", "Author") - .WithMany("Topics") - .HasForeignKey("AuthorId") - .HasConstraintName("FK__Topic__AuthorId__05D8E0BE"); - - b.Navigation("Author"); - }); - - modelBuilder.Entity("VNH.Domain.TopicDetail", b => - { - b.HasOne("VNH.Domain.Post", "Post") - .WithMany("TopicDetails") - .HasForeignKey("PostId") - .HasConstraintName("FK__TopicDeta__TagId__07C12930"); - - b.HasOne("VNH.Domain.Topic", "Topic") - .WithMany("TopicDetails") - .HasForeignKey("TopicId") - .HasConstraintName("FK__TopicDeta__Topic__06CD04F7"); - - b.Navigation("Post"); - - b.Navigation("Topic"); - }); - - modelBuilder.Entity("VNH.Domain.Answer", b => - { - b.Navigation("AnswerVotes"); - - b.Navigation("SubAnswers"); - }); - - modelBuilder.Entity("VNH.Domain.Course", b => - { - b.Navigation("CourseComments"); - - b.Navigation("CourseRatings"); - - b.Navigation("CourseSaves"); - - b.Navigation("Lessons"); - }); - - modelBuilder.Entity("VNH.Domain.CourseComment", b => - { - b.Navigation("CourseSubComments"); - }); - - modelBuilder.Entity("VNH.Domain.Document", b => - { - b.Navigation("DocumentSaves"); - }); - - modelBuilder.Entity("VNH.Domain.Entities.Notification", b => - { - b.Navigation("NotificationDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Exercise", b => - { - b.Navigation("ExerciseDetails"); - - b.Navigation("Quiz"); - }); - - modelBuilder.Entity("VNH.Domain.Lesson", b => - { - b.Navigation("Exercise"); - }); - - modelBuilder.Entity("VNH.Domain.Post", b => - { - b.Navigation("PostComments"); - - b.Navigation("PostLikes"); - - b.Navigation("PostReportDetails"); - - b.Navigation("PostSaves"); - - b.Navigation("PostTags"); - - b.Navigation("TopicDetails"); - }); - - modelBuilder.Entity("VNH.Domain.PostComment", b => - { - b.Navigation("PostSubComments"); - }); - - modelBuilder.Entity("VNH.Domain.Question", b => - { - b.Navigation("Answers"); - - b.Navigation("QuestionLikes"); - - b.Navigation("QuestionReportDetails"); - - b.Navigation("QuestionSaves"); - - b.Navigation("QuestionTag"); - }); - - modelBuilder.Entity("VNH.Domain.Report", b => - { - b.Navigation("PostReportDetails"); - - b.Navigation("QuestionReportDetails"); - }); - - modelBuilder.Entity("VNH.Domain.Tag", b => - { - b.Navigation("PostTags"); - - b.Navigation("QuestionTags"); - }); - - modelBuilder.Entity("VNH.Domain.Topic", b => - { - b.Navigation("Posts"); - - b.Navigation("TopicDetails"); - }); - - modelBuilder.Entity("VNH.Domain.User", b => - { - b.Navigation("AnswerVotes"); - - b.Navigation("Answers"); - - b.Navigation("CourseComments"); - - b.Navigation("CourseRatings"); - - b.Navigation("CourseSaves"); - - b.Navigation("CourseSubComments"); - - b.Navigation("Courses"); - - b.Navigation("DocumentSaves"); - - b.Navigation("Documents"); - - b.Navigation("ExerciseDetails"); - - b.Navigation("NotificationDetails"); - - b.Navigation("PostComments"); - - b.Navigation("PostLikes"); - - b.Navigation("PostReportDetails"); - - b.Navigation("PostSaves"); - - b.Navigation("PostSubComments"); - - b.Navigation("Posts"); - - b.Navigation("QuestionLikes"); - - b.Navigation("QuestionReportDetails"); - - b.Navigation("QuestionSaves"); - - b.Navigation("Questions"); - - b.Navigation("Searches"); - - b.Navigation("SubAnswers"); - - b.Navigation("Topics"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231205080409_remove_attr_news_table.cs b/VNH.Infrastructure/Migrations/20231205080409_remove_attr_news_table.cs deleted file mode 100644 index 6425b39..0000000 --- a/VNH.Infrastructure/Migrations/20231205080409_remove_attr_news_table.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - /// - public partial class remove_attr_news_table : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "CreatedAt", - table: "News"); - - migrationBuilder.AlterColumn( - name: "Url", - table: "News", - type: "varchar(max)", - unicode: false, - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(255)", - oldUnicode: false, - oldMaxLength: 255); - - migrationBuilder.AlterColumn( - name: "Title", - table: "News", - type: "nvarchar(max)", - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(255)", - oldMaxLength: 255); - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Url", - table: "News", - type: "varchar(255)", - unicode: false, - maxLength: 255, - nullable: false, - oldClrType: typeof(string), - oldType: "varchar(max)", - oldUnicode: false); - - migrationBuilder.AlterColumn( - name: "Title", - table: "News", - type: "nvarchar(255)", - maxLength: 255, - nullable: false, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - - migrationBuilder.AddColumn( - name: "CreatedAt", - table: "News", - type: "datetime", - nullable: true); - - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231210055416_createQuizCenter.cs b/VNH.Infrastructure/Migrations/20231210055416_createQuizCenter.cs deleted file mode 100644 index 7b54616..0000000 --- a/VNH.Infrastructure/Migrations/20231210055416_createQuizCenter.cs +++ /dev/null @@ -1,231 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - /// - public partial class createQuizCenter : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK__Quiz__Id__29221CFB", - table: "Quiz"); - - migrationBuilder.DropColumn( - name: "Answer1", - table: "Quiz"); - - migrationBuilder.DropColumn( - name: "Answer2", - table: "Quiz"); - - migrationBuilder.DropColumn( - name: "Answer3", - table: "Quiz"); - - migrationBuilder.DropColumn( - name: "Answer4", - table: "Quiz"); - - migrationBuilder.DropColumn( - name: "RightAnswer", - table: "Quiz"); - - migrationBuilder.RenameColumn( - name: "Question", - table: "Quiz", - newName: "Content"); - - migrationBuilder.AddColumn( - name: "MultipleChoiceId", - table: "Quiz", - type: "uniqueidentifier", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.AddColumn( - name: "QuizAnswerId", - table: "Quiz", - type: "uniqueidentifier", - maxLength: 500, - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - migrationBuilder.CreateTable( - name: "MultipleChoise", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Title = table.Column(type: "nvarchar(max)", nullable: false), - Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), - CreatedAt = table.Column(type: "datetime", maxLength: 500, nullable: false), - UpdatedAt = table.Column(type: "datetime", nullable: true), - WorkTime = table.Column(type: "int", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_MultipleChoise", x => x.Id); - table.ForeignKey( - name: "FK__MultipleChoice__UserId__06CD04F7", - column: x => x.UserId, - principalTable: "User", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "QuizAnswer", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - QuizId = table.Column(type: "uniqueidentifier", nullable: false), - Content = table.Column(type: "nvarchar(max)", nullable: false), - isCorrect = table.Column(type: "bit", maxLength: 500, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_QuizAnswer", x => x.Id); - table.ForeignKey( - name: "FK__QuizAnswers__QuizId__1AD3FVA4", - column: x => x.QuizId, - principalTable: "Quiz", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ExamHistory", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - MultipleChoiceId = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - Scores = table.Column(type: "int", nullable: false), - CompletionTime = table.Column(type: "int", nullable: false), - StarDate = table.Column(type: "datetime", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ExamHistory", x => x.Id); - table.ForeignKey( - name: "FK_ExamHistory_MultipleChoise_MultipleChoiceId", - column: x => x.MultipleChoiceId, - principalTable: "MultipleChoise", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - - migrationBuilder.CreateIndex( - name: "IX_Quiz_MultipleChoiceId", - table: "Quiz", - column: "MultipleChoiceId"); - - migrationBuilder.CreateIndex( - name: "IX_ExamHistory_MultipleChoiceId", - table: "ExamHistory", - column: "MultipleChoiceId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_MultipleChoise_UserId", - table: "MultipleChoise", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_QuizAnswer_QuizId", - table: "QuizAnswer", - column: "QuizId"); - - migrationBuilder.AddForeignKey( - name: "FK__MultipleChoice__Id__07C12930", - table: "Quiz", - column: "MultipleChoiceId", - principalTable: "MultipleChoise", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK__MultipleChoice__Id__07C12930", - table: "Quiz"); - - migrationBuilder.DropTable( - name: "ExamHistory"); - - migrationBuilder.DropTable( - name: "QuizAnswer"); - - migrationBuilder.DropTable( - name: "MultipleChoise"); - - migrationBuilder.DropIndex( - name: "IX_Quiz_MultipleChoiceId", - table: "Quiz"); - - migrationBuilder.DropColumn( - name: "MultipleChoiceId", - table: "Quiz"); - - migrationBuilder.DropColumn( - name: "QuizAnswerId", - table: "Quiz"); - - migrationBuilder.RenameColumn( - name: "Content", - table: "Quiz", - newName: "Question"); - - migrationBuilder.AddColumn( - name: "Answer1", - table: "Quiz", - type: "nvarchar(500)", - maxLength: 500, - nullable: true); - - migrationBuilder.AddColumn( - name: "Answer2", - table: "Quiz", - type: "nvarchar(500)", - maxLength: 500, - nullable: true); - - migrationBuilder.AddColumn( - name: "Answer3", - table: "Quiz", - type: "nvarchar(500)", - maxLength: 500, - nullable: true); - - migrationBuilder.AddColumn( - name: "Answer4", - table: "Quiz", - type: "nvarchar(500)", - maxLength: 500, - nullable: true); - - migrationBuilder.AddColumn( - name: "RightAnswer", - table: "Quiz", - type: "nvarchar(500)", - maxLength: 500, - nullable: true); - - - migrationBuilder.AddForeignKey( - name: "FK__Quiz__Id__29221CFB", - table: "Quiz", - column: "Id", - principalTable: "Exercise", - principalColumn: "Id"); - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231210060043_dropQuizAnswerIdInTableQuiz.cs b/VNH.Infrastructure/Migrations/20231210060043_dropQuizAnswerIdInTableQuiz.cs deleted file mode 100644 index 15540af..0000000 --- a/VNH.Infrastructure/Migrations/20231210060043_dropQuizAnswerIdInTableQuiz.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - /// - public partial class dropQuizAnswerIdInTableQuiz : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "QuizAnswerId", - table: "Quiz"); - - migrationBuilder.AlterColumn( - name: "Content", - table: "Quiz", - type: "nvarchar(500)", - maxLength: 500, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Content", - table: "Quiz", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(500)", - oldMaxLength: 500, - oldNullable: true); - - migrationBuilder.AddColumn( - name: "QuizAnswerId", - table: "Quiz", - type: "uniqueidentifier", - maxLength: 500, - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); - - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231215075132_add_file_path.cs b/VNH.Infrastructure/Migrations/20231215075132_add_file_path.cs deleted file mode 100644 index 8300ce2..0000000 --- a/VNH.Infrastructure/Migrations/20231215075132_add_file_path.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace VNH.Infrastructure.Migrations -{ - /// - public partial class add_file_path : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "FilePath", - table: "Document", - type: "varchar(max)", - nullable: true); - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "FilePath", - table: "Document"); - - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231215123041_add_data.cs b/VNH.Infrastructure/Migrations/20231215123041_add_data.cs deleted file mode 100644 index f461a78..0000000 --- a/VNH.Infrastructure/Migrations/20231215123041_add_data.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace VNH.Infrastructure.Migrations -{ - /// - public partial class add_data : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - - migrationBuilder.InsertData( - table: "Topic", - columns: new[] { "Id", "AuthorId", "CreatedAt", "Title", "UpdatedAt" }, - values: new object[,] - { - { new Guid("00000000-0000-0000-0000-000000000000"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Lịch sử Cổ đại", null }, - { new Guid("0228bc1a-09d8-49c1-a893-9b58fff09442"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chính sách đổi mới", null }, - { new Guid("0549df33-daaf-4b25-8c80-f1ebf3ef8233"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Phong trào Duy Tân", null }, - { new Guid("1a9c5fa8-dd86-402c-bdf9-6e0a13519b43"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Giao lưu văn hóa quốc tế", null }, - { new Guid("2fc72e05-a0eb-4487-b5a0-da609e1a5356"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nhà Nguyễn", null }, - { new Guid("3e6a861e-7683-4a6e-a990-6e3629c44b83"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Việt Nam", null }, - { new Guid("5228013c-d05d-41bc-8706-f547b783e3d9"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ đổi mới", null }, - { new Guid("5c047dbf-a6ef-48c7-a582-dd867f5e6e7a"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ thuộc địa Pháp", null }, - { new Guid("7b673511-8385-4a5a-9788-7cdb1b1d0057"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Những thăng trầm của triều đại Lê", null }, - { new Guid("7c061076-9a98-4eef-829b-47eb43bb58ba"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Lịch sử thời kỳ thuộc địa", null }, - { new Guid("86855d15-2e3b-475a-89c5-726a06f24fc0"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nhà Hậu Lê", null }, - { new Guid("8703f2b4-2952-4936-b0ef-f95ee5144562"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Anh hùng", null }, - { new Guid("8c2dc0b5-376c-4719-8ee9-a2f5cf247f68"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nghệ thuật và văn hóa đương đại", null }, - { new Guid("8c5979fe-5d04-4495-a9ef-675f06a462b9"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ Trung đại", null }, - { new Guid("bf8ef934-06b2-45ec-aff1-a1d20c7d50a2"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Việt Nam", null }, - { new Guid("c2e754b9-e397-432d-8032-af79f93532b1"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Vương quốc Âu Lạc.", null }, - { new Guid("c80c4467-c398-406d-a91d-500b987219a3"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Văn hóa và Nghệ thuật", null }, - { new Guid("d5ccd739-1898-4cc6-bbb5-4f4df93c43e1"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Đời sống trong xã cổ Đông Sơn.", null }, - { new Guid("ecbc1c53-18af-4c2b-b2ce-195f6e6f0006"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Văn hóa dân gian", null }, - { new Guid("f0db090d-2a6f-4c21-af27-ed8960249919"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Pháp-Đông Dương", null }, - { new Guid("f133d506-4d93-4b04-bea5-f5d6fdebcfdd"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thách thức hiện đại hóa", null }, - { new Guid("fa1a97b2-3819-40e1-bb94-1981dc75e702"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Triều đại Lý.", null } - }); - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231215124506_add_data_news.cs b/VNH.Infrastructure/Migrations/20231215124506_add_data_news.cs deleted file mode 100644 index 5d4ce84..0000000 --- a/VNH.Infrastructure/Migrations/20231215124506_add_data_news.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace VNH.Infrastructure.Migrations -{ - /// - public partial class add_data_news : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - - migrationBuilder.AlterColumn( - name: "Url", - table: "News", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "varchar(max)", - oldUnicode: false); - - migrationBuilder.AlterColumn( - name: "Title", - table: "News", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)"); - - migrationBuilder.AlterColumn( - name: "Image", - table: "News", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Description", - table: "News", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "text", - oldNullable: true); - - migrationBuilder.AddColumn( - name: "CreatedAt", - table: "News", - type: "datetime2", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - migrationBuilder.DropColumn( - name: "CreatedAt", - table: "News"); - - migrationBuilder.AlterColumn( - name: "Url", - table: "News", - type: "varchar(max)", - unicode: false, - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Title", - table: "News", - type: "nvarchar(max)", - nullable: false, - defaultValue: "", - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Image", - table: "News", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - migrationBuilder.AlterColumn( - name: "Description", - table: "News", - type: "text", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); - - } - } -} diff --git a/VNH.Infrastructure/Migrations/20231215124506_add_data_news.Designer.cs b/VNH.Infrastructure/Migrations/20231218055937_init.Designer.cs similarity index 96% rename from VNH.Infrastructure/Migrations/20231215124506_add_data_news.Designer.cs rename to VNH.Infrastructure/Migrations/20231218055937_init.Designer.cs index e2255f9..f83bf6d 100644 --- a/VNH.Infrastructure/Migrations/20231215124506_add_data_news.Designer.cs +++ b/VNH.Infrastructure/Migrations/20231218055937_init.Designer.cs @@ -12,8 +12,8 @@ namespace VNH.Infrastructure.Migrations { [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231215124506_add_data_news")] - partial class add_data_news + [Migration("20231218055937_init")] + partial class init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -1029,49 +1029,49 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9587), + CreatedAt = new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1413), Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", Title = "Nội dung vi phạm quy định về quyền riêng tư" }, new { Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9607), + CreatedAt = new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1435), Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", Title = "Nội dung xấu, xúc phạm, hay kỳ thị" }, new { Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9612), + CreatedAt = new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1438), Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" }, new { Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9616), + CreatedAt = new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1442), Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" }, new { Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9620), + CreatedAt = new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1445), Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" }, new { Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9623), + CreatedAt = new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1449), Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" }, new { Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9627), + CreatedAt = new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1453), Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" }); @@ -1100,21 +1100,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "2136f784-5172-4046-901e-801367014f68", + ConcurrencyStamp = "b8563bb9-4b36-4a5b-864b-36b593d5d36c", Name = "admin", NormalizedName = "admin" }, new { Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "b056248f-657f-4de1-8180-807862c43ff5", + ConcurrencyStamp = "f5fcff63-f067-448e-b72e-aefb426c558d", Name = "teacher", NormalizedName = "teacher" }, new { Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "0722bf9f-7f09-4d19-a6dc-72beb371e784", + ConcurrencyStamp = "f2c7ce5d-de4f-496a-bc53-129835856dc1", Name = "student", NormalizedName = "student" }); @@ -1215,127 +1215,127 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) }, new { - Id = new Guid("fe64196e-d1b5-4f01-964d-a5cfb6581bb4"), + Id = new Guid("daa7b78e-80a7-4b24-92c2-34fa17d77da9"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Thời kỳ Trung đại" }, new { - Id = new Guid("1119badd-3874-467a-92a0-0c620ae136e2"), + Id = new Guid("81631b70-12f2-4118-b362-16ce4f9b1b85"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Lịch sử thời kỳ thuộc địa" }, new { - Id = new Guid("185dc21d-5fba-4552-9ed9-be749486f324"), + Id = new Guid("a164d0be-812c-4a9c-ab5f-c9d4d04bb4cf"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Chiến tranh Việt Nam" }, new { - Id = new Guid("e06f0b87-148d-485e-891e-1bc83f35ceea"), + Id = new Guid("52cd4ca9-3029-40dd-bbf2-e44d726b9b2e"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Thời kỳ đổi mới" }, new { - Id = new Guid("ba5592bf-dd43-4fbe-ad3f-af60b07352b1"), + Id = new Guid("568558af-648d-46ae-8317-ade70012f3cf"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Văn hóa và Nghệ thuật" }, new { - Id = new Guid("8a2a6d74-148f-4f3e-8fb1-129d578a5db3"), + Id = new Guid("2f3dea3f-47d1-40aa-ad9b-25dc19fad03f"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Đời sống trong xã cổ Đông Sơn." }, new { - Id = new Guid("9304db08-37b6-4f25-83a7-e12c510b8f23"), + Id = new Guid("12f52ba9-2673-4d2c-86a8-984335cc4129"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Vương quốc Âu Lạc." }, new { - Id = new Guid("20936bf1-03ca-49ba-83e8-4c3b0d520932"), + Id = new Guid("975ade78-8f23-41e2-8b7e-0885f4daa97c"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Triều đại Lý." }, new { - Id = new Guid("e25909f4-d1c2-47b8-a6a1-58ed5504fa7c"), + Id = new Guid("eca76873-e0d8-4c7f-ae25-f05707e8ee35"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Những thăng trầm của triều đại Lê" }, new { - Id = new Guid("811fdbac-0812-4d35-8c8b-24d991c384fa"), + Id = new Guid("ab9bfbd4-26a1-42b0-bef6-ac239e8df4a3"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Thời kỳ thuộc địa Pháp" }, new { - Id = new Guid("64133fc8-1783-4cbf-9884-f77c61a6c61b"), + Id = new Guid("95807a63-e5df-49af-bb11-0c210cff64d9"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Phong trào Duy Tân" }, new { - Id = new Guid("7875af75-b4fc-4c19-9a56-930f9bbc5fe4"), + Id = new Guid("98d9ed5f-3ba9-44ed-bd0b-f887cb34f1f8"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Chiến tranh Pháp-Đông Dương" }, new { - Id = new Guid("fb74d62c-7a84-4675-a254-56c934398737"), + Id = new Guid("fe70bbdb-fa47-4bde-8b72-6a531488ac4d"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Chiến tranh Việt Nam" }, new { - Id = new Guid("7045e99f-65ab-4c0b-9088-350011c9336d"), + Id = new Guid("27fd3609-9965-4d57-99b7-4fcbb8653547"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Chính sách đổi mới" }, new { - Id = new Guid("626e93b8-5186-48d9-9d02-8f18004b6d45"), + Id = new Guid("be364be8-ed1c-4997-8ed5-4b0b53857cb8"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Thách thức hiện đại hóa" }, new { - Id = new Guid("dde8818f-653c-4a1e-8976-86dae420034e"), + Id = new Guid("73c9975b-7e5d-4a67-be4f-ea8088ef0b1a"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Văn hóa dân gian" }, new { - Id = new Guid("1436bfae-62d7-48a0-b6fe-661803294bfe"), + Id = new Guid("25a66923-d6e8-47da-9b8b-3d5f2efa0f33"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Nghệ thuật và văn hóa đương đại" }, new { - Id = new Guid("0462e243-80d7-40df-af11-1c2d2a346745"), + Id = new Guid("3f447575-d3f3-415d-bc59-5a1397ff4938"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Giao lưu văn hóa quốc tế" }, new { - Id = new Guid("8e732f75-5542-4a66-b53c-68e0ce5f22d5"), + Id = new Guid("19ef7fc7-5f58-4e90-a59a-3972ad2ef157"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Nhà Nguyễn" }, new { - Id = new Guid("dd1d0dc2-825b-4052-827e-6831b21ba87f"), + Id = new Guid("8b2cc6db-df2a-4390-a6a8-9d40c27ec2d1"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Anh hùng" }, new { - Id = new Guid("735d3139-7e14-497e-b1e5-21a01ed76d63"), + Id = new Guid("3fe8d29b-059e-477a-b7f7-a1401545a4b8"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Nhà Hậu Lê" }); @@ -1440,7 +1440,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), AccessFailedCount = 0, - ConcurrencyStamp = "fd3361d8-877e-40ee-aae1-6efdce1b8056", + ConcurrencyStamp = "4cc11f7a-e277-40e9-8018-03bd9affb56d", DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), Email = "admin@gmail.com", EmailConfirmed = true, @@ -1451,7 +1451,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) LockoutEnabled = false, NormalizedEmail = "onionwebdev@gmail.com", NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAENN17nFItiWgMPsbrrWZ6KAtM9gKQP3NbJwyowEuW1bb2TqSBaerxyCjlOuDGMh5LA==", + PasswordHash = "AQAAAAEAACcQAAAAELthC2YX0yD3LyCfcc90BjRdfZ/u/PQV2FZWsQ2HpyTwsxIOediSiMRDm+kImP50+Q==", PhoneNumberConfirmed = false, SecurityStamp = "", TwoFactorEnabled = false, diff --git a/VNH.Infrastructure/Migrations/20231129161341_init.cs b/VNH.Infrastructure/Migrations/20231218055937_init.cs similarity index 83% rename from VNH.Infrastructure/Migrations/20231129161341_init.cs rename to VNH.Infrastructure/Migrations/20231218055937_init.cs index 28d411d..3f367b7 100644 --- a/VNH.Infrastructure/Migrations/20231129161341_init.cs +++ b/VNH.Infrastructure/Migrations/20231218055937_init.cs @@ -61,11 +61,11 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - Title = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), - Description = table.Column(type: "text", nullable: true), - Image = table.Column(type: "text", nullable: true), - CreatedAt = table.Column(type: "datetime", nullable: true), - Url = table.Column(type: "varchar(255)", unicode: false, maxLength: 255, nullable: false) + Title = table.Column(type: "nvarchar(max)", nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: true), + Image = table.Column(type: "nvarchar(max)", nullable: true), + Url = table.Column(type: "nvarchar(max)", nullable: true) }, constraints: table => { @@ -136,6 +136,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Gender = table.Column(type: "int", nullable: false), Image = table.Column(type: "nvarchar(max)", maxLength: 3145728, nullable: true), NumberConfirm = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), UserName = table.Column(type: "nvarchar(max)", nullable: true), NormalizedUserName = table.Column(type: "nvarchar(max)", nullable: true), Email = table.Column(type: "nvarchar(max)", nullable: true), @@ -188,6 +189,13 @@ protected override void Up(MigrationBuilder migrationBuilder) principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); + + table.ForeignKey( + name: "FK_AppUserRoles_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -200,7 +208,8 @@ protected override void Up(MigrationBuilder migrationBuilder) UserId = table.Column(type: "uniqueidentifier", nullable: true), CreatedAt = table.Column(type: "datetime", nullable: true), UpdatedAt = table.Column(type: "datetime", nullable: true), - Image = table.Column(type: "nvarchar(max)", nullable: true) + Image = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -220,8 +229,10 @@ protected override void Up(MigrationBuilder migrationBuilder) Title = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), SubId = table.Column(type: "nvarchar(max)", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false), + FilePath = table.Column(type: "nvarchar(max)", nullable: true), FileName = table.Column(type: "nvarchar(max)", nullable: true), - UserId = table.Column(type: "uniqueidentifier", unicode: false, maxLength: 255, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), CreatedAt = table.Column(type: "datetime", nullable: false), UpdatedAt = table.Column(type: "datetime", nullable: true) }, @@ -235,6 +246,29 @@ protected override void Up(MigrationBuilder migrationBuilder) principalColumn: "Id"); }); + migrationBuilder.CreateTable( + name: "MultipleChoise", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Title = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false), + CreatedAt = table.Column(type: "datetime", maxLength: 500, nullable: false), + UpdatedAt = table.Column(type: "datetime", nullable: true), + WorkTime = table.Column(type: "int", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MultipleChoise", x => x.Id); + table.ForeignKey( + name: "FK__MultipleChoice__UserId__06CD04F7", + column: x => x.UserId, + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "NotificationDetails", columns: table => new @@ -274,7 +308,8 @@ protected override void Up(MigrationBuilder migrationBuilder) ViewNumber = table.Column(type: "int", nullable: false), AuthorId = table.Column(type: "uniqueidentifier", nullable: true), UpdatedAt = table.Column(type: "datetime", nullable: true), - CreatedAt = table.Column(type: "datetime", nullable: false) + CreatedAt = table.Column(type: "datetime", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -406,7 +441,8 @@ protected override void Up(MigrationBuilder migrationBuilder) UrlVideo = table.Column(type: "varchar(255)", unicode: false, maxLength: 255, nullable: true), Description = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), CourseId = table.Column(type: "uniqueidentifier", nullable: true), - ExerciseId = table.Column(type: "uniqueidentifier", nullable: true) + ExerciseId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -441,6 +477,47 @@ protected override void Up(MigrationBuilder migrationBuilder) principalColumn: "Id"); }); + migrationBuilder.CreateTable( + name: "ExamHistory", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + MultipleChoiceId = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + Scores = table.Column(type: "int", nullable: false), + CompletionTime = table.Column(type: "int", nullable: false), + StarDate = table.Column(type: "datetime", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ExamHistory", x => x.Id); + table.ForeignKey( + name: "FK_ExamHistory_MultipleChoise_MultipleChoiceId", + column: x => x.MultipleChoiceId, + principalTable: "MultipleChoise", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Quiz", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Content = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + MultipleChoiceId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Quiz", x => x.Id); + table.ForeignKey( + name: "FK__MultipleChoice__Id__07C12930", + column: x => x.MultipleChoiceId, + principalTable: "MultipleChoise", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "Answer", columns: table => new @@ -452,7 +529,8 @@ protected override void Up(MigrationBuilder migrationBuilder) CreatedAt = table.Column(type: "datetime", nullable: true), UpdatedAt = table.Column(type: "datetime", nullable: true), Confirm = table.Column(type: "bit", nullable: true), - MostConfirm = table.Column(type: "bit", nullable: true) + MostConfirm = table.Column(type: "bit", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -587,7 +665,8 @@ protected override void Up(MigrationBuilder migrationBuilder) UpdatedAt = table.Column(type: "datetime", nullable: true), UserId = table.Column(type: "uniqueidentifier", nullable: false), Image = table.Column(type: "nvarchar(max)", nullable: true), - ViewNumber = table.Column(type: "int", nullable: false) + ViewNumber = table.Column(type: "int", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false) }, constraints: table => { @@ -655,13 +734,34 @@ protected override void Up(MigrationBuilder migrationBuilder) principalColumn: "Id"); }); + migrationBuilder.CreateTable( + name: "QuizAnswer", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + QuizId = table.Column(type: "uniqueidentifier", nullable: false), + Content = table.Column(type: "nvarchar(max)", nullable: false), + isCorrect = table.Column(type: "bit", maxLength: 500, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_QuizAnswer", x => x.Id); + table.ForeignKey( + name: "FK__QuizAnswers__QuizId__1AD3FVA4", + column: x => x.QuizId, + principalTable: "Quiz", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "AnswerVote", columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), AnswerId = table.Column(type: "uniqueidentifier", nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true) + UserId = table.Column(type: "uniqueidentifier", nullable: true), + QuestionId = table.Column(type: "uniqueidentifier", nullable: true) }, constraints: table => { @@ -884,28 +984,6 @@ protected override void Up(MigrationBuilder migrationBuilder) principalColumn: "Id"); }); - migrationBuilder.CreateTable( - name: "Quiz", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Question = table.Column(type: "nvarchar(max)", nullable: true), - Answer1 = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - Answer2 = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - Answer3 = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - Answer4 = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), - RightAnswer = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Quiz", x => x.Id); - table.ForeignKey( - name: "FK__Quiz__Id__29221CFB", - column: x => x.Id, - principalTable: "Exercise", - principalColumn: "Id"); - }); - migrationBuilder.CreateTable( name: "PostSubComment", columns: table => new @@ -937,13 +1015,13 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: new[] { "Id", "CreatedAt", "Description", "Title" }, values: new object[,] { - { new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1890), "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", "Nội dung xấu, xúc phạm, hay kỳ thị" }, - { new Guid("3043c693-b3c9-453e-9876-31c943222576"), new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1905), "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" }, - { new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1894), "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", "Chứa nội dung tự tử hoặc tự gây thương tổn" }, - { new Guid("4a780087-9058-41c9-b84b-944d1a502010"), new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1899), "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", "Bài đăng chứa thông tin sai lệch hoặc giả mạo" }, - { new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1892), "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", "Chứa nội dung bạo lực hoặc đội nhóm xấu" }, - { new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1897), "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" }, - { new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1878), " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", "Nội dung vi phạm quy định về quyền riêng tư" } + { new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1435), "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", "Nội dung xấu, xúc phạm, hay kỳ thị" }, + { new Guid("3043c693-b3c9-453e-9876-31c943222576"), new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1453), "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" }, + { new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1442), "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", "Chứa nội dung tự tử hoặc tự gây thương tổn" }, + { new Guid("4a780087-9058-41c9-b84b-944d1a502010"), new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1449), "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", "Bài đăng chứa thông tin sai lệch hoặc giả mạo" }, + { new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1438), "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", "Chứa nội dung bạo lực hoặc đội nhóm xấu" }, + { new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1445), "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" }, + { new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), new DateTime(2023, 12, 18, 12, 59, 36, 825, DateTimeKind.Local).AddTicks(1413), " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", "Nội dung vi phạm quy định về quyền riêng tư" } }); migrationBuilder.InsertData( @@ -951,21 +1029,50 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, values: new object[,] { - { new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), "ed14ffc7-e2d5-4165-a466-43faa539db13", "student", "student" }, - { new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), "c998aba1-7d62-483a-a82c-dffca027ed0e", "admin", "admin" }, - { new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), "ae9a8b2b-7978-448e-a405-c884869f328d", "teacher", "teacher" } + { new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), "f2c7ce5d-de4f-496a-bc53-129835856dc1", "student", "student" }, + { new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), "b8563bb9-4b36-4a5b-864b-36b593d5d36c", "admin", "admin" }, + { new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), "f5fcff63-f067-448e-b72e-aefb426c558d", "teacher", "teacher" } }); migrationBuilder.InsertData( table: "User", - columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "DateOfBirth", "Email", "EmailConfirmed", "Fullname", "Gender", "Image", "Introduction", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "NumberConfirm", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" }, - values: new object[] { new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), 0, "4e2eef99-65a4-4b8a-a919-145ed60b15a2", new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), "admin@gmail.com", true, "Lương Xuân Nhất", 0, "", null, false, null, "onionwebdev@gmail.com", "admin", null, "AQAAAAEAACcQAAAAEAL81EjrI0KYNGldHCVGr6VWAAG6C3NTtw/mpPYP8v1ClFiJBnsTwh8zzWucfocLyQ==", null, false, "", false, "admin" }); + columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "DateOfBirth", "Email", "EmailConfirmed", "Fullname", "Gender", "Image", "Introduction", "IsDeleted", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "NumberConfirm", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" }, + values: new object[] { new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), 0, "4cc11f7a-e277-40e9-8018-03bd9affb56d", new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), "admin@gmail.com", true, "Lương Xuân Nhất", 0, "", null, false, false, null, "onionwebdev@gmail.com", "admin", null, "AQAAAAEAACcQAAAAELthC2YX0yD3LyCfcc90BjRdfZ/u/PQV2FZWsQ2HpyTwsxIOediSiMRDm+kImP50+Q==", null, false, "", false, "admin" }); migrationBuilder.InsertData( table: "UserRoles", columns: new[] { "RoleId", "UserId" }, values: new object[] { new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5") }); + migrationBuilder.InsertData( + table: "Topic", + columns: new[] { "Id", "AuthorId", "CreatedAt", "Title", "UpdatedAt" }, + values: new object[,] + { + { new Guid("00000000-0000-0000-0000-000000000000"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Lịch sử Cổ đại", null }, + { new Guid("12f52ba9-2673-4d2c-86a8-984335cc4129"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Vương quốc Âu Lạc.", null }, + { new Guid("19ef7fc7-5f58-4e90-a59a-3972ad2ef157"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nhà Nguyễn", null }, + { new Guid("25a66923-d6e8-47da-9b8b-3d5f2efa0f33"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nghệ thuật và văn hóa đương đại", null }, + { new Guid("27fd3609-9965-4d57-99b7-4fcbb8653547"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chính sách đổi mới", null }, + { new Guid("2f3dea3f-47d1-40aa-ad9b-25dc19fad03f"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Đời sống trong xã cổ Đông Sơn.", null }, + { new Guid("3f447575-d3f3-415d-bc59-5a1397ff4938"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Giao lưu văn hóa quốc tế", null }, + { new Guid("3fe8d29b-059e-477a-b7f7-a1401545a4b8"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nhà Hậu Lê", null }, + { new Guid("52cd4ca9-3029-40dd-bbf2-e44d726b9b2e"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ đổi mới", null }, + { new Guid("568558af-648d-46ae-8317-ade70012f3cf"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Văn hóa và Nghệ thuật", null }, + { new Guid("73c9975b-7e5d-4a67-be4f-ea8088ef0b1a"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Văn hóa dân gian", null }, + { new Guid("81631b70-12f2-4118-b362-16ce4f9b1b85"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Lịch sử thời kỳ thuộc địa", null }, + { new Guid("8b2cc6db-df2a-4390-a6a8-9d40c27ec2d1"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Anh hùng", null }, + { new Guid("95807a63-e5df-49af-bb11-0c210cff64d9"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Phong trào Duy Tân", null }, + { new Guid("975ade78-8f23-41e2-8b7e-0885f4daa97c"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Triều đại Lý.", null }, + { new Guid("98d9ed5f-3ba9-44ed-bd0b-f887cb34f1f8"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Pháp-Đông Dương", null }, + { new Guid("a164d0be-812c-4a9c-ab5f-c9d4d04bb4cf"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Việt Nam", null }, + { new Guid("ab9bfbd4-26a1-42b0-bef6-ac239e8df4a3"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ thuộc địa Pháp", null }, + { new Guid("be364be8-ed1c-4997-8ed5-4b0b53857cb8"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thách thức hiện đại hóa", null }, + { new Guid("daa7b78e-80a7-4b24-92c2-34fa17d77da9"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ Trung đại", null }, + { new Guid("eca76873-e0d8-4c7f-ae25-f05707e8ee35"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Những thăng trầm của triều đại Lê", null }, + { new Guid("fe70bbdb-fa47-4bde-8b72-6a531488ac4d"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Việt Nam", null } + }); + migrationBuilder.CreateIndex( name: "IX_Answer_AuthorId", table: "Answer", @@ -1046,6 +1153,12 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "DocumentSave", column: "UserId"); + migrationBuilder.CreateIndex( + name: "IX_ExamHistory_MultipleChoiceId", + table: "ExamHistory", + column: "MultipleChoiceId", + unique: true); + migrationBuilder.CreateIndex( name: "IX_ExerciseDetail_ExerciseId", table: "ExerciseDetail", @@ -1061,6 +1174,11 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "Lesson", column: "CourseId"); + migrationBuilder.CreateIndex( + name: "IX_MultipleChoise_UserId", + table: "MultipleChoise", + column: "UserId"); + migrationBuilder.CreateIndex( name: "IX_NotificationDetails_NotificationId", table: "NotificationDetails", @@ -1196,6 +1314,16 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "QuestionTag", column: "TagId"); + migrationBuilder.CreateIndex( + name: "IX_Quiz_MultipleChoiceId", + table: "Quiz", + column: "MultipleChoiceId"); + + migrationBuilder.CreateIndex( + name: "IX_QuizAnswer_QuizId", + table: "QuizAnswer", + column: "QuizId"); + migrationBuilder.CreateIndex( name: "IX_Search_UserId", table: "Search", @@ -1254,6 +1382,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "DocumentSave"); + migrationBuilder.DropTable( + name: "ExamHistory"); + migrationBuilder.DropTable( name: "ExerciseDetail"); @@ -1291,7 +1422,7 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "QuestionTag"); migrationBuilder.DropTable( - name: "Quiz"); + name: "QuizAnswer"); migrationBuilder.DropTable( name: "Roles"); @@ -1317,6 +1448,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "Document"); + migrationBuilder.DropTable( + name: "Exercise"); + migrationBuilder.DropTable( name: "Notification"); @@ -1330,25 +1464,28 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "Tag"); migrationBuilder.DropTable( - name: "Exercise"); + name: "Quiz"); migrationBuilder.DropTable( name: "Answer"); + migrationBuilder.DropTable( + name: "Lesson"); + migrationBuilder.DropTable( name: "Post"); migrationBuilder.DropTable( - name: "Lesson"); + name: "MultipleChoise"); migrationBuilder.DropTable( name: "Question"); migrationBuilder.DropTable( - name: "Topic"); + name: "Course"); migrationBuilder.DropTable( - name: "Course"); + name: "Topic"); migrationBuilder.DropTable( name: "User"); diff --git a/VNH.Infrastructure/Migrations/20231215123041_add_data.Designer.cs b/VNH.Infrastructure/Migrations/20231221023249_update_score.Designer.cs similarity index 95% rename from VNH.Infrastructure/Migrations/20231215123041_add_data.Designer.cs rename to VNH.Infrastructure/Migrations/20231221023249_update_score.Designer.cs index e17fa5c..c4d539e 100644 --- a/VNH.Infrastructure/Migrations/20231215123041_add_data.Designer.cs +++ b/VNH.Infrastructure/Migrations/20231221023249_update_score.Designer.cs @@ -12,8 +12,8 @@ namespace VNH.Infrastructure.Migrations { [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231215123041_add_data")] - partial class add_data + [Migration("20231221023249_update_score")] + partial class update_score { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -403,8 +403,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MultipleChoiceId") .HasColumnType("uniqueidentifier"); - b.Property("Scores") - .HasColumnType("int"); + b.Property("Scores") + .HasColumnType("real"); b.Property("StarDate") .HasColumnType("datetime"); @@ -649,20 +649,20 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Id") .HasColumnType("uniqueidentifier"); + b.Property("CreatedAt") + .HasColumnType("datetime2"); + b.Property("Description") - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Image") - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Title") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Url") - .IsRequired() - .IsUnicode(false) - .HasColumnType("varchar(max)"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -1029,49 +1029,49 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 15, 19, 30, 41, 57, DateTimeKind.Local).AddTicks(4061), + CreatedAt = new DateTime(2023, 12, 21, 9, 32, 49, 475, DateTimeKind.Local).AddTicks(2693), Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", Title = "Nội dung vi phạm quy định về quyền riêng tư" }, new { Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 15, 19, 30, 41, 57, DateTimeKind.Local).AddTicks(4071), + CreatedAt = new DateTime(2023, 12, 21, 9, 32, 49, 475, DateTimeKind.Local).AddTicks(2703), Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", Title = "Nội dung xấu, xúc phạm, hay kỳ thị" }, new { Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 15, 19, 30, 41, 57, DateTimeKind.Local).AddTicks(4075), + CreatedAt = new DateTime(2023, 12, 21, 9, 32, 49, 475, DateTimeKind.Local).AddTicks(2705), Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" }, new { Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 15, 19, 30, 41, 57, DateTimeKind.Local).AddTicks(4077), + CreatedAt = new DateTime(2023, 12, 21, 9, 32, 49, 475, DateTimeKind.Local).AddTicks(2707), Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" }, new { Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 15, 19, 30, 41, 57, DateTimeKind.Local).AddTicks(4080), + CreatedAt = new DateTime(2023, 12, 21, 9, 32, 49, 475, DateTimeKind.Local).AddTicks(2709), Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" }, new { Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 15, 19, 30, 41, 57, DateTimeKind.Local).AddTicks(4081), + CreatedAt = new DateTime(2023, 12, 21, 9, 32, 49, 475, DateTimeKind.Local).AddTicks(2711), Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" }, new { Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 15, 19, 30, 41, 57, DateTimeKind.Local).AddTicks(4083), + CreatedAt = new DateTime(2023, 12, 21, 9, 32, 49, 475, DateTimeKind.Local).AddTicks(2712), Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" }); @@ -1100,21 +1100,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "1d696c35-b8c8-4f5e-9a13-ffb10908ea76", + ConcurrencyStamp = "9eb37f98-d073-495b-946d-d18b1c15a5b4", Name = "admin", NormalizedName = "admin" }, new { Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "aa87c8e0-a3a6-4b25-9589-989cd5947400", + ConcurrencyStamp = "f12f29f7-56ac-47f9-8675-8bef61d99f0b", Name = "teacher", NormalizedName = "teacher" }, new { Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "87c2e4f9-7be0-465a-829c-463e1b368b87", + ConcurrencyStamp = "b93e7829-5bb9-4570-8e34-fa89f8060520", Name = "student", NormalizedName = "student" }); @@ -1215,127 +1215,127 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) }, new { - Id = new Guid("8c5979fe-5d04-4495-a9ef-675f06a462b9"), + Id = new Guid("9f908dfd-7aaa-46ef-8a9f-fcf99e7cea43"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Thời kỳ Trung đại" }, new { - Id = new Guid("7c061076-9a98-4eef-829b-47eb43bb58ba"), + Id = new Guid("16091b4c-d7f1-40d7-aa89-4eb496a4795d"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Lịch sử thời kỳ thuộc địa" }, new { - Id = new Guid("3e6a861e-7683-4a6e-a990-6e3629c44b83"), + Id = new Guid("687e1b3f-8a33-4b6a-9d8b-ecc1c49838de"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Chiến tranh Việt Nam" }, new { - Id = new Guid("5228013c-d05d-41bc-8706-f547b783e3d9"), + Id = new Guid("bcfc4e59-8377-421d-a47c-95002c7ac638"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Thời kỳ đổi mới" }, new { - Id = new Guid("c80c4467-c398-406d-a91d-500b987219a3"), + Id = new Guid("b5adcc59-dd79-4c8e-8688-c7127f13433b"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Văn hóa và Nghệ thuật" }, new { - Id = new Guid("d5ccd739-1898-4cc6-bbb5-4f4df93c43e1"), + Id = new Guid("3e1629e6-9d3f-415a-a9e3-47251c4d6002"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Đời sống trong xã cổ Đông Sơn." }, new { - Id = new Guid("c2e754b9-e397-432d-8032-af79f93532b1"), + Id = new Guid("eedaea4e-15de-4dfb-ba8b-e6320581842a"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Vương quốc Âu Lạc." }, new { - Id = new Guid("fa1a97b2-3819-40e1-bb94-1981dc75e702"), + Id = new Guid("49405f7b-d079-457f-8378-c1bcb3c751b0"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Triều đại Lý." }, new { - Id = new Guid("7b673511-8385-4a5a-9788-7cdb1b1d0057"), + Id = new Guid("588533c0-232f-42e2-8f54-288f0f3d1d84"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Những thăng trầm của triều đại Lê" }, new { - Id = new Guid("5c047dbf-a6ef-48c7-a582-dd867f5e6e7a"), + Id = new Guid("4dce757c-c7c4-4237-a7aa-d7fcc94eb060"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Thời kỳ thuộc địa Pháp" }, new { - Id = new Guid("0549df33-daaf-4b25-8c80-f1ebf3ef8233"), + Id = new Guid("5c1e08a3-cdd0-40e4-acec-a9c8d795f2f0"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Phong trào Duy Tân" }, new { - Id = new Guid("f0db090d-2a6f-4c21-af27-ed8960249919"), + Id = new Guid("91cd591b-79eb-411f-b762-aa32dfa4153c"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Chiến tranh Pháp-Đông Dương" }, new { - Id = new Guid("bf8ef934-06b2-45ec-aff1-a1d20c7d50a2"), + Id = new Guid("cd00f319-706a-4bdd-a5ae-a3c2874ceb75"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Chiến tranh Việt Nam" }, new { - Id = new Guid("0228bc1a-09d8-49c1-a893-9b58fff09442"), + Id = new Guid("7fa22316-501f-4a49-9b45-b8671d1420a6"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Chính sách đổi mới" }, new { - Id = new Guid("f133d506-4d93-4b04-bea5-f5d6fdebcfdd"), + Id = new Guid("8c22250b-c2a8-40a2-a91d-212f3f8ab4c9"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Thách thức hiện đại hóa" }, new { - Id = new Guid("ecbc1c53-18af-4c2b-b2ce-195f6e6f0006"), + Id = new Guid("85f92f07-8597-4088-811e-8c2f101a1478"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Văn hóa dân gian" }, new { - Id = new Guid("8c2dc0b5-376c-4719-8ee9-a2f5cf247f68"), + Id = new Guid("a1afc68d-e877-47e0-afed-5c3d9d86a4f5"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Nghệ thuật và văn hóa đương đại" }, new { - Id = new Guid("1a9c5fa8-dd86-402c-bdf9-6e0a13519b43"), + Id = new Guid("14f5ea7b-f500-4b3d-818b-474acefdc280"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Giao lưu văn hóa quốc tế" }, new { - Id = new Guid("2fc72e05-a0eb-4487-b5a0-da609e1a5356"), + Id = new Guid("310ca0f2-3e7e-4db4-a8df-55b9a66e7f5e"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Nhà Nguyễn" }, new { - Id = new Guid("8703f2b4-2952-4936-b0ef-f95ee5144562"), + Id = new Guid("5b0474a0-4886-4af6-845f-63b287a22b43"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Anh hùng" }, new { - Id = new Guid("86855d15-2e3b-475a-89c5-726a06f24fc0"), + Id = new Guid("81638220-c64a-4c27-bd54-117913b0e93d"), AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), Title = "Nhà Hậu Lê" }); @@ -1440,7 +1440,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), AccessFailedCount = 0, - ConcurrencyStamp = "540f36b1-91a7-4ac4-9504-8dfcc30c9b38", + ConcurrencyStamp = "d3d562fc-7fb1-41fa-94da-dfc2b0436a2d", DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), Email = "admin@gmail.com", EmailConfirmed = true, @@ -1451,7 +1451,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) LockoutEnabled = false, NormalizedEmail = "onionwebdev@gmail.com", NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAEFGy6Sd6Q04EMZ0bEP9gBuz1lwApOd/oCAZpx/jXBYI83NAacoQNdm0k/HKfIUyuyQ==", + PasswordHash = "AQAAAAEAACcQAAAAENTB4k3TjUDNYD/3wADRWq8x4L7dDbaAZb1gxjQwsZJLyD7OFN40lPu1Z9xgH58OUA==", PhoneNumberConfirmed = false, SecurityStamp = "", TwoFactorEnabled = false, diff --git a/VNH.Infrastructure/Migrations/20231221023249_update_score.cs b/VNH.Infrastructure/Migrations/20231221023249_update_score.cs new file mode 100644 index 0000000..f793907 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231221023249_update_score.cs @@ -0,0 +1,41 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class update_score : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + + migrationBuilder.AlterColumn( + name: "Scores", + table: "ExamHistory", + type: "real", + nullable: false, + oldClrType: typeof(int), + oldType: "int"); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + migrationBuilder.AlterColumn( + name: "Scores", + table: "ExamHistory", + type: "int", + nullable: false, + oldClrType: typeof(float), + oldType: "real"); + + } + } +} diff --git a/VNH.Infrastructure/Migrations/20231210055416_createQuizCenter.Designer.cs b/VNH.Infrastructure/Migrations/20231222065421_update_attribute.Designer.cs similarity index 88% rename from VNH.Infrastructure/Migrations/20231210055416_createQuizCenter.Designer.cs rename to VNH.Infrastructure/Migrations/20231222065421_update_attribute.Designer.cs index 99daadd..083b0f2 100644 --- a/VNH.Infrastructure/Migrations/20231210055416_createQuizCenter.Designer.cs +++ b/VNH.Infrastructure/Migrations/20231222065421_update_attribute.Designer.cs @@ -12,8 +12,8 @@ namespace VNH.Infrastructure.Migrations { [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231210055416_createQuizCenter")] - partial class createQuizCenter + [Migration("20231222065421_update_attribute")] + partial class update_attribute { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -338,12 +338,17 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("datetime"); b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); + + b.Property("DownloadNumber") + .HasColumnType("int"); b.Property("FileName") .HasColumnType("nvarchar(max)"); + b.Property("FilePath") + .HasColumnType("nvarchar(max)"); + b.Property("IsDeleted") .HasColumnType("bit"); @@ -351,18 +356,17 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); + .HasColumnType("nvarchar(max)"); b.Property("UpdatedAt") .HasColumnType("datetime"); b.Property("UserId") - .HasMaxLength(255) - .IsUnicode(false) .HasColumnType("uniqueidentifier"); + b.Property("ViewNumber") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("UserId"); @@ -396,14 +400,14 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); - b.Property("CompletionTime") - .HasColumnType("datetime"); + b.Property("CompletionTime") + .HasColumnType("int"); b.Property("MultipleChoiceId") .HasColumnType("uniqueidentifier"); - b.Property("Scores") - .HasColumnType("int"); + b.Property("Scores") + .HasColumnType("real"); b.Property("StarDate") .HasColumnType("datetime"); @@ -426,13 +430,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("uniqueidentifier"); b.Property("CreatedAt") - .HasMaxLength(500) .HasColumnType("datetime"); b.Property("Description") .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); b.Property("Title") .IsRequired() @@ -648,20 +650,20 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Id") .HasColumnType("uniqueidentifier"); + b.Property("CreatedAt") + .HasColumnType("datetime2"); + b.Property("Description") - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Image") - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Title") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Url") - .IsRequired() - .IsUnicode(false) - .HasColumnType("varchar(max)"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -687,8 +689,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("bit"); b.Property("SubId") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.Property("Title") .HasMaxLength(255) @@ -873,8 +875,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); b.Property("UpdatedAt") .HasColumnType("datetime"); @@ -990,15 +991,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("uniqueidentifier"); b.Property("Content") - .HasColumnType("nvarchar(max)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.Property("MultipleChoiceId") .HasColumnType("uniqueidentifier"); - b.Property("QuizAnswerId") - .HasMaxLength(500) - .HasColumnType("uniqueidentifier"); - b.HasKey("Id"); b.HasIndex("MultipleChoiceId"); @@ -1031,49 +1029,49 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 10, 12, 54, 15, 795, DateTimeKind.Local).AddTicks(1001), + CreatedAt = new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(380), Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", Title = "Nội dung vi phạm quy định về quyền riêng tư" }, new { Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 10, 12, 54, 15, 795, DateTimeKind.Local).AddTicks(1015), + CreatedAt = new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(393), Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", Title = "Nội dung xấu, xúc phạm, hay kỳ thị" }, new { Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 10, 12, 54, 15, 795, DateTimeKind.Local).AddTicks(1018), + CreatedAt = new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(400), Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" }, new { Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 10, 12, 54, 15, 795, DateTimeKind.Local).AddTicks(1020), + CreatedAt = new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(403), Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" }, new { Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 10, 12, 54, 15, 795, DateTimeKind.Local).AddTicks(1022), + CreatedAt = new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(406), Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" }, new { Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 10, 12, 54, 15, 795, DateTimeKind.Local).AddTicks(1024), + CreatedAt = new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(408), Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" }, new { Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 10, 12, 54, 15, 795, DateTimeKind.Local).AddTicks(1026), + CreatedAt = new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(411), Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" }); @@ -1102,21 +1100,21 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) new { Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "1f84b605-ea8a-4e2f-8aab-69607402ece9", + ConcurrencyStamp = "7384f037-6d8d-48a6-a154-195d3a5db7ab", Name = "admin", NormalizedName = "admin" }, new { Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "450b81e3-beb2-4c71-ac2c-5dce651504ca", + ConcurrencyStamp = "a6163b8e-97ec-498b-8fd9-e465ff3543e1", Name = "teacher", NormalizedName = "teacher" }, new { Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "28a35153-df9b-4037-8bd7-7457ee89401d", + ConcurrencyStamp = "fd6f7cf8-8977-4b47-85a9-22d25d605913", Name = "student", NormalizedName = "student" }); @@ -1207,6 +1205,140 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("AuthorId"); b.ToTable("Topic"); + + b.HasData( + new + { + Id = new Guid("00000000-0000-0000-0000-000000000000"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Lịch sử Cổ đại" + }, + new + { + Id = new Guid("80bc02ad-9401-4280-a76d-9fa5f7813dd1"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Thời kỳ Trung đại" + }, + new + { + Id = new Guid("5c414d41-5620-48a4-88c7-61c9a0174243"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Lịch sử thời kỳ thuộc địa" + }, + new + { + Id = new Guid("fd826d64-1f87-436d-82c9-7009d2571199"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Chiến tranh Việt Nam" + }, + new + { + Id = new Guid("208c6340-0a32-492f-afcb-e522ee62a379"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Thời kỳ đổi mới" + }, + new + { + Id = new Guid("45b5a102-1a0f-4a01-b3ad-87033c628a74"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Văn hóa và Nghệ thuật" + }, + new + { + Id = new Guid("30006f7c-d22b-4f57-a4a0-2004bbd7cc5d"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Đời sống trong xã cổ Đông Sơn." + }, + new + { + Id = new Guid("8b2d71a5-ccfd-45ae-9bf3-565b56b73931"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Vương quốc Âu Lạc." + }, + new + { + Id = new Guid("faa13d37-2f3a-447b-92ab-0a26126273e8"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Triều đại Lý." + }, + new + { + Id = new Guid("52463519-05b1-4ad8-a501-ce6073592f7b"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Những thăng trầm của triều đại Lê" + }, + new + { + Id = new Guid("3a5050ee-fc0c-4063-b81e-4dbd58bd1bf2"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Thời kỳ thuộc địa Pháp" + }, + new + { + Id = new Guid("3167df9b-f1d8-4da8-a719-2d9c72618788"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Phong trào Duy Tân" + }, + new + { + Id = new Guid("e932683e-fa11-4adb-8409-93fb40e23315"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Chiến tranh Pháp-Đông Dương" + }, + new + { + Id = new Guid("cc7d45d9-1ffb-460e-9966-8a81e8803896"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Chiến tranh Việt Nam" + }, + new + { + Id = new Guid("92d0fb18-3849-46a7-b6b0-fe76898549a1"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Chính sách đổi mới" + }, + new + { + Id = new Guid("d4a56cbc-e450-4323-be8f-a0606ed5dfe5"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Thách thức hiện đại hóa" + }, + new + { + Id = new Guid("493af5b6-a3f9-45b4-a2e4-25feef7ad6d8"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Văn hóa dân gian" + }, + new + { + Id = new Guid("570b164e-e22e-464c-b224-d2a0309e3065"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Nghệ thuật và văn hóa đương đại" + }, + new + { + Id = new Guid("dd41bdc9-d9d0-4e4f-a8f7-7066fbda0cdc"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Giao lưu văn hóa quốc tế" + }, + new + { + Id = new Guid("987d7996-c324-4585-b86a-cb2a13e2171d"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Nhà Nguyễn" + }, + new + { + Id = new Guid("301eba8b-5332-4501-ae39-4a0475784012"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Anh hùng" + }, + new + { + Id = new Guid("68b43a88-5ef2-494a-b0fe-5bb1705e0736"), + AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + Title = "Nhà Hậu Lê" + }); }); modelBuilder.Entity("VNH.Domain.TopicDetail", b => @@ -1308,7 +1440,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), AccessFailedCount = 0, - ConcurrencyStamp = "0f002472-7451-4186-8beb-031c8b1e11b6", + ConcurrencyStamp = "655f7435-dbfe-418e-a873-2a98f7518f62", DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), Email = "admin@gmail.com", EmailConfirmed = true, @@ -1319,7 +1451,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) LockoutEnabled = false, NormalizedEmail = "onionwebdev@gmail.com", NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAEOU132sCBprXhjVtcdKyx4+iVysC6fPDSHhyEOFTWHbLs8gmbHKbSHQmi8psE9QdEQ==", + PasswordHash = "AQAAAAEAACcQAAAAEOtQFl2yzdrxjnrsTdsQC9KSysBJv5jjIYf4CZbwHIO7kgkPifjNSf1I4MigYSkbRw==", PhoneNumberConfirmed = false, SecurityStamp = "", TwoFactorEnabled = false, diff --git a/VNH.Infrastructure/Migrations/20231222065421_update_attribute.cs b/VNH.Infrastructure/Migrations/20231222065421_update_attribute.cs new file mode 100644 index 0000000..07fc2cf --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231222065421_update_attribute.cs @@ -0,0 +1,145 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class update_attribute : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Title", + table: "Question", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(500)", + oldMaxLength: 500, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SubId", + table: "Post", + type: "nvarchar(500)", + maxLength: 500, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(300)", + oldMaxLength: 300, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "MultipleChoise", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(500)", + oldMaxLength: 500); + + migrationBuilder.AlterColumn( + name: "Title", + table: "Document", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Document", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(500)", + oldMaxLength: 500, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "DownloadNumber", + table: "Document", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ViewNumber", + table: "Document", + type: "bigint", + nullable: false, + defaultValue: 0L); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DownloadNumber", + table: "Document"); + + migrationBuilder.DropColumn( + name: "ViewNumber", + table: "Document"); + + migrationBuilder.AlterColumn( + name: "Title", + table: "Question", + type: "nvarchar(500)", + maxLength: 500, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SubId", + table: "Post", + type: "nvarchar(300)", + maxLength: 300, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(500)", + oldMaxLength: 500, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "MultipleChoise", + type: "nvarchar(500)", + maxLength: 500, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "Title", + table: "Document", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Document", + type: "nvarchar(500)", + maxLength: 500, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + } + } +} diff --git a/VNH.Infrastructure/Migrations/20231210060043_dropQuizAnswerIdInTableQuiz.Designer.cs b/VNH.Infrastructure/Migrations/20231227095837_u_multi_exam_2.Designer.cs similarity index 88% rename from VNH.Infrastructure/Migrations/20231210060043_dropQuizAnswerIdInTableQuiz.Designer.cs rename to VNH.Infrastructure/Migrations/20231227095837_u_multi_exam_2.Designer.cs index 733f980..4c8c567 100644 --- a/VNH.Infrastructure/Migrations/20231210060043_dropQuizAnswerIdInTableQuiz.Designer.cs +++ b/VNH.Infrastructure/Migrations/20231227095837_u_multi_exam_2.Designer.cs @@ -12,8 +12,8 @@ namespace VNH.Infrastructure.Migrations { [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231210060043_dropQuizAnswerIdInTableQuiz")] - partial class dropQuizAnswerIdInTableQuiz + [Migration("20231227095837_u_multi_exam_2")] + partial class u_multi_exam_2 { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -100,13 +100,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("UserId", "RoleId"); b.ToTable("UserRoles", (string)null); - - b.HasData( - new - { - UserId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - RoleId = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575") - }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -338,12 +331,17 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("datetime"); b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); + + b.Property("DownloadNumber") + .HasColumnType("int"); b.Property("FileName") .HasColumnType("nvarchar(max)"); + b.Property("FilePath") + .HasColumnType("nvarchar(max)"); + b.Property("IsDeleted") .HasColumnType("bit"); @@ -351,18 +349,17 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); + .HasColumnType("nvarchar(max)"); b.Property("UpdatedAt") .HasColumnType("datetime"); b.Property("UserId") - .HasMaxLength(255) - .IsUnicode(false) .HasColumnType("uniqueidentifier"); + b.Property("ViewNumber") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("UserId"); @@ -396,14 +393,14 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("uniqueidentifier"); - b.Property("CompletionTime") - .HasColumnType("datetime"); + b.Property("CompletionTime") + .HasColumnType("int"); b.Property("MultipleChoiceId") .HasColumnType("uniqueidentifier"); - b.Property("Scores") - .HasColumnType("int"); + b.Property("Scores") + .HasColumnType("real"); b.Property("StarDate") .HasColumnType("datetime"); @@ -413,8 +410,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("MultipleChoiceId") - .IsUnique(); + b.HasIndex("MultipleChoiceId"); b.ToTable("ExamHistory"); }); @@ -426,13 +422,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("uniqueidentifier"); b.Property("CreatedAt") - .HasMaxLength(500) .HasColumnType("datetime"); b.Property("Description") .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); b.Property("Title") .IsRequired() @@ -648,20 +642,20 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Id") .HasColumnType("uniqueidentifier"); + b.Property("CreatedAt") + .HasColumnType("datetime2"); + b.Property("Description") - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Image") - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Title") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Url") - .IsRequired() - .IsUnicode(false) - .HasColumnType("varchar(max)"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -687,8 +681,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("bit"); b.Property("SubId") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.Property("Title") .HasMaxLength(255) @@ -873,8 +867,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); b.Property("UpdatedAt") .HasColumnType("datetime"); @@ -1023,57 +1016,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Report"); - - b.HasData( - new - { - Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 10, 13, 0, 43, 228, DateTimeKind.Local).AddTicks(1346), - Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", - Title = "Nội dung vi phạm quy định về quyền riêng tư" - }, - new - { - Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 10, 13, 0, 43, 228, DateTimeKind.Local).AddTicks(1356), - Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", - Title = "Nội dung xấu, xúc phạm, hay kỳ thị" - }, - new - { - Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 10, 13, 0, 43, 228, DateTimeKind.Local).AddTicks(1358), - Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", - Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" - }, - new - { - Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 10, 13, 0, 43, 228, DateTimeKind.Local).AddTicks(1360), - Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", - Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" - }, - new - { - Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 10, 13, 0, 43, 228, DateTimeKind.Local).AddTicks(1366), - Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", - Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" - }, - new - { - Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 10, 13, 0, 43, 228, DateTimeKind.Local).AddTicks(1368), - Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", - Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" - }, - new - { - Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 10, 13, 0, 43, 228, DateTimeKind.Local).AddTicks(1370), - Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", - Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" - }); }); modelBuilder.Entity("VNH.Domain.Role", b => @@ -1094,29 +1036,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Roles"); - - b.HasData( - new - { - Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "52be16be-c7dd-4d91-bd9a-d6f9a039171b", - Name = "admin", - NormalizedName = "admin" - }, - new - { - Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "216c436b-6ee3-4e32-a97a-53d7ce990d37", - Name = "teacher", - NormalizedName = "teacher" - }, - new - { - Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "891b01e2-8b5e-4bfa-90e7-b255ea9a01cf", - Name = "student", - NormalizedName = "student" - }); }); modelBuilder.Entity("VNH.Domain.Search", b => @@ -1299,29 +1218,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("User"); - - b.HasData( - new - { - Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - AccessFailedCount = 0, - ConcurrencyStamp = "abb326f4-51ea-4278-abe3-92ce4a8102c9", - DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), - Email = "admin@gmail.com", - EmailConfirmed = true, - Fullname = "Lương Xuân Nhất", - Gender = 0, - Image = "", - IsDeleted = false, - LockoutEnabled = false, - NormalizedEmail = "onionwebdev@gmail.com", - NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAEKBCzIxoXws/qUvTkOgJOoAoJ6z+eXE5s1eHrE52wk1ChYbz4JNPfHgXk879IIRmog==", - PhoneNumberConfirmed = false, - SecurityStamp = "", - TwoFactorEnabled = false, - UserName = "admin" - }); }); modelBuilder.Entity("VNH.Domain.Answer", b => @@ -1468,10 +1364,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("VNH.Domain.Entities.ExamHistory", b => { b.HasOne("VNH.Domain.Entities.MultipleChoice", "MultipleChoice") - .WithOne("ExamHistories") - .HasForeignKey("VNH.Domain.Entities.ExamHistory", "MultipleChoiceId") + .WithMany("ExamHistory") + .HasForeignKey("MultipleChoiceId") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("FK__MultipleChoice__ExamHistoryId__06CD04F7"); b.Navigation("MultipleChoice"); }); @@ -1882,8 +1779,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("VNH.Domain.Entities.MultipleChoice", b => { - b.Navigation("ExamHistories") - .IsRequired(); + b.Navigation("ExamHistory"); b.Navigation("Quiz"); }); diff --git a/VNH.Infrastructure/Migrations/20231227095837_u_multi_exam_2.cs b/VNH.Infrastructure/Migrations/20231227095837_u_multi_exam_2.cs new file mode 100644 index 0000000..977729d --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231227095837_u_multi_exam_2.cs @@ -0,0 +1,129 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class u_multi_exam_2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_ExamHistory_MultipleChoise_MultipleChoiceId", + table: "ExamHistory"); + + migrationBuilder.DropIndex( + name: "IX_ExamHistory_MultipleChoiceId", + table: "ExamHistory"); + + + migrationBuilder.CreateIndex( + name: "IX_ExamHistory_MultipleChoiceId", + table: "ExamHistory", + column: "MultipleChoiceId"); + + migrationBuilder.AddForeignKey( + name: "FK__MultipleChoice__ExamHistoryId__06CD04F7", + table: "ExamHistory", + column: "MultipleChoiceId", + principalTable: "MultipleChoise", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK__MultipleChoice__ExamHistoryId__06CD04F7", + table: "ExamHistory"); + + migrationBuilder.DropIndex( + name: "IX_ExamHistory_MultipleChoiceId", + table: "ExamHistory"); + + migrationBuilder.InsertData( + table: "Report", + columns: new[] { "Id", "CreatedAt", "Description", "Title" }, + values: new object[,] + { + { new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(393), "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", "Nội dung xấu, xúc phạm, hay kỳ thị" }, + { new Guid("3043c693-b3c9-453e-9876-31c943222576"), new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(411), "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" }, + { new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(403), "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", "Chứa nội dung tự tử hoặc tự gây thương tổn" }, + { new Guid("4a780087-9058-41c9-b84b-944d1a502010"), new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(408), "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", "Bài đăng chứa thông tin sai lệch hoặc giả mạo" }, + { new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(400), "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", "Chứa nội dung bạo lực hoặc đội nhóm xấu" }, + { new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(406), "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" }, + { new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), new DateTime(2023, 12, 22, 13, 54, 20, 961, DateTimeKind.Local).AddTicks(380), " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", "Nội dung vi phạm quy định về quyền riêng tư" } + }); + + migrationBuilder.InsertData( + table: "Roles", + columns: new[] { "Id", "ConcurrencyStamp", "Name", "NormalizedName" }, + values: new object[,] + { + { new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), "fd6f7cf8-8977-4b47-85a9-22d25d605913", "student", "student" }, + { new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), "7384f037-6d8d-48a6-a154-195d3a5db7ab", "admin", "admin" }, + { new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), "a6163b8e-97ec-498b-8fd9-e465ff3543e1", "teacher", "teacher" } + }); + + migrationBuilder.InsertData( + table: "User", + columns: new[] { "Id", "AccessFailedCount", "ConcurrencyStamp", "DateOfBirth", "Email", "EmailConfirmed", "Fullname", "Gender", "Image", "Introduction", "IsDeleted", "LockoutEnabled", "LockoutEnd", "NormalizedEmail", "NormalizedUserName", "NumberConfirm", "PasswordHash", "PhoneNumber", "PhoneNumberConfirmed", "SecurityStamp", "TwoFactorEnabled", "UserName" }, + values: new object[] { new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), 0, "655f7435-dbfe-418e-a873-2a98f7518f62", new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), "admin@gmail.com", true, "Lương Xuân Nhất", 0, "", null, false, false, null, "onionwebdev@gmail.com", "admin", null, "AQAAAAEAACcQAAAAEOtQFl2yzdrxjnrsTdsQC9KSysBJv5jjIYf4CZbwHIO7kgkPifjNSf1I4MigYSkbRw==", null, false, "", false, "admin" }); + + migrationBuilder.InsertData( + table: "UserRoles", + columns: new[] { "RoleId", "UserId" }, + values: new object[] { new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5") }); + + migrationBuilder.InsertData( + table: "Topic", + columns: new[] { "Id", "AuthorId", "CreatedAt", "Title", "UpdatedAt" }, + values: new object[,] + { + { new Guid("00000000-0000-0000-0000-000000000000"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Lịch sử Cổ đại", null }, + { new Guid("208c6340-0a32-492f-afcb-e522ee62a379"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ đổi mới", null }, + { new Guid("30006f7c-d22b-4f57-a4a0-2004bbd7cc5d"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Đời sống trong xã cổ Đông Sơn.", null }, + { new Guid("301eba8b-5332-4501-ae39-4a0475784012"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Anh hùng", null }, + { new Guid("3167df9b-f1d8-4da8-a719-2d9c72618788"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Phong trào Duy Tân", null }, + { new Guid("3a5050ee-fc0c-4063-b81e-4dbd58bd1bf2"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ thuộc địa Pháp", null }, + { new Guid("45b5a102-1a0f-4a01-b3ad-87033c628a74"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Văn hóa và Nghệ thuật", null }, + { new Guid("493af5b6-a3f9-45b4-a2e4-25feef7ad6d8"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Văn hóa dân gian", null }, + { new Guid("52463519-05b1-4ad8-a501-ce6073592f7b"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Những thăng trầm của triều đại Lê", null }, + { new Guid("570b164e-e22e-464c-b224-d2a0309e3065"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nghệ thuật và văn hóa đương đại", null }, + { new Guid("5c414d41-5620-48a4-88c7-61c9a0174243"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Lịch sử thời kỳ thuộc địa", null }, + { new Guid("68b43a88-5ef2-494a-b0fe-5bb1705e0736"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nhà Hậu Lê", null }, + { new Guid("80bc02ad-9401-4280-a76d-9fa5f7813dd1"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thời kỳ Trung đại", null }, + { new Guid("8b2d71a5-ccfd-45ae-9bf3-565b56b73931"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Vương quốc Âu Lạc.", null }, + { new Guid("92d0fb18-3849-46a7-b6b0-fe76898549a1"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chính sách đổi mới", null }, + { new Guid("987d7996-c324-4585-b86a-cb2a13e2171d"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Nhà Nguyễn", null }, + { new Guid("cc7d45d9-1ffb-460e-9966-8a81e8803896"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Việt Nam", null }, + { new Guid("d4a56cbc-e450-4323-be8f-a0606ed5dfe5"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Thách thức hiện đại hóa", null }, + { new Guid("dd41bdc9-d9d0-4e4f-a8f7-7066fbda0cdc"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Giao lưu văn hóa quốc tế", null }, + { new Guid("e932683e-fa11-4adb-8409-93fb40e23315"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Pháp-Đông Dương", null }, + { new Guid("faa13d37-2f3a-447b-92ab-0a26126273e8"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Triều đại Lý.", null }, + { new Guid("fd826d64-1f87-436d-82c9-7009d2571199"), new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), null, "Chiến tranh Việt Nam", null } + }); + + migrationBuilder.CreateIndex( + name: "IX_ExamHistory_MultipleChoiceId", + table: "ExamHistory", + column: "MultipleChoiceId", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_ExamHistory_MultipleChoise_MultipleChoiceId", + table: "ExamHistory", + column: "MultipleChoiceId", + principalTable: "MultipleChoise", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/VNH.Infrastructure/Migrations/20231215075132_add_file_path.Designer.cs b/VNH.Infrastructure/Migrations/20231228061045_update_notification_detail.Designer.cs similarity index 89% rename from VNH.Infrastructure/Migrations/20231215075132_add_file_path.Designer.cs rename to VNH.Infrastructure/Migrations/20231228061045_update_notification_detail.Designer.cs index 3e8b586..c08fb8f 100644 --- a/VNH.Infrastructure/Migrations/20231215075132_add_file_path.Designer.cs +++ b/VNH.Infrastructure/Migrations/20231228061045_update_notification_detail.Designer.cs @@ -12,8 +12,8 @@ namespace VNH.Infrastructure.Migrations { [DbContext(typeof(VietNamHistoryContext))] - [Migration("20231215075132_add_file_path")] - partial class add_file_path + [Migration("20231228061045_update_notification_detail")] + partial class update_notification_detail { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -100,13 +100,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("UserId", "RoleId"); b.ToTable("UserRoles", (string)null); - - b.HasData( - new - { - UserId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - RoleId = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575") - }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -338,8 +331,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("datetime"); b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); + + b.Property("DownloadNumber") + .HasColumnType("int"); b.Property("FileName") .HasColumnType("nvarchar(max)"); @@ -354,9 +349,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); + .HasColumnType("nvarchar(max)"); b.Property("UpdatedAt") .HasColumnType("datetime"); @@ -364,6 +357,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("UserId") .HasColumnType("uniqueidentifier"); + b.Property("ViewNumber") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("UserId"); @@ -403,8 +399,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MultipleChoiceId") .HasColumnType("uniqueidentifier"); - b.Property("Scores") - .HasColumnType("int"); + b.Property("Scores") + .HasColumnType("real"); b.Property("StarDate") .HasColumnType("datetime"); @@ -414,8 +410,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("MultipleChoiceId") - .IsUnique(); + b.HasIndex("MultipleChoiceId"); b.ToTable("ExamHistory"); }); @@ -427,13 +422,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("uniqueidentifier"); b.Property("CreatedAt") - .HasMaxLength(500) .HasColumnType("datetime"); b.Property("Description") .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); b.Property("Title") .IsRequired() @@ -482,12 +475,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Date") .HasColumnType("datetime2"); + b.Property("IdObject") + .HasColumnType("uniqueidentifier"); + b.Property("IsRead") .HasColumnType("int"); b.Property("NotificationId") .HasColumnType("uniqueidentifier"); + b.Property("Url") + .HasColumnType("nvarchar(max)"); + b.Property("UserId") .HasColumnType("uniqueidentifier"); @@ -649,20 +648,20 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Id") .HasColumnType("uniqueidentifier"); + b.Property("CreatedAt") + .HasColumnType("datetime2"); + b.Property("Description") - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Image") - .HasColumnType("text"); + .HasColumnType("nvarchar(max)"); b.Property("Title") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Url") - .IsRequired() - .IsUnicode(false) - .HasColumnType("varchar(max)"); + .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -688,8 +687,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("bit"); b.Property("SubId") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.Property("Title") .HasMaxLength(255) @@ -874,8 +873,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); b.Property("UpdatedAt") .HasColumnType("datetime"); @@ -1024,57 +1022,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Report"); - - b.HasData( - new - { - Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 15, 14, 51, 31, 700, DateTimeKind.Local).AddTicks(9924), - Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", - Title = "Nội dung vi phạm quy định về quyền riêng tư" - }, - new - { - Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 15, 14, 51, 31, 700, DateTimeKind.Local).AddTicks(9942), - Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", - Title = "Nội dung xấu, xúc phạm, hay kỳ thị" - }, - new - { - Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 15, 14, 51, 31, 700, DateTimeKind.Local).AddTicks(9945), - Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", - Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" - }, - new - { - Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 15, 14, 51, 31, 700, DateTimeKind.Local).AddTicks(9948), - Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", - Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" - }, - new - { - Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 15, 14, 51, 31, 700, DateTimeKind.Local).AddTicks(9950), - Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", - Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" - }, - new - { - Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 15, 14, 51, 31, 700, DateTimeKind.Local).AddTicks(9952), - Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", - Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" - }, - new - { - Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 15, 14, 51, 31, 700, DateTimeKind.Local).AddTicks(9954), - Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", - Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" - }); }); modelBuilder.Entity("VNH.Domain.Role", b => @@ -1095,29 +1042,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Roles"); - - b.HasData( - new - { - Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "45b270c6-0bb5-410e-a37d-58ce8b0e95bf", - Name = "admin", - NormalizedName = "admin" - }, - new - { - Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "6ee005b6-1aef-4955-ae04-5e15d2687fac", - Name = "teacher", - NormalizedName = "teacher" - }, - new - { - Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "0cffc651-df2c-4707-880b-692f861a1508", - Name = "student", - NormalizedName = "student" - }); }); modelBuilder.Entity("VNH.Domain.Search", b => @@ -1300,29 +1224,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("User"); - - b.HasData( - new - { - Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - AccessFailedCount = 0, - ConcurrencyStamp = "55a2d003-4617-4127-a4bd-c4481f8cf966", - DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), - Email = "admin@gmail.com", - EmailConfirmed = true, - Fullname = "Lương Xuân Nhất", - Gender = 0, - Image = "", - IsDeleted = false, - LockoutEnabled = false, - NormalizedEmail = "onionwebdev@gmail.com", - NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAEKnAYjbHRi72B0lSgpNfv3TRaGb+g5gR6F1k2loonAnTruWHDLF5W4wDjq2FaU8nPQ==", - PhoneNumberConfirmed = false, - SecurityStamp = "", - TwoFactorEnabled = false, - UserName = "admin" - }); }); modelBuilder.Entity("VNH.Domain.Answer", b => @@ -1469,10 +1370,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("VNH.Domain.Entities.ExamHistory", b => { b.HasOne("VNH.Domain.Entities.MultipleChoice", "MultipleChoice") - .WithOne("ExamHistories") - .HasForeignKey("VNH.Domain.Entities.ExamHistory", "MultipleChoiceId") + .WithMany("ExamHistory") + .HasForeignKey("MultipleChoiceId") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("FK__MultipleChoice__ExamHistoryId__06CD04F7"); b.Navigation("MultipleChoice"); }); @@ -1883,8 +1785,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("VNH.Domain.Entities.MultipleChoice", b => { - b.Navigation("ExamHistories") - .IsRequired(); + b.Navigation("ExamHistory"); b.Navigation("Quiz"); }); diff --git a/VNH.Infrastructure/Migrations/20231228061045_update_notification_detail.cs b/VNH.Infrastructure/Migrations/20231228061045_update_notification_detail.cs new file mode 100644 index 0000000..54604ff --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231228061045_update_notification_detail.cs @@ -0,0 +1,39 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class update_notification_detail : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IdObject", + table: "NotificationDetails", + type: "uniqueidentifier", + nullable: true); + + migrationBuilder.AddColumn( + name: "Url", + table: "NotificationDetails", + type: "nvarchar(max)", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IdObject", + table: "NotificationDetails"); + + migrationBuilder.DropColumn( + name: "Url", + table: "NotificationDetails"); + } + } +} diff --git a/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs b/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs index 395d62f..8cd9804 100644 --- a/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs +++ b/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs @@ -97,13 +97,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("UserId", "RoleId"); b.ToTable("UserRoles", (string)null); - - b.HasData( - new - { - UserId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - RoleId = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575") - }); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => @@ -335,8 +328,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("datetime"); b.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); + + b.Property("DownloadNumber") + .HasColumnType("int"); b.Property("FileName") .HasColumnType("nvarchar(max)"); @@ -351,9 +346,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("Title") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); + .HasColumnType("nvarchar(max)"); b.Property("UpdatedAt") .HasColumnType("datetime"); @@ -361,6 +354,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("UserId") .HasColumnType("uniqueidentifier"); + b.Property("ViewNumber") + .HasColumnType("bigint"); + b.HasKey("Id"); b.HasIndex("UserId"); @@ -400,8 +396,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("MultipleChoiceId") .HasColumnType("uniqueidentifier"); - b.Property("Scores") - .HasColumnType("int"); + b.Property("Scores") + .HasColumnType("real"); b.Property("StarDate") .HasColumnType("datetime"); @@ -411,8 +407,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("MultipleChoiceId") - .IsUnique(); + b.HasIndex("MultipleChoiceId"); b.ToTable("ExamHistory"); }); @@ -424,13 +419,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("uniqueidentifier"); b.Property("CreatedAt") - .HasMaxLength(500) .HasColumnType("datetime"); b.Property("Description") .IsRequired() - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); b.Property("Title") .IsRequired() @@ -479,12 +472,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Date") .HasColumnType("datetime2"); + b.Property("IdObject") + .HasColumnType("uniqueidentifier"); + b.Property("IsRead") .HasColumnType("int"); b.Property("NotificationId") .HasColumnType("uniqueidentifier"); + b.Property("Url") + .HasColumnType("nvarchar(max)"); + b.Property("UserId") .HasColumnType("uniqueidentifier"); @@ -685,8 +684,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("bit"); b.Property("SubId") - .HasMaxLength(300) - .HasColumnType("nvarchar(300)"); + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); b.Property("Title") .HasMaxLength(255) @@ -871,8 +870,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("Title") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); + .HasColumnType("nvarchar(max)"); b.Property("UpdatedAt") .HasColumnType("datetime"); @@ -1021,57 +1019,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Report"); - - b.HasData( - new - { - Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9587), - Description = " Báo cáo này được sử dụng khi người dùng chia sẻ nội dung cá nhân của bạn mà bạn cho rằng vi phạm quyền riêng tư của bạn.", - Title = "Nội dung vi phạm quy định về quyền riêng tư" - }, - new - { - Id = new Guid("25752490-4ba5-4abb-ac3b-192205cd1b6e"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9607), - Description = "Sử dụng khi bạn thấy nội dung bài đăng chứa lời lẽ xúc phạm, kỳ thị hoặc có tính chất đe doạ đến người khác.", - Title = "Nội dung xấu, xúc phạm, hay kỳ thị" - }, - new - { - Id = new Guid("bab1da58-6921-44b9-837f-c58d3998497b"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9612), - Description = "Dùng khi bạn thấy nội dung chứa hình ảnh hoặc video bạo lực hoặc đội nhóm xấu, hoặc khuyến khích hành vi bạo lực.", - Title = "Chứa nội dung bạo lực hoặc đội nhóm xấu" - }, - new - { - Id = new Guid("349ed807-6107-436f-9a4c-9d6183fbc444"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9616), - Description = "Sử dụng khi bạn thấy nội dung chứa hình ảnh tự tử hoặc khuyến khích hành vi tự gây thương tổn.", - Title = "Chứa nội dung tự tử hoặc tự gây thương tổn" - }, - new - { - Id = new Guid("c4ddb872-06c5-4779-a8a3-a55e5b2c5347"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9620), - Description = "Sử dụng khi bạn cho rằng Nội dung vi phạm quyền sở hữu trí tuệ hoặc bản quyền, chẳng hạn như sử dụng hình ảnh hoặc video mà bạn sở hữu mà không có sự cho phép.", - Title = "Nội dung vi phạm bản quyền hoặc sở hữu trí tuệ" - }, - new - { - Id = new Guid("4a780087-9058-41c9-b84b-944d1a502010"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9623), - Description = "Sử dụng khi bạn thấy rằng nội dung chứa thông tin sai lệch, giả mạo hoặc vi phạm quy tắc về sự thật và trung thực.", - Title = "Bài đăng chứa thông tin sai lệch hoặc giả mạo" - }, - new - { - Id = new Guid("3043c693-b3c9-453e-9876-31c943222576"), - CreatedAt = new DateTime(2023, 12, 15, 19, 45, 6, 331, DateTimeKind.Local).AddTicks(9627), - Description = "Dùng khi bạn muốn báo cáo vì nó quá nhiều thông báo hoặc quảng cáo không mong muốn.", - Title = "Nội dung xuất hiện quá nhiều thông báo hoặc quảng cáo không mong muốn" - }); }); modelBuilder.Entity("VNH.Domain.Role", b => @@ -1092,29 +1039,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("Roles"); - - b.HasData( - new - { - Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "2136f784-5172-4046-901e-801367014f68", - Name = "admin", - NormalizedName = "admin" - }, - new - { - Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "b056248f-657f-4de1-8180-807862c43ff5", - Name = "teacher", - NormalizedName = "teacher" - }, - new - { - Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "0722bf9f-7f09-4d19-a6dc-72beb371e784", - Name = "student", - NormalizedName = "student" - }); }); modelBuilder.Entity("VNH.Domain.Search", b => @@ -1202,140 +1126,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("AuthorId"); b.ToTable("Topic"); - - b.HasData( - new - { - Id = new Guid("00000000-0000-0000-0000-000000000000"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Lịch sử Cổ đại" - }, - new - { - Id = new Guid("fe64196e-d1b5-4f01-964d-a5cfb6581bb4"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Thời kỳ Trung đại" - }, - new - { - Id = new Guid("1119badd-3874-467a-92a0-0c620ae136e2"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Lịch sử thời kỳ thuộc địa" - }, - new - { - Id = new Guid("185dc21d-5fba-4552-9ed9-be749486f324"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Chiến tranh Việt Nam" - }, - new - { - Id = new Guid("e06f0b87-148d-485e-891e-1bc83f35ceea"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Thời kỳ đổi mới" - }, - new - { - Id = new Guid("ba5592bf-dd43-4fbe-ad3f-af60b07352b1"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Văn hóa và Nghệ thuật" - }, - new - { - Id = new Guid("8a2a6d74-148f-4f3e-8fb1-129d578a5db3"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Đời sống trong xã cổ Đông Sơn." - }, - new - { - Id = new Guid("9304db08-37b6-4f25-83a7-e12c510b8f23"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Vương quốc Âu Lạc." - }, - new - { - Id = new Guid("20936bf1-03ca-49ba-83e8-4c3b0d520932"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Triều đại Lý." - }, - new - { - Id = new Guid("e25909f4-d1c2-47b8-a6a1-58ed5504fa7c"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Những thăng trầm của triều đại Lê" - }, - new - { - Id = new Guid("811fdbac-0812-4d35-8c8b-24d991c384fa"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Thời kỳ thuộc địa Pháp" - }, - new - { - Id = new Guid("64133fc8-1783-4cbf-9884-f77c61a6c61b"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Phong trào Duy Tân" - }, - new - { - Id = new Guid("7875af75-b4fc-4c19-9a56-930f9bbc5fe4"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Chiến tranh Pháp-Đông Dương" - }, - new - { - Id = new Guid("fb74d62c-7a84-4675-a254-56c934398737"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Chiến tranh Việt Nam" - }, - new - { - Id = new Guid("7045e99f-65ab-4c0b-9088-350011c9336d"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Chính sách đổi mới" - }, - new - { - Id = new Guid("626e93b8-5186-48d9-9d02-8f18004b6d45"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Thách thức hiện đại hóa" - }, - new - { - Id = new Guid("dde8818f-653c-4a1e-8976-86dae420034e"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Văn hóa dân gian" - }, - new - { - Id = new Guid("1436bfae-62d7-48a0-b6fe-661803294bfe"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Nghệ thuật và văn hóa đương đại" - }, - new - { - Id = new Guid("0462e243-80d7-40df-af11-1c2d2a346745"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Giao lưu văn hóa quốc tế" - }, - new - { - Id = new Guid("8e732f75-5542-4a66-b53c-68e0ce5f22d5"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Nhà Nguyễn" - }, - new - { - Id = new Guid("dd1d0dc2-825b-4052-827e-6831b21ba87f"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Anh hùng" - }, - new - { - Id = new Guid("735d3139-7e14-497e-b1e5-21a01ed76d63"), - AuthorId = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - Title = "Nhà Hậu Lê" - }); }); modelBuilder.Entity("VNH.Domain.TopicDetail", b => @@ -1431,29 +1221,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); b.ToTable("User"); - - b.HasData( - new - { - Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), - AccessFailedCount = 0, - ConcurrencyStamp = "fd3361d8-877e-40ee-aae1-6efdce1b8056", - DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), - Email = "admin@gmail.com", - EmailConfirmed = true, - Fullname = "Lương Xuân Nhất", - Gender = 0, - Image = "", - IsDeleted = false, - LockoutEnabled = false, - NormalizedEmail = "onionwebdev@gmail.com", - NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAENN17nFItiWgMPsbrrWZ6KAtM9gKQP3NbJwyowEuW1bb2TqSBaerxyCjlOuDGMh5LA==", - PhoneNumberConfirmed = false, - SecurityStamp = "", - TwoFactorEnabled = false, - UserName = "admin" - }); }); modelBuilder.Entity("VNH.Domain.Answer", b => @@ -1600,10 +1367,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("VNH.Domain.Entities.ExamHistory", b => { b.HasOne("VNH.Domain.Entities.MultipleChoice", "MultipleChoice") - .WithOne("ExamHistories") - .HasForeignKey("VNH.Domain.Entities.ExamHistory", "MultipleChoiceId") + .WithMany("ExamHistory") + .HasForeignKey("MultipleChoiceId") .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .IsRequired() + .HasConstraintName("FK__MultipleChoice__ExamHistoryId__06CD04F7"); b.Navigation("MultipleChoice"); }); @@ -2014,8 +1782,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("VNH.Domain.Entities.MultipleChoice", b => { - b.Navigation("ExamHistories") - .IsRequired(); + b.Navigation("ExamHistory"); b.Navigation("Quiz"); }); diff --git a/VNH.Infrastructure/Presenters/ChatSignalR.cs b/VNH.Infrastructure/Presenters/ChatSignalR.cs index 7024b57..8f7a072 100644 --- a/VNH.Infrastructure/Presenters/ChatSignalR.cs +++ b/VNH.Infrastructure/Presenters/ChatSignalR.cs @@ -8,7 +8,6 @@ public class ChatSignalR : Hub { public async Task SendComment(CommentPostDto comment) { - // Broadcast the subAnswer to all connected clients await Clients.All.SendAsync("ReceiveComment", comment); } @@ -17,10 +16,21 @@ public async Task SendAnswer(AnswerQuestionDto comment) await Clients.All.SendAsync("ReceiveAnswer", comment); } - //public async Task SendSubAnswer(List subAnswer) - //{ - // await Clients.All.SendAsync("ReceiveSubAnswer", subAnswer); - //} + public async Task AddToGroup(string userId) + { + await Groups.AddToGroupAsync(Context.ConnectionId, userId); + } + public override async Task OnConnectedAsync() + { + Console.WriteLine("Client connected: " + Context.ConnectionId); + await base.OnConnectedAsync(); + } + + public override async Task OnDisconnectedAsync(Exception exception) + { + Console.WriteLine("Client disconnected: " + Context.ConnectionId); + await base.OnDisconnectedAsync(exception); + } } diff --git a/VNH.Infrastructure/Presenters/DbContext/VietNamHistoryContext.cs b/VNH.Infrastructure/Presenters/DbContext/VietNamHistoryContext.cs index 32cb2b4..1443d5f 100644 --- a/VNH.Infrastructure/Presenters/DbContext/VietNamHistoryContext.cs +++ b/VNH.Infrastructure/Presenters/DbContext/VietNamHistoryContext.cs @@ -69,9 +69,18 @@ public VietNamHistoryContext(DbContextOptions options) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { + //if (!optionsBuilder.IsConfigured) + //{ + // optionsBuilder.UseSqlServer(SystemConstants.ConnectString); + //} + if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlServer(SystemConstants.ConnectString); + optionsBuilder.UseSqlServer(SystemConstants.ConnectString, + sqlServerOptionsBuilder => + { + sqlServerOptionsBuilder.EnableRetryOnFailure(maxRetryCount: 5, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); + }); } } @@ -537,33 +546,22 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity(entity => { - - entity.HasOne(e => e.ExamHistories).WithOne(d => d.MultipleChoice).HasForeignKey(e => e.MultipleChoiceId); - entity.HasOne(e=>e.User).WithMany(d=>d.MultipleChoices).HasForeignKey(e=>e.UserId).HasConstraintName("FK__MultipleChoice__UserId__06CD04F7"); }); - - - modelBuilder.Entity(entity => { - - entity.HasOne(e => e.MultipleChoice).WithOne(d => d.ExamHistories).HasForeignKey(e => e.MultipleChoiceId); + entity.HasKey(e => e.Id); + entity.HasOne(e=>e.MultipleChoice).WithMany(e=>e.ExamHistory).HasForeignKey(e => e.MultipleChoiceId).HasConstraintName("FK__MultipleChoice__ExamHistoryId__06CD04F7"); }); - - - - - modelBuilder.Entity>().ToTable("UserRoles").HasKey(x => new { x.UserId, x.RoleId }); modelBuilder.Entity>().ToTable("AppUserLogins").HasKey(x => x.UserId); modelBuilder.Entity>().ToTable("AppRoleClaims"); modelBuilder.Entity>().ToTable("AppUserTokens").HasKey(x => x.UserId); OnModelCreatingPartial(modelBuilder); - new SeedingData(modelBuilder).Seed(); + // new SeedingData(modelBuilder).Seed(); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); diff --git a/VNH.WebAPi/Controllers/AccountController.cs b/VNH.WebAPi/Controllers/AccountController.cs index 77f98e6..4eb7a40 100644 --- a/VNH.WebAPi/Controllers/AccountController.cs +++ b/VNH.WebAPi/Controllers/AccountController.cs @@ -266,7 +266,7 @@ public async Task EmailConfirm(string numberConfirm) public async Task ForgetPassword([FromQuery] string email) { var result = await _account.ForgetPassword(email); - return result.IsSuccessed ? Ok(result) : BadRequest(result); + return Ok(result); } [HttpGet("ForgetPassword/ConfirmCode")] diff --git a/VNH.WebAPi/Controllers/AnswerController.cs b/VNH.WebAPi/Controllers/AnswerController.cs index 7e0115a..53c15cc 100644 --- a/VNH.WebAPi/Controllers/AnswerController.cs +++ b/VNH.WebAPi/Controllers/AnswerController.cs @@ -25,15 +25,16 @@ public AnswerController(IAnswerService answerService) public async Task GetAnswers(string questionId) { var result = await _answerService.GetAnswer(questionId); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost()] [Authorize] public async Task CreateAnswer(AnswerQuestionDto answer) { - var result = await _answerService.CreateAnswer(answer); - return result is null ? BadRequest(result) : Ok(result); + var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; + var result = await _answerService.CreateAnswer(answer, id); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPut] @@ -46,7 +47,7 @@ public async Task UpdateAnswer(AnswerQuestionDto answer) return BadRequest(); } var result = await _answerService.UpdateAnswer(answer); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpDelete("delete")] [Authorize] @@ -58,7 +59,7 @@ public async Task DeleteAnswer(string idAnswer) return BadRequest(); } var result = await _answerService.DeteleAnswer(idAnswer); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } @@ -67,7 +68,7 @@ public async Task DeleteAnswer(string idAnswer) public async Task CreateSubAnswer(SubAnswerQuestionDto subAnswer) { var result = await _answerService.CreateSubAnswer(subAnswer); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPut("SubAnswer")] @@ -80,7 +81,7 @@ public async Task UpdateSubAnswer(SubAnswerQuestionDto subAnswer) return BadRequest(); } var result = await _answerService.UpdateSubAnswer(subAnswer); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } @@ -94,7 +95,7 @@ public async Task DeleteSubAnswer(string idSubAnswer) return BadRequest(); } var result = await _answerService.DeteleSubAnswer(idSubAnswer); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Confirm")] diff --git a/VNH.WebAPi/Controllers/ArticleImageController.cs b/VNH.WebAPi/Controllers/ArticleImageController.cs new file mode 100644 index 0000000..56caef0 --- /dev/null +++ b/VNH.WebAPi/Controllers/ArticleImageController.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using VNH.Application.Interfaces.Common; + +namespace VNH.WebAPi.Controllers +{ + [Route("[controller]")] + [ApiController] + public class ArticleImageController : ControllerBase + { + private readonly IImageService _image; + public ArticleImageController(IImageService imageService) { + _image = imageService; + } + + [HttpPost("upload")] + public async Task ImageUpload(IFormFile file) + { + try + { + if (file != null && file.Length > 0) + { + if (file.Length > 3 * 1024 * 1024) // 3 MB + { + return BadRequest("Kích thước file không được lớn hơn 3 MB"); + } + var fileName = file.FileName; + var rerult = await _image.SaveFile(file); + return Ok(rerult); + } else { return BadRequest(); } + } + catch (Exception e) + { + return BadRequest(new { message = e.Message }); + } + } + } +} diff --git a/VNH.WebAPi/Controllers/DocumentController.cs b/VNH.WebAPi/Controllers/DocumentController.cs index 08debd7..7ae39b9 100644 --- a/VNH.WebAPi/Controllers/DocumentController.cs +++ b/VNH.WebAPi/Controllers/DocumentController.cs @@ -23,7 +23,7 @@ public DocumentController(IDocumentService documentService) public async Task Index() { var result = await _documentService.GetAll(); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPut] @@ -32,7 +32,7 @@ public async Task Index() public async Task UpdateDocument([FromForm] CreateDocumentDto requestDto) { var result = await _documentService.Update(requestDto, User.Identity.Name); - return result == null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } @@ -42,29 +42,29 @@ public async Task UpdateDocument([FromForm] CreateDocumentDto req public async Task CreateDocument([FromForm] CreateDocumentDto requestDto) { var result = await _documentService.Create(requestDto, User.Identity.Name); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("{id}")] public async Task Detail(string id) { var result = await _documentService.Detail(id); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpDelete("Delete")] public async Task Delete(string Id) { var result = await _documentService.Delete(Id, User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Save")] [Authorize] - public async Task GetSaveDocs([FromForm] DocumentFpkDto docsFpk) + public async Task GetSaveDocs([FromQuery] DocumentFpkDto docsFpk) { var result = await _documentService.GetSave(docsFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Save")] @@ -72,7 +72,7 @@ public async Task GetSaveDocs([FromForm] DocumentFpkDto docsFpk) public async Task Save([FromForm] DocumentFpkDto docsFpk) { var result = await _documentService.AddOrRemoveSaveDocs(docsFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Search")] @@ -96,5 +96,12 @@ public async Task GetMyDocument() var result = await _documentService.GetMyDocument(userId); return !result.IsSuccessed ? BadRequest(result) : Ok(result); } + + [HttpPost("SaveDownloads")] + public async Task SaveDownloads(Guid documentId) + { + await _documentService.SaveDownloads(documentId); + return Ok(); + } } } diff --git a/VNH.WebAPi/Controllers/ExamHistoryController.cs b/VNH.WebAPi/Controllers/ExamHistoryController.cs index c516e05..eb78997 100644 --- a/VNH.WebAPi/Controllers/ExamHistoryController.cs +++ b/VNH.WebAPi/Controllers/ExamHistoryController.cs @@ -1,10 +1,9 @@ -using Microsoft.AspNetCore.Authorization; +using DocumentFormat.OpenXml.Office2010.Excel; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using System.Security.Claims; using VNH.Application.DTOs.Catalog.ExamHistory; -using VNH.Application.DTOs.Catalog.MultipleChoiceDto; -using VNH.Application.DTOs.Catalog.Posts; using VNH.Application.Interfaces.Catalog.ExamHistory; -using VNH.Domain; namespace VNH.WebAPi.Controllers { @@ -22,28 +21,30 @@ public ExamHistoryController(IExamHistoryService examHistoryService) [HttpPost] [Authorize] - [Consumes("multipart/form-data")] public async Task Create([FromForm] CreateExamHistoryDto requestDto) { var result = await _examHistoryService.Create(requestDto,User.Identity.Name ); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } - [HttpPut] - [Authorize] - public async Task Update([FromForm] CreateExamHistoryDto requestDto) + [HttpGet("GetExamHistory")] + public async Task GetExamHistory(string id) { - var result = await _examHistoryService.Update(requestDto, User.Identity.Name); - return result == null ? BadRequest(result) : Ok(result); + var result = await _examHistoryService.GetExamHistory(id); + + return !result.IsSuccessed ? BadRequest(result) : Ok(result); + + } [HttpGet("GetMyExamHistory")] - public async Task GetMyExamHistory(string id) + public async Task GetMyExamHistory() { - var result = await _examHistoryService.GetMyExamHistory(id); + var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""; + var result = await _examHistoryService.GetMyExamHistory(userId); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } diff --git a/VNH.WebAPi/Controllers/HashTagController.cs b/VNH.WebAPi/Controllers/HashTagController.cs index 5c930c6..3a7036e 100644 --- a/VNH.WebAPi/Controllers/HashTagController.cs +++ b/VNH.WebAPi/Controllers/HashTagController.cs @@ -18,13 +18,13 @@ public HashTagController(IHashTag hashTagService) { public async Task GetAll() { var result = await _hasgTagService.GetAllTag(0); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("TopTag")] public async Task GetTopTags(int numberTag) { var result = await _hasgTagService.GetAllTag(numberTag); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } } } diff --git a/VNH.WebAPi/Controllers/MultiChoiceController.cs b/VNH.WebAPi/Controllers/MultiChoiceController.cs index 91783bd..eac7f62 100644 --- a/VNH.WebAPi/Controllers/MultiChoiceController.cs +++ b/VNH.WebAPi/Controllers/MultiChoiceController.cs @@ -26,7 +26,7 @@ public MultiChoiceController(IMultipleChoiceService multipleChoiceService) public async Task CreateMultiChoice([FromForm] CreateQuizDto requestDto) { var result = await _multipleChoiceService.Create(requestDto, User.Identity.Name); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } @@ -34,7 +34,7 @@ public async Task CreateMultiChoice([FromForm] CreateQuizDto requ public async Task Detail(string id) { var result = await _multipleChoiceService.Detail(id); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } @@ -42,7 +42,7 @@ public async Task Detail(string id) public async Task Index() { var result = await _multipleChoiceService.GetAll(); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } @@ -69,7 +69,7 @@ public async Task Delete(string idMultipleChoice) { var result = await _multipleChoiceService.Delete(idMultipleChoice, User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } @@ -79,7 +79,7 @@ public async Task DeleteQuizById(string idQuiz) { var result = await _multipleChoiceService.DeleteQuizById(idQuiz); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } @@ -88,12 +88,22 @@ public async Task Search([FromQuery] string keyWord) { var result = await _multipleChoiceService.Search(keyWord); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } + [HttpGet("MyMultipleChoice")] + [Authorize(Roles ="admin")] + public async Task GetMyPost() + { + var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""; + var result = await _multipleChoiceService.GetMyMultipleChoice(id); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); + } + + } diff --git a/VNH.WebAPi/Controllers/NotificationController.cs b/VNH.WebAPi/Controllers/NotificationController.cs new file mode 100644 index 0000000..1b55fb9 --- /dev/null +++ b/VNH.WebAPi/Controllers/NotificationController.cs @@ -0,0 +1,51 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Security.Claims; +using VNH.Application.DTOs.Catalog.Notifications; +using VNH.Application.Implement.Catalog.NotificationServices; + +namespace VNH.WebAPi.Controllers +{ + [Route("[controller]")] + [ApiController] + public class NotificationController : Controller + { + private readonly INotificationService _notificationService; + public NotificationController(INotificationService notification) + { + _notificationService = notification; + } + [HttpGet] + [Authorize] + public async Task Index() + { + var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""; + var result = await _notificationService.GetAll(userId); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); + } + + [HttpPost] + [Authorize(Roles = "admin")] + public async Task Add(string title) + { + var result = await _notificationService.Add(title); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); + } + + [HttpPost("AddNotification")] + [Authorize] + public async Task AddNotificationDetail(NotificationDto notification) + { + await _notificationService.AddNotificationDetail(notification); + return Ok(); + } + + [HttpPut] + [Authorize] + public async Task Update(NotificationDto notification) + { + var result = await _notificationService.Update(notification); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); + } + } +} diff --git a/VNH.WebAPi/Controllers/PostController.cs b/VNH.WebAPi/Controllers/PostController.cs index e574814..643d450 100644 --- a/VNH.WebAPi/Controllers/PostController.cs +++ b/VNH.WebAPi/Controllers/PostController.cs @@ -21,19 +21,19 @@ public PostController(IPostService postService) public async Task Index() { var result = await _postService.GetAll(); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("DiscoverMobile")] public async Task IndexMobile() { var result = await _postService.GetAllMobile(); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("RandomArticle")] public async Task RandomPost(int quantity = 0) { var result = await _postService.GetRandomPost(quantity); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost] [Authorize] @@ -41,7 +41,7 @@ public async Task RandomPost(int quantity = 0) public async Task CreatePost([FromForm] CreatePostDto requestDto) { var result = await _postService.Create(requestDto, User.Identity.Name); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPut] @@ -50,21 +50,21 @@ public async Task CreatePost([FromForm] CreatePostDto requestDto) public async Task UpdatePost([FromForm] CreatePostDto requestDto) { var result = await _postService.Update(requestDto, User.Identity.Name); - return result == null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("{id}")] public async Task Detail(string id) { var result = await _postService.Detail(id); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpDelete("Delete")] public async Task Delete(string Id) { var result = await _postService.Delete(Id, User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpDelete("Remove")] @@ -72,13 +72,13 @@ public async Task Delete(string Id) public async Task DeleteAdmin(string Id) { var result = await _postService.DeleteAdmin(Id); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Like")] public async Task GetLikePost([FromQuery] PostFpkDto postFpk) { var result = await _postService.GetLike(postFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Like")] @@ -86,14 +86,14 @@ public async Task GetLikePost([FromQuery] PostFpkDto postFpk) public async Task Like([FromForm] PostFpkDto postFpk) { var result = await _postService.AddOrUnLikePost(postFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Save")] [Authorize] public async Task GetSavePost([FromQuery] PostFpkDto postFpk) { var result = await _postService.GetSave(postFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("MyPostSaved")] [Authorize] @@ -101,7 +101,7 @@ public async Task GetMyPostSaved() { var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""; var result = await _postService.GetMyPostSaved(id); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("MyPost")] [Authorize] @@ -109,7 +109,7 @@ public async Task GetMyPost() { var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""; var result = await _postService.GetMyPost(id); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Save")] @@ -117,7 +117,7 @@ public async Task GetMyPost() public async Task Save([FromForm] PostFpkDto postFpk) { var result = await _postService.AddOrRemoveSavePost(postFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Report")] @@ -139,26 +139,27 @@ public async Task GetReport() public async Task GetPostByTag(string tag) { var result = await _postService.GetPostByTag(tag); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Search")] public async Task Search([FromQuery] string keyWord) { var result = await _postService.SearchPosts(keyWord); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Chat")] public async Task GetComments(string PostId) { var result = await _postService.GetComment(PostId); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Chat")] [Authorize] public async Task CreateComment(CommentPostDto comment) { - var result = await _postService.CreateComment(comment); - return result is null ? BadRequest(result) : Ok(result); + var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""; + var result = await _postService.CreateComment(comment, userId); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPut("Chat")] [Authorize] @@ -170,7 +171,7 @@ public async Task UpdateComment(CommentPostDto comment) return BadRequest(); } var result = await _postService.UpdateComment(comment); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpDelete("Chat")] [Authorize] @@ -182,7 +183,7 @@ public async Task DeleteComment(string idComment) return BadRequest(); } var result = await _postService.DeteleComment(idComment); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Chat/NumberComment")] public async Task GetCommentPost(string PostId) @@ -196,7 +197,7 @@ public async Task GetCommentPost(string PostId) public async Task FindByTopic(string TopicName) { var result = await _postService.FindByTopic(TopicName); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } } } diff --git a/VNH.WebAPi/Controllers/QuestionController.cs b/VNH.WebAPi/Controllers/QuestionController.cs index d37bbcc..7222e4c 100644 --- a/VNH.WebAPi/Controllers/QuestionController.cs +++ b/VNH.WebAPi/Controllers/QuestionController.cs @@ -26,7 +26,7 @@ public QuestionController(IQuestionService questionService) public async Task CreateQuestion([FromForm] CreateQuestionDto requestDto) { var result = await _questionService.Create(requestDto, User.Identity.Name); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPut] @@ -60,41 +60,41 @@ public async Task SubDetail(string subId) public async Task Index() { var result = await _questionService.GetAll(); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpDelete("Delete")] public async Task Delete(string Id) { var result = await _questionService.Delete(Id, User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Like")] [Authorize] public async Task Like([FromForm] QuestionFpkDto questionFpk) { var result = await _questionService.AddOrUnLikeQuestion(questionFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Like")] public async Task GetLikePost([FromQuery] QuestionFpkDto questionFpk) { var result = await _questionService.GetLike(questionFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Save")] [Authorize] public async Task GetSaveQuestion([FromQuery] QuestionFpkDto questionFpk) { var result = await _questionService.GetSave(questionFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Save")] [Authorize] public async Task Save([FromForm] QuestionFpkDto questionFpk) { var result = await _questionService.AddOrRemoveSaveQuestion(questionFpk); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("MyQuestionSaved")] [Authorize] @@ -102,7 +102,7 @@ public async Task GetMyQuestionSaved() { var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""; var result = await _questionService.GetMyQuestionSaved(id); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("MyQuestion")] [Authorize] @@ -110,14 +110,14 @@ public async Task GetMyQuestion() { var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""; var result = await _questionService.GetMyQuestion(id); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost("Report")] [Authorize] public async Task Report([FromBody] ReportQuestionDto reportquestionDto) { var result = await _questionService.ReportQuestion(reportquestionDto); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Report")] @@ -125,26 +125,26 @@ public async Task Report([FromBody] ReportQuestionDto reportquest public async Task GetReport() { var result = await _questionService.GetReport(); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("Search")] public async Task Search([FromQuery] string keyWord) { var result = await _questionService.SearchQuestions(keyWord); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("AllTag")] public async Task GetAllTag( int numberTag) { var result = await _questionService.GetAllTag(numberTag); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("FindByTag")] public async Task GetQuestionByTag(string tag) { var result = await _questionService.GetQuestionByTag(tag); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } } diff --git a/VNH.WebAPi/Controllers/TopicController.cs b/VNH.WebAPi/Controllers/TopicController.cs index e8ed2c6..7ad2102 100644 --- a/VNH.WebAPi/Controllers/TopicController.cs +++ b/VNH.WebAPi/Controllers/TopicController.cs @@ -20,34 +20,34 @@ public TopicController(ITopicService topicService) { public async Task GetAllTopic() { var result = await _topicService.GetAllTopic(); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpGet("GetById")] public async Task GetById(string idTopic) { var result = await _topicService.GetById(idTopic); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPost] [Authorize] public async Task CreateTopic(string topic) { var result = await _topicService.CreateTopic(topic, User.Identity.Name); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpPut] [Authorize] public async Task UpdateTopic(Guid topicId ,string topic) { var result = await _topicService.UpdateTopic(topicId, topic); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } [HttpDelete] [Authorize] public async Task DeleteTopic(Guid topicId ) { var result = await _topicService.DeleteTopic(topicId); - return result is null ? BadRequest(result) : Ok(result); + return !result.IsSuccessed ? BadRequest(result) : Ok(result); } } diff --git a/VNH.WebAPi/Program.cs b/VNH.WebAPi/Program.cs index 0b246d4..8a45615 100644 --- a/VNH.WebAPi/Program.cs +++ b/VNH.WebAPi/Program.cs @@ -20,11 +20,12 @@ public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); - // Add services to the container. - // Add DI in other layer var connectionString = builder.Environment.IsDevelopment() ? builder.Configuration.GetConnectionString("LocalDataConnect") : builder.Configuration.GetConnectionString("DataConnect"); + + // var connectionString = builder.Configuration.GetConnectionString("DataConnect"); + builder.Services.AddDbContext(options => { options.UseSqlServer(connectionString); diff --git a/VNH.WebAPi/VNH.WebAPi.csproj b/VNH.WebAPi/VNH.WebAPi.csproj index 499a48a..4ebcef3 100644 --- a/VNH.WebAPi/VNH.WebAPi.csproj +++ b/VNH.WebAPi/VNH.WebAPi.csproj @@ -26,6 +26,7 @@ + diff --git a/VNH.WebAPi/appsettings.json b/VNH.WebAPi/appsettings.json index ff08dc6..320e892 100644 --- a/VNH.WebAPi/appsettings.json +++ b/VNH.WebAPi/appsettings.json @@ -8,12 +8,12 @@ "AllowedHosts": "*", "Tokens": { "Key": "0123456789ABCDEF", - "Issuer": "https://webapi.tedu.com.vn" + "Issuer": "https://tyls.fun" }, "ConnectionStrings": { - "LocalDataConnect": "Data Source=.;Initial Catalog=VietNamHistory;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;", - "DataConnect": "Data Source=SQL5106.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;User Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai" - //"DataConnect": "Data Source=.\\MSSQLSERVER2022;Initial Catalog=db_aa121e_vuanhpham25;User Id=tyls;Password=9F3s2k5*n" + "LocalDataConnect": "Data Source=.;Initial Catalog=tyls;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;", + //"DataConnect": "Data Source=SQL5112.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;User Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai" + "DataConnect": "Data Source=.\\MSSQLSERVER2022;Initial Catalog=tyls;User Id=toiyeulichsu;Password=MheZDu9$oGbrYlL#S%ApJ^qf;TrustServerCertificate=True;Encrypt=False" }, "MailSettings": { diff --git a/VNH.WebAPi/wwwroot/Documents/Bai-tap-ngay-041223-012025.081174.docx b/VNH.WebAPi/wwwroot/Documents/Bai-tap-ngay-041223-012025.081174.docx new file mode 100644 index 0000000..6117fc9 Binary files /dev/null and b/VNH.WebAPi/wwwroot/Documents/Bai-tap-ngay-041223-012025.081174.docx differ diff --git a/VNH.WebAPi/wwwroot/Documents/Bo-tai-lieu-su-moi-nhat-104557.795228.pdf b/VNH.WebAPi/wwwroot/Documents/Bo-tai-lieu-su-moi-nhat-104557.795228.pdf new file mode 100644 index 0000000..1c3ff06 Binary files /dev/null and b/VNH.WebAPi/wwwroot/Documents/Bo-tai-lieu-su-moi-nhat-104557.795228.pdf differ diff --git a/VNH.WebAPi/wwwroot/Documents/On-thi-lich-su-12-221624.727457.pdf b/VNH.WebAPi/wwwroot/Documents/On-thi-lich-su-12-221624.727457.pdf new file mode 100644 index 0000000..ef95e81 Binary files /dev/null and b/VNH.WebAPi/wwwroot/Documents/On-thi-lich-su-12-221624.727457.pdf differ diff --git a/VNH.WebAPi/wwwroot/Documents/Tai-lieu-on-thi-172459.016200.pdf b/VNH.WebAPi/wwwroot/Documents/Tai-lieu-on-thi-172459.016200.pdf new file mode 100644 index 0000000..ef95e81 Binary files /dev/null and b/VNH.WebAPi/wwwroot/Documents/Tai-lieu-on-thi-172459.016200.pdf differ diff --git a/VNH.WebAPi/wwwroot/Documents/Tai-lieu-trac-nghiem-on-thi-172533.236452.pdf b/VNH.WebAPi/wwwroot/Documents/Tai-lieu-trac-nghiem-on-thi-172533.236452.pdf new file mode 100644 index 0000000..d6c730a Binary files /dev/null and b/VNH.WebAPi/wwwroot/Documents/Tai-lieu-trac-nghiem-on-thi-172533.236452.pdf differ diff --git a/VNH.WebAPi/wwwroot/Documents/Tai-lieu-trac-nghiemh-104435.415345.docx b/VNH.WebAPi/wwwroot/Documents/Tai-lieu-trac-nghiemh-104435.415345.docx new file mode 100644 index 0000000..52336de Binary files /dev/null and b/VNH.WebAPi/wwwroot/Documents/Tai-lieu-trac-nghiemh-104435.415345.docx differ diff --git a/VNH.WebAPi/wwwroot/Documents/Trac-nghiem-moi-nhat-ve-lich-su-104726.808297.pdf b/VNH.WebAPi/wwwroot/Documents/Trac-nghiem-moi-nhat-ve-lich-su-104726.808297.pdf new file mode 100644 index 0000000..68d4879 Binary files /dev/null and b/VNH.WebAPi/wwwroot/Documents/Trac-nghiem-moi-nhat-ve-lich-su-104726.808297.pdf differ diff --git a/VNH.WebAPi/wwwroot/Documents/kien-thuc-lich-su-Viet-Nam-101542.113915.pdf b/VNH.WebAPi/wwwroot/Documents/kien-thuc-lich-su-Viet-Nam-101542.113915.pdf new file mode 100644 index 0000000..d6c730a Binary files /dev/null and b/VNH.WebAPi/wwwroot/Documents/kien-thuc-lich-su-Viet-Nam-101542.113915.pdf differ diff --git a/VNH.WebAPi/wwwroot/Images/8869b5cb-2505-4aa1-8df3-a24c38088301.png b/VNH.WebAPi/wwwroot/Images/8869b5cb-2505-4aa1-8df3-a24c38088301.png new file mode 100644 index 0000000..d14beef Binary files /dev/null and b/VNH.WebAPi/wwwroot/Images/8869b5cb-2505-4aa1-8df3-a24c38088301.png differ diff --git a/VNH.WebAPi/wwwroot/Images/e5ba794b-f6a6-4bb4-b37f-d1898492b32b.avif b/VNH.WebAPi/wwwroot/Images/e5ba794b-f6a6-4bb4-b37f-d1898492b32b.avif new file mode 100644 index 0000000..437a15b Binary files /dev/null and b/VNH.WebAPi/wwwroot/Images/e5ba794b-f6a6-4bb4-b37f-d1898492b32b.avif differ