diff --git a/VNH.Application/Common/Contants/SystemConstants.cs b/VNH.Application/Common/Contants/SystemConstants.cs index 5e1fac6..0daafcf 100644 --- a/VNH.Application/Common/Contants/SystemConstants.cs +++ b/VNH.Application/Common/Contants/SystemConstants.cs @@ -5,10 +5,10 @@ public static class SystemConstants public const string Token = "Token"; public const string BaseAddress = "BaseAddress"; - 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 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 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=VietNamHistory;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;"; } } diff --git a/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs index f42fc12..edf3826 100644 --- a/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs +++ b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs @@ -8,7 +8,10 @@ namespace VNH.Application.DTOs.Catalog.Forum.Answer { public class AnswerFpkDto { + public string QuestionId { get; set; } = string.Empty; public string AnswerId { get; set; } = string.Empty; public string UserId { get; set; } = string.Empty; + public string QuestionUserId { get; set; } = string.Empty; + } } diff --git a/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs index 6f76f98..147ceb2 100644 --- a/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs +++ b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs @@ -8,14 +8,14 @@ public class AnswerQuestionDto public Guid? Id { get; set; } = Guid.NewGuid(); public Guid? AuthorId { get; set; } - public string QuestionId { get; set; } = string.Empty; public UserShortDto? UserShort { get; set; } public string Content { get; set; } = String.Empty; - public DateTime? CreatedAt { get; set; } = DateTime.Now; + public DateTime? CreatedAt { get; set; } public DateTime? UpdatedAt { get; set; } public bool Confirm { get; set; } = false; public bool MostConfirm { get; set; } = false; + public int VoteNumber { get; set; } = 0; public List? SubAnswer { get; set; } = new(); } @@ -27,7 +27,7 @@ public class SubAnswerQuestionDto public Guid AuthorId { get; set; } public string Content { get; set; } = string.Empty; [Column(TypeName = "datetime")] - public DateTime? CreatedAt { get; set; } = DateTime.Now; + public DateTime? CreatedAt { get; set; } [Column(TypeName = "datetime")] public DateTime? UpdatedAt { get; set; } diff --git a/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs b/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs index 2367908..9583704 100644 --- a/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs +++ b/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs @@ -1,4 +1,5 @@ using VNH.Application.DTOs.Catalog.Forum.Answer; +using VNH.Application.DTOs.Common; using VNH.Application.DTOs.Common.ResponseNotification; using VNH.Domain; @@ -18,8 +19,7 @@ public interface IAnswerService Task> UpdateSubAnswer(SubAnswerQuestionDto answer); Task> DeteleSubAnswer(string id); - Task> ConfirmOrNoConfirm(AnswerFpkDto answerFpk); - - + Task> ConfirmedByQuestioner(string answerId); + Task> VoteConfirmByUser(AnswerFpkDto answer); } } diff --git a/VNH.Application/Interfaces/Catalog/NewsHistory/INewsService.cs b/VNH.Application/Interfaces/Catalog/NewsHistory/INewsService.cs new file mode 100644 index 0000000..2c252a1 --- /dev/null +++ b/VNH.Application/Interfaces/Catalog/NewsHistory/INewsService.cs @@ -0,0 +1,9 @@ +using VNH.Domain; + +namespace VNH.Application.Interfaces.Catalog.NewsHistory +{ + public interface INewsService + { + Task> GetNews(string url); + } +} diff --git a/VNH.Domain/Entities/Answer.cs b/VNH.Domain/Entities/Answer.cs index 723674b..5a37a8b 100644 --- a/VNH.Domain/Entities/Answer.cs +++ b/VNH.Domain/Entities/Answer.cs @@ -29,6 +29,7 @@ public Answer() public DateTime? UpdatedAt { get; set; } public bool? Confirm { get; set; } public bool? MostConfirm { get; set; } + public bool IsDeleted { get; set; } = false; [ForeignKey("AuthorId")] [InverseProperty("Answers")] diff --git a/VNH.Domain/Entities/AnswerVote.cs b/VNH.Domain/Entities/AnswerVote.cs index 56805e8..29fe7e0 100644 --- a/VNH.Domain/Entities/AnswerVote.cs +++ b/VNH.Domain/Entities/AnswerVote.cs @@ -15,6 +15,7 @@ public partial class AnswerVote public Guid Id { get; set; } public Guid? AnswerId { get; set; } public Guid? UserId { get; set; } + public Guid? QuestionId { get; set; } [ForeignKey("AnswerId")] [InverseProperty("AnswerVotes")] diff --git a/VNH.Domain/Entities/Course.cs b/VNH.Domain/Entities/Course.cs index 16a5dfb..985ba20 100644 --- a/VNH.Domain/Entities/Course.cs +++ b/VNH.Domain/Entities/Course.cs @@ -31,6 +31,7 @@ public Course() [Column(TypeName = "datetime")] public DateTime? UpdatedAt { get; set; } public string Image { get; set; } = string.Empty; + public bool IsDeleted { get; set; } = false; [ForeignKey("UserId")] [InverseProperty("Courses")] public virtual User User { get; set; } diff --git a/VNH.Domain/Entities/Document.cs b/VNH.Domain/Entities/Document.cs index 75bc8d8..08fc8ca 100644 --- a/VNH.Domain/Entities/Document.cs +++ b/VNH.Domain/Entities/Document.cs @@ -24,7 +24,7 @@ public Document() [StringLength(500)] public string Description { get; set; } public string SubId { get; set; } - + public bool IsDeleted { get; set; } = false; public string FileName { get; set; } [StringLength(255)] [Unicode(false)] diff --git a/VNH.Domain/Entities/Lesson.cs b/VNH.Domain/Entities/Lesson.cs index ced11a2..48d0a26 100644 --- a/VNH.Domain/Entities/Lesson.cs +++ b/VNH.Domain/Entities/Lesson.cs @@ -22,11 +22,13 @@ public partial class Lesson public string Description { get; set; } public Guid? CourseId { get; set; } public Guid? ExerciseId { get; set; } + public bool IsDeleted { get; set; } = false; [ForeignKey("CourseId")] [InverseProperty("Lessons")] public virtual Course Course { get; set; } [InverseProperty("IdNavigation")] public virtual Exercise Exercise { get; set; } + } } \ No newline at end of file diff --git a/VNH.Domain/Entities/News.cs b/VNH.Domain/Entities/News.cs index 42a5305..a3c685c 100644 --- a/VNH.Domain/Entities/News.cs +++ b/VNH.Domain/Entities/News.cs @@ -13,16 +13,12 @@ public partial class News [Key] public Guid Id { get; set; } [Required] - [StringLength(255)] public string Title { get; set; } [Column(TypeName = "text")] public string Description { get; set; } = string.Empty; [Column(TypeName = "text")] public string Image { get; set; } = string.Empty; - [Column(TypeName = "datetime")] - public DateTime? CreatedAt { get; set; } [Required] - [StringLength(255)] [Unicode(false)] public string Url { get; set; } } diff --git a/VNH.Domain/Entities/Post.cs b/VNH.Domain/Entities/Post.cs index 7269414..55eac0e 100644 --- a/VNH.Domain/Entities/Post.cs +++ b/VNH.Domain/Entities/Post.cs @@ -33,6 +33,7 @@ public Post() public Guid UserId { get; set; } public string Image { get; set; } = string.Empty; public int ViewNumber { get; set; } + public bool IsDeleted { get; set; } = false; [ForeignKey("TopicId")] [InverseProperty("Posts")] diff --git a/VNH.Domain/Entities/Question.cs b/VNH.Domain/Entities/Question.cs index 353af57..795e5b1 100644 --- a/VNH.Domain/Entities/Question.cs +++ b/VNH.Domain/Entities/Question.cs @@ -28,7 +28,9 @@ public Question() [Column(TypeName = "datetime")] public DateTime CreatedAt { get; set; } - + public bool IsDeleted { get; set; } = false; + + [ForeignKey("AuthorId")] [InverseProperty("Questions")] diff --git a/VNH.Domain/Entities/User.cs b/VNH.Domain/Entities/User.cs index f0a859c..d143349 100644 --- a/VNH.Domain/Entities/User.cs +++ b/VNH.Domain/Entities/User.cs @@ -49,6 +49,7 @@ public User() public Gender Gender { get; set; } public string Image { get; set; } = string.Empty; public string NumberConfirm { get; set; } // Confirm Email + public bool IsDeleted { get; set; } = false; [InverseProperty("User")] public virtual ICollection AnswerVotes { get; set; } [InverseProperty("Author")] diff --git a/VNH.Infrastructure/Implement/Catalog/Account/AccountService.cs b/VNH.Infrastructure/Implement/Catalog/Account/AccountService.cs index 1392a80..f8fb6a9 100644 --- a/VNH.Infrastructure/Implement/Catalog/Account/AccountService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Account/AccountService.cs @@ -50,6 +50,10 @@ public AccountService(VietNamHistoryContext context, public async Task> Authenticate(LoginRequest request) { var user = await _userManager.FindByEmailAsync(request.Email); + if(user != null && user.IsDeleted) + { + user = null; + } var errorMessages = new Dictionary, string> { @@ -88,7 +92,8 @@ public async Task GetToken(User user) new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Email,user.Email), new Claim(ClaimTypes.Role, string.Join(";",roles)), - new Claim(ClaimTypes.Name, user.UserName), + new Claim(ClaimTypes.Name, user.Email), + new Claim(ClaimTypes.Surname, user.Fullname), }; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"])); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); diff --git a/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs b/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs index 1ca38c4..01c0721 100644 --- a/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using VNH.Application.DTOs.Catalog.Forum.Answer; using VNH.Application.DTOs.Catalog.Users; +using VNH.Application.DTOs.Common; using VNH.Application.DTOs.Common.ResponseNotification; using VNH.Application.Interfaces.Catalog.Forum; using VNH.Domain; @@ -33,7 +34,7 @@ public AnswerService(UserManager userManager, IHubContext ans private UserShortDto? GetUserShort(List users, Guid? IdUser) { return users - .Where(x => x.Id.Equals(IdUser)) + .Where(x => x.Id.Equals(IdUser) && !x.IsDeleted) .Select(x => new UserShortDto { Id = x.Id, @@ -52,25 +53,48 @@ public AnswerService(UserManager userManager, IHubContext ans answer.UserShort = GetUserShort(users, item.AuthorId); result.Add(answer); } - return result; + return result.OrderBy(x=>x.CreatedAt).ToList(); } public async Task>> GetAnswer(string questionId) { - var question = await _dataContext.Questions.FirstAsync(x => x.Id.Equals(Guid.Parse(questionId))); + var question = await _dataContext.Questions.FirstAsync(x => x.Id.Equals(Guid.Parse(questionId)) && !x.IsDeleted); if (question == null) { return new ApiSuccessResult>(); } - var users = await _dataContext.User.ToListAsync(); - var answerQuestion = await _dataContext.Answers.Where(x => x.QuestionId.Equals(question.Id)).OrderByDescending(x => x.CreatedAt).ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); + var answerQuestion = await _dataContext.Answers.Where(x => x.QuestionId.Equals(question.Id) && !x.IsDeleted).OrderByDescending(x => x.CreatedAt).ToListAsync(); var subAnswerQuestion = await _dataContext.SubAnswers.ToListAsync(); var result = new List(); - foreach(var item in answerQuestion) + var viewVotes = await _dataContext.AnswerVotes + .Where(x => x.QuestionId.ToString() == questionId) + .GroupBy(x => x.AnswerId) + .Select(group => new { AnswerId = group.Key, VoteCount = group.Count()}) + .ToListAsync(); + + // mostConfirm required > 10 selected + var mostview = viewVotes.Where(x=>x.VoteCount > 10).OrderByDescending(x=>x.VoteCount).Take(1).FirstOrDefault(); + foreach (var item in answerQuestion) { var subAnswer = subAnswerQuestion.Where(x => x.PreAnswerId.Equals(item.Id)).OrderByDescending(x => x.CreatedAt).ToList(); var answ = _mapper.Map(item); + var voteNumber = viewVotes.FirstOrDefault(x => x.AnswerId == item.Id); + answ.VoteNumber = voteNumber != null ? voteNumber.VoteCount : 0; + if(mostview != null) + { + if (mostview.AnswerId == item.Id && item.MostConfirm != true) + { + item.MostConfirm = true; + _dataContext.Answers.Update(item); + } + if (mostview.AnswerId != item.Id && item.MostConfirm == true) + { + item.MostConfirm = false; + _dataContext.Answers.Update(item); + } + } answ.UserShort = GetUserShort(users, item.AuthorId); if(subAnswer.Count > 0) { @@ -78,6 +102,9 @@ public async Task>> GetAnswer(string questionI } result.Add(answ); } + await _dataContext.SaveChangesAsync(); + result = result.OrderByDescending(x=>x.VoteNumber).ToList(); + return new ApiSuccessResult>(result); } @@ -86,7 +113,7 @@ public async Task>> GetAnswer(string questionI public async Task>> CreateAnswer(AnswerQuestionDto answer) { - var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(answer.QuestionId))); + var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(answer.QuestionId)) && !x.IsDeleted); if (question == null) { return new ApiErrorResult>("Không tìm câu hỏi mà bạn trả lời, có thể nó đã bị xóa"); @@ -94,6 +121,7 @@ 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(); @@ -107,7 +135,7 @@ public async Task>> CreateAnswer(AnswerQuestio public async Task>> UpdateAnswer(AnswerQuestionDto answer) { - var questionAnswer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id == answer.Id); + var questionAnswer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id == answer.Id && !x.IsDeleted); if (questionAnswer == null) { return new ApiErrorResult>("Không tìm thấy câu hỏi bạn trả lời!"); @@ -127,12 +155,13 @@ public async Task>> UpdateAnswer(AnswerQuestio public async Task> DeteleAnswer(string id) { - var answer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id))); + var answer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id)) && !x.IsDeleted); if (answer == null) { return new ApiErrorResult("Không tìm thấy câu hỏi"); } - _dataContext.Answers.Remove(answer); + answer.IsDeleted = true; + _dataContext.Answers.Update(answer); await _dataContext.SaveChangesAsync(); var answers = await GetAnswer(answer.QuestionId.ToString()); @@ -141,16 +170,30 @@ public async Task> DeteleAnswer(string id) return new ApiSuccessResult(); } - + private async Task>> GetSubAnswer(string? answerId) + { + List result = new(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); + var listSubAnswer = await _dataContext.SubAnswers.Where(x => x.PreAnswerId.ToString() == answerId).OrderBy(x => x.CreatedAt).ToListAsync(); + foreach (var item in listSubAnswer) + { + var answer = _mapper.Map(item); + answer.UserShort = GetUserShort(users, item.AuthorId); + result.Add(answer); + } + return new ApiSuccessResult>(result); + } public async Task> CreateSubAnswer(SubAnswerQuestionDto subAnswer) { - var answer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id.Equals(subAnswer.PreAnswerId)); + var answer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id.Equals(subAnswer.PreAnswerId) && !x.IsDeleted); if (answer == null) { return new ApiErrorResult("Không tìm được câu trả lời"); } SubAnswer sub = _mapper.Map(subAnswer); sub.PreAnswerId = answer.Id; + sub.CreatedAt = DateTime.Now; + _dataContext.SubAnswers.Add(sub); await _dataContext.SaveChangesAsync(); var answers = await GetAnswer(answer.QuestionId.ToString()); @@ -159,7 +202,6 @@ public async Task> CreateSubAnswer(SubAnswerQuestionDto subAns } - public async Task> UpdateSubAnswer(SubAnswerQuestionDto subAnswer) { @@ -175,26 +217,13 @@ public async Task> UpdateSubAnswer(SubAnswerQuestionDto subAns _dataContext.SubAnswers.Update(subAns); await _dataContext.SaveChangesAsync(); - var answers = await GetSubAnswer(subAns.PreAnswerId.ToString()); - await _answerHubContext.Clients.All.SendAsync("ReceiveAnswer", answers); + var subAnswers = await GetSubAnswer(subAns.PreAnswerId.ToString()); + await _answerHubContext.Clients.All.SendAsync("ReceiveSubAnswer", subAnswers); return new ApiSuccessResult("Đã cập nhập bình luận"); } - private async Task> GetSubAnswer(string? answerId) - { - List result = new(); - var users = await _dataContext.User.ToListAsync(); - var listSubAnswer = await _dataContext.SubAnswers.Where(x=>x.PreAnswerId.ToString() == answerId).ToListAsync(); - foreach (var item in listSubAnswer) - { - var answer = _mapper.Map(item); - answer.UserShort = GetUserShort(users, item.AuthorId); - result.Add(answer); - } - return result; - } - + public async Task> DeteleSubAnswer(string id) { var subAnswer = await _dataContext.SubAnswers.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id))); @@ -205,41 +234,68 @@ public async Task> DeteleSubAnswer(string id) _dataContext.SubAnswers.Remove(subAnswer); await _dataContext.SaveChangesAsync(); - var answers = await GetSubAnswer(subAnswer.PreAnswerId.ToString()); - await _answerHubContext.Clients.All.SendAsync("ReceiveAnswer", answers); + var subAnswers = await GetSubAnswer(subAnswer.PreAnswerId.ToString()); + await _answerHubContext.Clients.All.SendAsync("ReceiveSubAnswer", subAnswers); return new ApiSuccessResult(); } - public async Task> ConfirmOrNoConfirm(AnswerFpkDto answerFpk) + public async Task> ConfirmedByQuestioner(string answerId) { - var answer = await _dataContext.Answers.FirstOrDefaultAsync(x=> x.Id.Equals(Guid.Parse(answerFpk.AnswerId))); - if(answer == null) + var answer = await _dataContext.Answers.FirstOrDefaultAsync(x=> x.Id.Equals(Guid.Parse(answerId)) && !x.IsDeleted); + if (answer == null) + { + return new ApiErrorResult("Không tìm thấy câu trả lời"); + } + if (answer.Confirm == true) + { + answer.Confirm = false; + _dataContext.Answers.Update(answer); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(new() { Check = false, Quantity = 1 }); + } else { - return new ApiErrorResult("Không tìm thấy câu trả lời"); + var item = await _dataContext.Answers.FirstOrDefaultAsync(x => x.QuestionId.Equals(answer.QuestionId) && x.Confirm == true); + if(item != null) + { + item.Confirm = false; + answer.Confirm = true; + _dataContext.Answers.Update(item); + _dataContext.Answers.Update(answer); + } else + { + answer.Confirm = true; + _dataContext.Answers.Update(answer); + } + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(new() { Check = true, Quantity = 1 }); } - var check = _dataContext.AnswerVotes.Where(x => x.AnswerId == answer.Id && x.UserId == Guid.Parse(answerFpk.UserId)).FirstOrDefault(); - var mess = ""; - var voteNumber = await _dataContext.AnswerVotes.Where(x=>x.AnswerId == answer.Id).CountAsync(); - if(check is null) + + + } + + public async Task> VoteConfirmByUser(AnswerFpkDto answer) + { + var userVote = await _dataContext.AnswerVotes.FirstOrDefaultAsync(x => x.UserId.ToString().Equals(answer.UserId) && x.AnswerId.ToString().Equals(answer.AnswerId)); + if (userVote == null) { - var vote = new AnswerVote() + var answerVote = new AnswerVote() { Id = Guid.NewGuid(), - AnswerId = answer.Id, - UserId = Guid.Parse(answerFpk.UserId), + QuestionId = Guid.Parse(answer.QuestionId), + AnswerId = Guid.Parse(answer.AnswerId), + UserId = Guid.Parse(answer.UserId) }; - _dataContext.AnswerVotes.Add(vote); - await _dataContext.SaveChangesAsync(); - return new ApiSuccessResult(voteNumber + 1); + _dataContext.AnswerVotes.Add(answerVote); } else { - _dataContext.AnswerVotes.Remove(check); - await _dataContext.SaveChangesAsync(); - return new ApiSuccessResult(voteNumber - 1); + _dataContext.AnswerVotes.Remove(userVote); } + await _dataContext.SaveChangesAsync(); + var numberVote = await _dataContext.AnswerVotes.Where(x=>x.AnswerId == Guid.Parse(answer.AnswerId)).CountAsync(); + return new ApiSuccessResult(new() { Check = true, Quantity = numberVote }); } } } diff --git a/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs b/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs index a3a2f01..4785b09 100644 --- a/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs @@ -83,7 +83,7 @@ public async Task> Update(CreateQuestionDto reque { var user = await _userManager.FindByEmailAsync(name); - var updateQuestion = _dataContext.Questions.First(x => x.Id.Equals(requestDto.Id)); + var updateQuestion = _dataContext.Questions.First(x => x.Id.Equals(requestDto.Id) && !x.IsDeleted); if (updateQuestion is null) { return new ApiErrorResult("Lỗi :Câu hỏi không được cập nhập (không tìm thấy bài viết)"); @@ -137,7 +137,7 @@ public async Task> Update(CreateQuestionDto reque public async Task> Detail(string Id) { - var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(Id))); + var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(Id)) && !x.IsDeleted); if (question is null) { return new ApiErrorResult("Không tìm thấy câu hỏi"); @@ -176,7 +176,7 @@ public async Task> Detail(string Id) public async Task>> GetAll() { - var questions = await _dataContext.Questions.OrderByDescending(x => x.CreatedAt).ToListAsync(); + var questions = await _dataContext.Questions.Where(x=> !x.IsDeleted).OrderByDescending(x => x.CreatedAt).ToListAsync(); var users = await _dataContext.User.ToListAsync(); var result = new List(); @@ -207,8 +207,9 @@ public async Task> Delete(string id, string userId) { return new ApiErrorResult("Không tìm thấy câu hỏi"); } - - _dataContext.Questions.Remove(question); + + question.IsDeleted = true; + _dataContext.Questions.Update(question); await _dataContext.SaveChangesAsync(); @@ -217,7 +218,7 @@ public async Task> Delete(string id, string userId) public async Task> AddOrRemoveSaveQuestion(QuestionFpkDto questionFpk) { - var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(questionFpk.QuestionId))); + var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(questionFpk.QuestionId)) && !x.IsDeleted); if (question is null) { return new ApiErrorResult("Không tìm thấy câu hỏi"); @@ -248,7 +249,7 @@ public async Task> AddOrRemoveSaveQuestion(QuestionFpkD } public async Task> GetSave(QuestionFpkDto questionFpk) { - var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(questionFpk.QuestionId))); + 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(); var check = await _dataContext.QuestionSaves.Where(x => x.QuestionId.Equals(question.Id) && x.UserId == Guid.Parse(questionFpk.UserId)).FirstOrDefaultAsync(); return new ApiSuccessResult(new() { Check = check != null, Quantity = number }) ; @@ -272,7 +273,7 @@ public async Task>> GetQuestionByTag(string .Where(question => _dataContext.QuestionTags .Any(questionTag => _dataContext.Tags .Any(tagEntity => tagEntity.Name.ToLower().Contains(tag.ToLower()) && tagEntity.Id == questionTag.TagId) - && questionTag.QuestionId == question.Id)) + && questionTag.QuestionId == question.Id) && !question.IsDeleted) .ToListAsync(); if (questions.IsNullOrEmpty()) { @@ -298,7 +299,7 @@ public async Task>> GetQuestionByTag(string public async Task> SubDetail(string subId) { - var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.SubId.Equals(subId)); + var question = await _dataContext.Questions.Where(x=> !x.IsDeleted).FirstOrDefaultAsync(x => x.SubId.Equals(subId)); if (question is null) { return new ApiErrorResult("Không tìm thấy câu hỏi"); @@ -336,7 +337,7 @@ public async Task> SubDetail(string subId) public async Task> GetLike(QuestionFpkDto questionFpk) { - var question = _dataContext.Questions.First(x => x.SubId.Equals(questionFpk.QuestionId)); + var question = _dataContext.Questions.First(x => x.SubId.Equals(questionFpk.QuestionId) && !x.IsDeleted); var check = await _dataContext.QuestionLikes.Where(x => x.QuestionId.Equals(question.Id) && x.UserId == Guid.Parse(questionFpk.UserId)).FirstOrDefaultAsync(); var number = await _dataContext.QuestionLikes.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); return new ApiSuccessResult(new() { Check = (check != null), Quantity = number }); @@ -344,7 +345,7 @@ public async Task> GetLike(QuestionFpkDto questionFpk) public async Task> AddOrUnLikeQuestion(QuestionFpkDto questionFpk) { - var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.SubId.Equals(questionFpk.QuestionId)); + var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.SubId.Equals(questionFpk.QuestionId) && !x.IsDeleted); if (question is null) { return new ApiErrorResult("Không tìm thấy câu hỏi"); @@ -374,7 +375,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))).ToListAsync(); + var questions = await _dataContext.Questions.Where(x => x.AuthorId.Equals(Guid.Parse(id)) && !x.IsDeleted).ToListAsync(); var result = new List(); foreach (var item in questions) { @@ -390,7 +391,7 @@ public async Task>> GetMyQuestion(string id) public async Task> ReportQuestion(ReportQuestionDto reportquestionDto) { - var question = _dataContext.Questions.FirstOrDefault(x => x.SubId.Equals(reportquestionDto.QuestionId)); + var question = _dataContext.Questions.FirstOrDefault(x => x.SubId.Equals(reportquestionDto.QuestionId) && !x.IsDeleted); if (question == null) { return new ApiErrorResult("Bài viết không tồn tại"); @@ -477,6 +478,13 @@ select question foreach (var item in questions) { var question = _mapper.Map(item); + var userShort = users.First(x => x.Id == item.AuthorId); + if (userShort is not null) + { + question.UserShort.FullName = userShort.Fullname; + 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(); diff --git a/VNH.Infrastructure/Implement/Catalog/NewsHistory/NewsService.cs b/VNH.Infrastructure/Implement/Catalog/NewsHistory/NewsService.cs new file mode 100644 index 0000000..ecaf2c1 --- /dev/null +++ b/VNH.Infrastructure/Implement/Catalog/NewsHistory/NewsService.cs @@ -0,0 +1,53 @@ +using HtmlAgilityPack; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.Interfaces.Catalog.NewsHistory; +using VNH.Domain; + +namespace VNH.Infrastructure.Implement.Catalog.NewsHistory +{ + public class NewsService : INewsService + { + + public async Task> GetNews(string url) + { + var httpClient = new HttpClient(); + var html = httpClient.GetStringAsync(url).Result; + + var htmlDocument = new HtmlDocument(); + htmlDocument.LoadHtml(html); + + var newsList = new List(); + + var newsNodes = htmlDocument.DocumentNode.SelectNodes("//ul[@class='list-news']/li"); + if (newsNodes != null) + { + foreach (var newsNode in newsNodes) + { + var titleNode = newsNode.SelectSingleNode(".//h3/a"); + var descriptionNode = newsNode.SelectSingleNode(".//div[@class='sapo']"); + var imageNode = newsNode.SelectSingleNode(".//img"); + + if (titleNode != null && descriptionNode != null && imageNode != null) + { + var news = new News + { + Id = Guid.NewGuid(), + Title = titleNode.InnerText.Trim(), + Description = descriptionNode.InnerText.Trim(), + Image = imageNode.GetAttributeValue("src", "").Trim(), + Url = titleNode.GetAttributeValue("href", "").Trim() + }; + + newsList.Add(news); + } + } + } + + return newsList; + } + } +} diff --git a/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs b/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs index 5eb30bd..3939e22 100644 --- a/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs @@ -88,7 +88,7 @@ public async Task> Update(CreatePostDto requestDto, s { var user = await _userManager.FindByEmailAsync(name); - var updatePost = _dataContext.Posts.First(x=>x.Id.Equals(requestDto.Id)); + var updatePost = _dataContext.Posts.First(x=>x.Id.Equals(requestDto.Id) && !x.IsDeleted); if (updatePost is null) { return new ApiErrorResult("Lỗi :Bài viết không được cập nhập (không tìm thấy bài viết)"); @@ -143,7 +143,7 @@ public async Task> Update(CreatePostDto requestDto, s public async Task> Detail(string Id) { - var post = await _dataContext.Posts.FirstOrDefaultAsync(x=>x.SubId.Equals(Id)); + var post = await _dataContext.Posts.FirstOrDefaultAsync(x=>x.SubId.Equals(Id) && !x.IsDeleted); if (post is null) { return new ApiErrorResult("Không tìm thấy bài viết"); @@ -183,8 +183,8 @@ public async Task> Detail(string Id) public async Task>> GetAll() { - var posts = await _dataContext.Posts.OrderByDescending(x => x.CreatedAt).ToListAsync(); - var users = await _dataContext.User.ToListAsync(); + var posts = await _dataContext.Posts.Where(x=>!x.IsDeleted).OrderByDescending(x => x.CreatedAt).ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); var topics = await _dataContext.Topics.ToListAsync(); var result = new List(); @@ -206,8 +206,8 @@ public async Task>> GetAll() } public async Task>> GetAllMobile() { - var posts = await _dataContext.Posts.OrderByDescending(x => x.CreatedAt).ToListAsync(); - var users = await _dataContext.User.ToListAsync(); + var posts = await _dataContext.Posts.Where(x => !x.IsDeleted).OrderByDescending(x => x.CreatedAt).ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); var topics = await _dataContext.Topics.ToListAsync(); var result = new List(); @@ -233,17 +233,17 @@ public async Task>> GetAllMobile() public async Task> Delete(string id, string userId) { - var post = await _dataContext.Posts.FirstOrDefaultAsync(x => x.Id.Equals(id) && x.UserId.ToString().Equals(userId)); + var post = await _dataContext.Posts.FirstOrDefaultAsync(x => x.Id.Equals(id) && x.UserId.ToString().Equals(userId) && !x.IsDeleted); if (post is null) { return new ApiErrorResult("Không tìm thấy bài viết"); } - if (post.Image != string.Empty) - { - await _storageService.DeleteFileAsync(post.Image); - } - _dataContext.Posts.Remove(post); - + //if (post.Image != string.Empty) + //{ + // await _storageService.DeleteFileAsync(post.Image); + //} + post.IsDeleted = true; + _dataContext.Posts.Update(post); await _dataContext.SaveChangesAsync(); return new ApiSuccessResult("Đã xóa bài viết"); @@ -251,16 +251,17 @@ public async Task> Delete(string id, string userId) public async Task> DeleteAdmin(string id) { - var post = await _dataContext.Posts.FirstOrDefaultAsync(x => x.Id.Equals(id)); + var post = await _dataContext.Posts.FirstOrDefaultAsync(x => x.Id.Equals(id) && !x.IsDeleted); if (post is null) { return new ApiErrorResult("Không tìm thấy bài viết"); } - if (post.Image != string.Empty) - { - await _storageService.DeleteFileAsync(post.Image); - } - _dataContext.Posts.Remove(post); + //if (post.Image != string.Empty) + //{ + // await _storageService.DeleteFileAsync(post.Image); + //} + post.IsDeleted = true; + _dataContext.Posts.Update(post); await _dataContext.SaveChangesAsync(); @@ -269,7 +270,7 @@ public async Task> DeleteAdmin(string id) public async Task> AddOrUnLikePost(PostFpkDto postFpk) { - var post = await _dataContext.Posts.FirstOrDefaultAsync(x => x.SubId.Equals(postFpk.PostId)); + var post = await _dataContext.Posts.FirstOrDefaultAsync(x => x.SubId.Equals(postFpk.PostId) && !x.IsDeleted); if (post is null) { return new ApiErrorResult("Không tìm thấy bài viết"); @@ -300,7 +301,7 @@ public async Task> AddOrUnLikePost(PostFpkDto postFpk) public async Task> AddOrRemoveSavePost(PostFpkDto postFpk) { - var post = await _dataContext.Posts.FirstOrDefaultAsync(x => x.SubId.Equals(postFpk.PostId)); + var post = await _dataContext.Posts.FirstOrDefaultAsync(x => x.SubId.Equals(postFpk.PostId) && !x.IsDeleted); if (post is null) { return new ApiErrorResult("Không tìm thấy bài viết"); @@ -331,7 +332,7 @@ public async Task> AddOrRemoveSavePost(PostFpkDto postF public async Task> ReportPost(ReportPostDto reportPostDto) { - var post = _dataContext.Posts.FirstOrDefault(x => x.SubId.Equals(reportPostDto.PostId)); + var post = _dataContext.Posts.FirstOrDefault(x => x.SubId.Equals(reportPostDto.PostId) && !x.IsDeleted); if (post == null) { return new ApiErrorResult("Bài viết không tồn tại"); @@ -360,7 +361,7 @@ public async Task>> GetReport() public async Task> GetLike(PostFpkDto postFpk) { - var post = _dataContext.Posts.First(x => x.SubId.Equals(postFpk.PostId)); + var post = _dataContext.Posts.First(x => x.SubId.Equals(postFpk.PostId) && !x.IsDeleted); var check = await _dataContext.PostLikes.Where(x => x.PostId.Equals(post.Id) && x.UserId == Guid.Parse(postFpk.UserId)).FirstOrDefaultAsync(); var number = await _dataContext.PostLikes.Where(x => x.PostId.Equals(post.Id)).CountAsync(); return new ApiSuccessResult(new() { Check = (check != null), Quantity = number}); @@ -368,7 +369,7 @@ public async Task> GetLike(PostFpkDto postFpk) public async Task> GetSave(PostFpkDto postFpk) { - var post = _dataContext.Posts.First(x => x.SubId.Equals(postFpk.PostId)); + var post = _dataContext.Posts.First(x => x.SubId.Equals(postFpk.PostId) && !x.IsDeleted); var check = await _dataContext.PostSaves.Where(x => x.PostId.Equals(post.Id) && x.UserId == Guid.Parse(postFpk.UserId)).FirstOrDefaultAsync(); var number = await _dataContext.PostSaves.Where(x => x.PostId.Equals(post.Id)).CountAsync(); return new ApiSuccessResult(new() { Check = (check != null), Quantity = number }); @@ -386,7 +387,7 @@ public async Task>> GetPostByTag(string tag) { return new ApiSuccessResult>(new List()); } - var users = await _dataContext.User.ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); var result = new List(); foreach (var item in posts) @@ -410,12 +411,12 @@ public async Task>> GetPostByTag(string tag) public async Task>> GetComment(string postId) { - var post = await _dataContext.Posts.FirstAsync(x => x.SubId.Equals(postId)); + var post = await _dataContext.Posts.FirstAsync(x => x.SubId.Equals(postId) && !x.IsDeleted); if (post == null) { return new ApiSuccessResult>(); } - var users = await _dataContext.User.ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); var postComment = await _dataContext.PostComments.Where(x=>x.PostId.Equals(post.Id)).ToListAsync(); var postSubComment = await _dataContext.PostSubComments.ToListAsync(); @@ -449,7 +450,7 @@ public async Task>> GetComment(string postId) private UserShortDto? GetUserShort(List users, Guid? IdUser) { return users - .Where(x => x.Id.Equals(IdUser)) + .Where(x => x.Id.Equals(IdUser) && !x.IsDeleted) .Select(x => new UserShortDto { Id = x.Id, @@ -461,7 +462,7 @@ public async Task>> GetComment(string postId) public async Task>> CreateComment(CommentPostDto comment) { - var post = await _dataContext.Posts.FirstOrDefaultAsync(x=>x.SubId.Equals(comment.PostId)); + var post = await _dataContext.Posts.FirstOrDefaultAsync(x=>x.SubId.Equals(comment.PostId) && !x.IsDeleted); if (post == null) { return new ApiErrorResult>("Không tìm thấy bài đọc bạn bình luận, có thể nó đã bị xóa"); @@ -516,7 +517,7 @@ public async Task>> DeteleComment(string id) public async Task>> GetMyPostSaved(string id) { Guid userId = Guid.Parse(id); - var users = await _dataContext.User.ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); var posts = await ( from postSave in _dataContext.PostSaves @@ -542,7 +543,7 @@ select post } public async Task>> GetMyPost(string id) { - var posts = await _dataContext.Posts.Where(x=>x.UserId.Equals(Guid.Parse(id))).ToListAsync(); + var posts = await _dataContext.Posts.Where(x=>x.UserId.Equals(Guid.Parse(id)) && !x.IsDeleted).ToListAsync(); var result = new List(); foreach (var item in posts) { @@ -563,10 +564,10 @@ public async Task>> SearchPosts(string keyWord) keyWord = keyWord.TrimStart('#'); return await GetPostByTag(keyWord); } - var users = await _dataContext.User.ToListAsync(); + var users = await _dataContext.User.Where(x=> !x.IsDeleted).ToListAsync(); var posts = new List(); string[] searchKeywords = keyWord.ToLower().Split(' '); - var result = from post in _dataContext.Posts as IEnumerable + var result = from post in _dataContext.Posts.Where(x => !x.IsDeleted) as IEnumerable let titleWords = post.Title.ToLower().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries) let searchPhrases = HandleCommon.GenerateSearchPhrases(searchKeywords) let matchingPhrases = searchPhrases @@ -609,7 +610,7 @@ public async Task>> GetRandomPost(int quantity) DateTime currentDate = DateTime.Now; DateTime startDate = currentDate.AddDays(-30); var posts = await _dataContext.Posts - .Where(post => post.CreatedAt >= startDate && post.CreatedAt <= currentDate) + .Where(post => post.CreatedAt >= startDate && post.CreatedAt <= currentDate && !post.IsDeleted) .Take(100) .ToListAsync(); @@ -640,16 +641,16 @@ public async Task>> GetRandomPost(int quantity) public async Task>> FindByTopic(string topicName) { var posts = await _dataContext.Posts - .Where(post => _dataContext.TopicDetails + .Where(post => _dataContext.TopicDetails .Any(postTag => _dataContext.Topics .Any(tagEntity => tagEntity.Title.ToLower().Equals(topicName.ToLower()) && tagEntity.Id == postTag.TopicId) - && postTag.PostId == post.Id)) + && postTag.PostId == post.Id) && !post.IsDeleted) .ToListAsync(); if (posts.IsNullOrEmpty()) { return new ApiSuccessResult>(new List()); } - var users = await _dataContext.User.ToListAsync(); + var users = await _dataContext.User.Where(x => !x.IsDeleted).ToListAsync(); var result = new List(); foreach (var item in posts) diff --git a/VNH.Infrastructure/Implement/Catalog/Users/UserService.cs b/VNH.Infrastructure/Implement/Catalog/Users/UserService.cs index 6f731fc..d68479b 100644 --- a/VNH.Infrastructure/Implement/Catalog/Users/UserService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Users/UserService.cs @@ -12,6 +12,7 @@ using VNH.Application.Interfaces.Common; using Microsoft.AspNetCore.Http; using VNH.Infrastructure.Implement.Common; +using Microsoft.EntityFrameworkCore; namespace VNH.Infrastructure.Implement.Catalog.Users { @@ -70,13 +71,14 @@ public async Task> Update(UserUpdateDto request) public async Task> GetImage(string email) { - var user = await _userManager.FindByNameAsync(email); + var user = await _dataContext.User.FirstOrDefaultAsync(x=>x.Email.Equals(email)); + if(user is null) return new ApiSuccessResult(string.Empty); return new ApiSuccessResult(user.Image); } - public async Task> SetImageUser(string name, IFormFile image) + public async Task> SetImageUser(string email, IFormFile image) { - var user = await _userManager.FindByNameAsync(name); + var user = await _dataContext.User.FirstOrDefaultAsync(x => x.Email.Equals(email)); if (user.Image != string.Empty) { await _storageService.DeleteFileAsync(user.Image); diff --git a/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.Designer.cs b/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.Designer.cs new file mode 100644 index 0000000..7ffd12e --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.Designer.cs @@ -0,0 +1,1896 @@ +// +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 new file mode 100644 index 0000000..54c71b1 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231203134514_add_IsDeleted_Attr.cs @@ -0,0 +1,100 @@ +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 new file mode 100644 index 0000000..9ec75c6 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231204054827_add_qId_attr_AnswerVote.Designer.cs @@ -0,0 +1,1902 @@ +// +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 new file mode 100644 index 0000000..58712d6 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231204054827_add_qId_attr_AnswerVote.cs @@ -0,0 +1,31 @@ +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 new file mode 100644 index 0000000..dd684f1 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231205080409_remove_attr_news_table.Designer.cs @@ -0,0 +1,1897 @@ +// +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 new file mode 100644 index 0000000..6425b39 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231205080409_remove_attr_news_table.cs @@ -0,0 +1,71 @@ +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/VietNamHistoryContextModelSnapshot.cs b/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs index b410d69..86bc783 100644 --- a/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs +++ b/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs @@ -143,6 +143,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedAt") .HasColumnType("datetime"); + b.Property("IsDeleted") + .HasColumnType("bit"); + b.Property("MostConfirm") .HasColumnType("bit"); @@ -169,6 +172,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("AnswerId") .HasColumnType("uniqueidentifier"); + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + b.Property("UserId") .HasColumnType("uniqueidentifier"); @@ -201,6 +207,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Image") .HasColumnType("nvarchar(max)"); + b.Property("IsDeleted") + .HasColumnType("bit"); + b.Property("UpdatedAt") .HasColumnType("datetime"); @@ -332,6 +341,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("FileName") .HasColumnType("nvarchar(max)"); + b.Property("IsDeleted") + .HasColumnType("bit"); + b.Property("SubId") .HasColumnType("nvarchar(max)"); @@ -521,6 +533,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ExerciseId") .HasColumnType("uniqueidentifier"); + b.Property("IsDeleted") + .HasColumnType("bit"); + b.Property("Title") .HasMaxLength(500) .HasColumnType("nvarchar(500)"); @@ -542,9 +557,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Id") .HasColumnType("uniqueidentifier"); - b.Property("CreatedAt") - .HasColumnType("datetime"); - b.Property("Description") .HasColumnType("text"); @@ -553,14 +565,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Title") .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); + .HasColumnType("nvarchar(max)"); b.Property("Url") .IsRequired() - .HasMaxLength(255) .IsUnicode(false) - .HasColumnType("varchar(255)"); + .HasColumnType("varchar(max)"); b.HasKey("Id"); @@ -582,6 +592,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Image") .HasColumnType("nvarchar(max)"); + b.Property("IsDeleted") + .HasColumnType("bit"); + b.Property("SubId") .HasMaxLength(300) .HasColumnType("nvarchar(300)"); @@ -762,6 +775,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("CreatedAt") .HasColumnType("datetime"); + b.Property("IsDeleted") + .HasColumnType("bit"); + b.Property("SubId") .HasColumnType("nvarchar(max)"); @@ -935,49 +951,49 @@ protected override void BuildModel(ModelBuilder modelBuilder) new { Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1878), + 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, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1890), + 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, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1892), + 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, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1894), + 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, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1897), + 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, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1899), + 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, 11, 29, 23, 13, 41, 415, DateTimeKind.Local).AddTicks(1905), + 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" }); @@ -1006,21 +1022,21 @@ protected override void BuildModel(ModelBuilder modelBuilder) new { Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "c998aba1-7d62-483a-a82c-dffca027ed0e", + ConcurrencyStamp = "3182dd22-7192-40cc-bf32-ae0bb5363bba", Name = "admin", NormalizedName = "admin" }, new { Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "ae9a8b2b-7978-448e-a405-c884869f328d", + ConcurrencyStamp = "2a155be9-196e-48ad-95a4-28f7eee91b69", Name = "teacher", NormalizedName = "teacher" }, new { Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "ed14ffc7-e2d5-4165-a466-43faa539db13", + ConcurrencyStamp = "7f5fc9f5-7422-4f96-8126-3a42fd7ff282", Name = "student", NormalizedName = "student" }); @@ -1167,6 +1183,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Introduction") .HasColumnType("nvarchar(max)"); + b.Property("IsDeleted") + .HasColumnType("bit"); + b.Property("LockoutEnabled") .HasColumnType("bit"); @@ -1209,17 +1228,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) { Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), AccessFailedCount = 0, - ConcurrencyStamp = "4e2eef99-65a4-4b8a-a919-145ed60b15a2", + 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 = "AQAAAAEAACcQAAAAEAL81EjrI0KYNGldHCVGr6VWAAG6C3NTtw/mpPYP8v1ClFiJBnsTwh8zzWucfocLyQ==", + PasswordHash = "AQAAAAEAACcQAAAAENntF+L92TVYiUupnD7s15ka9Nrde4KrOfDTQcYRgC+/SRv5zyA12ZH1deKOvdEbtA==", PhoneNumberConfirmed = false, SecurityStamp = "", TwoFactorEnabled = false, diff --git a/VNH.Infrastructure/Presenters/ChatSignalR.cs b/VNH.Infrastructure/Presenters/ChatSignalR.cs index a12adf4..7024b57 100644 --- a/VNH.Infrastructure/Presenters/ChatSignalR.cs +++ b/VNH.Infrastructure/Presenters/ChatSignalR.cs @@ -8,14 +8,20 @@ public class ChatSignalR : Hub { public async Task SendComment(CommentPostDto comment) { - // Broadcast the comment to all connected clients + // Broadcast the subAnswer to all connected clients await Clients.All.SendAsync("ReceiveComment", comment); } public async Task SendAnswer(AnswerQuestionDto comment) { - await Clients.All.SendAsync("ReceiveAnswer", comment); } + + //public async Task SendSubAnswer(List subAnswer) + //{ + // await Clients.All.SendAsync("ReceiveSubAnswer", subAnswer); + //} + + } } diff --git a/VNH.Infrastructure/VNH.Infrastructure.csproj b/VNH.Infrastructure/VNH.Infrastructure.csproj index 7e052ea..24a64b5 100644 --- a/VNH.Infrastructure/VNH.Infrastructure.csproj +++ b/VNH.Infrastructure/VNH.Infrastructure.csproj @@ -8,6 +8,7 @@ + diff --git a/VNH.WebAPi/Controllers/AnswerController.cs b/VNH.WebAPi/Controllers/AnswerController.cs index cb4e05e..4ccb93d 100644 --- a/VNH.WebAPi/Controllers/AnswerController.cs +++ b/VNH.WebAPi/Controllers/AnswerController.cs @@ -97,14 +97,26 @@ public async Task DeleteSubAnswer(string idSubAnswer) return result is null ? BadRequest(result) : Ok(result); } + [HttpPost("Confirm")] + [Authorize] + public async Task ConfirmAnswer(AnswerFpkDto answer) + { + var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; + if(id == answer.QuestionUserId) + { + var result = await _answerService.ConfirmedByQuestioner(answer.AnswerId); + return Ok(result); + } + return Ok(); + + } [HttpPost("Vote")] [Authorize] - public async Task Vote([FromForm] AnswerFpkDto answerFpk) + public async Task Vote(AnswerFpkDto answer) { - var result = await _answerService.ConfirmOrNoConfirm(answerFpk); - return result is null ? BadRequest(result) : Ok(result); + var result = await _answerService.VoteConfirmByUser(answer); + return Ok(result); } - } } diff --git a/VNH.WebAPi/Controllers/NewsController.cs b/VNH.WebAPi/Controllers/NewsController.cs new file mode 100644 index 0000000..b25de30 --- /dev/null +++ b/VNH.WebAPi/Controllers/NewsController.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Mvc; +using VNH.Application.Interfaces.Catalog.NewsHistory; +using VNH.Domain; + +namespace VNH.WebAPi.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class NewsController : ControllerBase + { + private readonly INewsService _newsService; + NewsController(INewsService newsService) { + _newsService = newsService; + } + + [HttpGet] + public async Task GetNews() + { + string url = "https://danviet.vn/lich-su-viet-nam.html"; + List newsList = await _newsService.GetNews(url); + return Ok(newsList); + } + + } +} diff --git a/VNH.WebAPi/wwwroot/Images/2ef22127-d152-4a81-a543-5c84b0086487.jpg b/VNH.WebAPi/wwwroot/Images/2ef22127-d152-4a81-a543-5c84b0086487.jpg new file mode 100644 index 0000000..2a93a02 Binary files /dev/null and b/VNH.WebAPi/wwwroot/Images/2ef22127-d152-4a81-a543-5c84b0086487.jpg differ