From dea306e47eebe8a4acb53e18173275e2e5e755f6 Mon Sep 17 00:00:00 2001 From: vuanh25 Date: Tue, 21 Nov 2023 15:53:27 +0700 Subject: [PATCH 1/2] Create Question, Answer for Question --- .../DTOs/Catalog/Posts/QuestionResponseDto.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 VNH.Application/DTOs/Catalog/Posts/QuestionResponseDto.cs diff --git a/VNH.Application/DTOs/Catalog/Posts/QuestionResponseDto.cs b/VNH.Application/DTOs/Catalog/Posts/QuestionResponseDto.cs new file mode 100644 index 0000000..3e65a4d --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Posts/QuestionResponseDto.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.EntityFrameworkCore.Metadata.Internal; +using System.ComponentModel.DataAnnotations.Schema; +using VNH.Application.DTOs.Catalog.HashTags; +using VNH.Application.DTOs.Catalog.Users; +using VNH.Domain; + +namespace VNH.Application.DTOs.Catalog.Posts +{ + public class QuestionResponseDto + { + public string Id { get; set; } = string.Empty; + public string SubId { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public string Image { get; set; } = string.Empty; + public DateTime? CreatedAt { get; set; } + public DateTime? UpdatedAt { get; set; } + public string TopicName { get; set; } = string.Empty; + public List Tags { get; set; } = new List(); + public UserShortDto UserShort { get; set; } = new UserShortDto(); + public int ViewNumber { get; set; } = 0; + public int CommentNumber { get; set; } = 0; + public int LikeNumber { get; set; } = 0; + public int SaveNumber { get; set; } = 0; + } +} \ No newline at end of file From 1d6d24c05317eca5f8bb96c89d2bfbedb53687f1 Mon Sep 17 00:00:00 2001 From: vuanh25 Date: Tue, 21 Nov 2023 15:54:58 +0700 Subject: [PATCH 2/2] Create Question,Answer for question --- .../DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs | 14 + .../Catalog/Forum/Answer/AnswerQuestionDto.cs | 44 + .../Catalog/Forum/Answer/AnswerResponseDto.cs | 40 + .../Catalog/Forum/Answer/CreateAnswerDto.cs | 30 + .../Forum/Question/CreateQuestionDto.cs | 18 + .../Catalog/Forum/Question/QuestionFpkDto.cs | 14 + .../Forum/Question/QuestionResponseDto.cs | 21 + .../DTOs/Catalog/Posts/CreatePostDto.cs | 3 +- .../DTOs/Catalog/Posts/QuestionResponseDto.cs | 27 - .../Catalog/Forum/IAnswerService.cs | 25 + .../Catalog/Forum/IQuestionService.cs | 27 + VNH.Application/Mappers/AnswerMapper.cs | 23 + VNH.Application/Mappers/QuestionMapper.cs | 21 + VNH.Domain/Entities/Answer.cs | 3 + VNH.Domain/Entities/Question.cs | 11 +- VNH.Domain/Entities/QuestionTag.cs | 6 +- VNH.Domain/Entities/SubAnswer.cs | 3 + .../DependencyInjectionInfrastructure.cs | 4 + .../Implement/Catalog/Forum/AnswerService.cs | 237 +++ .../Catalog/Forum/QuestionService.cs | 338 +++ .../Implement/Catalog/Posts/PostService.cs | 2 +- ...20064521_update question table.Designer.cs | 1867 ++++++++++++++++ .../20231120064521_update question table.cs | 42 + ...75940_update questiontag table.Designer.cs | 1867 ++++++++++++++++ ...20231120075940_update questiontag table.cs | 41 + ...158_update questiontag table 2.Designer.cs | 1868 ++++++++++++++++ ...231120083158_update questiontag table 2.cs | 52 + ...lumn UpdateAt for table Answer.Designer.cs | 1871 ++++++++++++++++ ...23_add column UpdateAt for table Answer.cs | 30 + ...n UpdateAt for table SubAnswer.Designer.cs | 1874 +++++++++++++++++ ...add column UpdateAt for table SubAnswer.cs | 31 + .../VietNamHistoryContextModelSnapshot.cs | 54 +- VNH.Infrastructure/Presenters/ChatSignalR.cs | 7 + .../DbContext/VietNamHistoryContext.cs | 7 +- VNH.WebAPi/Controllers/AnswerController.cs | 110 + VNH.WebAPi/Controllers/DocumentController.cs | 2 +- VNH.WebAPi/Controllers/QuestionController.cs | 103 + 37 files changed, 10674 insertions(+), 63 deletions(-) create mode 100644 VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs create mode 100644 VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs create mode 100644 VNH.Application/DTOs/Catalog/Forum/Answer/AnswerResponseDto.cs create mode 100644 VNH.Application/DTOs/Catalog/Forum/Answer/CreateAnswerDto.cs create mode 100644 VNH.Application/DTOs/Catalog/Forum/Question/CreateQuestionDto.cs create mode 100644 VNH.Application/DTOs/Catalog/Forum/Question/QuestionFpkDto.cs create mode 100644 VNH.Application/DTOs/Catalog/Forum/Question/QuestionResponseDto.cs delete mode 100644 VNH.Application/DTOs/Catalog/Posts/QuestionResponseDto.cs create mode 100644 VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs create mode 100644 VNH.Application/Interfaces/Catalog/Forum/IQuestionService.cs create mode 100644 VNH.Application/Mappers/AnswerMapper.cs create mode 100644 VNH.Application/Mappers/QuestionMapper.cs create mode 100644 VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs create mode 100644 VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs create mode 100644 VNH.Infrastructure/Migrations/20231120064521_update question table.Designer.cs create mode 100644 VNH.Infrastructure/Migrations/20231120064521_update question table.cs create mode 100644 VNH.Infrastructure/Migrations/20231120075940_update questiontag table.Designer.cs create mode 100644 VNH.Infrastructure/Migrations/20231120075940_update questiontag table.cs create mode 100644 VNH.Infrastructure/Migrations/20231120083158_update questiontag table 2.Designer.cs create mode 100644 VNH.Infrastructure/Migrations/20231120083158_update questiontag table 2.cs create mode 100644 VNH.Infrastructure/Migrations/20231121014823_add column UpdateAt for table Answer.Designer.cs create mode 100644 VNH.Infrastructure/Migrations/20231121014823_add column UpdateAt for table Answer.cs create mode 100644 VNH.Infrastructure/Migrations/20231121030333_add column UpdateAt for table SubAnswer.Designer.cs create mode 100644 VNH.Infrastructure/Migrations/20231121030333_add column UpdateAt for table SubAnswer.cs create mode 100644 VNH.WebAPi/Controllers/AnswerController.cs create mode 100644 VNH.WebAPi/Controllers/QuestionController.cs diff --git a/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs new file mode 100644 index 0000000..f42fc12 --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VNH.Application.DTOs.Catalog.Forum.Answer +{ + public class AnswerFpkDto + { + public string AnswerId { get; set; } = string.Empty; + public string UserId { get; set; } = string.Empty; + } +} diff --git a/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs new file mode 100644 index 0000000..55e2af0 --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerQuestionDto.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.DTOs.Catalog.Users; + +namespace VNH.Application.DTOs.Catalog.Forum.Answer +{ + 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 PubDate { get; set; } + public DateTime? UpdateAt { get; set; } + public bool Confirm { get; set; } = false; + public bool MostConfirm { get; set; } = false; + public List? SubAnswer { get; set; } + + } + + public class SubAnswerQuestionDto + { + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid PreAnswerId { get; set; } + public Guid AuthorId { get; set; } + public string Content { get; set; } = string.Empty; + [Column(TypeName = "datetime")] + public DateTime? PubDate { get; set; } + [Column(TypeName = "datetime")] + public DateTime? UpdateAt { get; set; } + + public UserShortDto? UserShort { get; set; } + + + } + +} diff --git a/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerResponseDto.cs b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerResponseDto.cs new file mode 100644 index 0000000..d1e05b7 --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Forum/Answer/AnswerResponseDto.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.DTOs.Catalog.Users; + +namespace VNH.Application.DTOs.Catalog.Forum.Answer +{ + public class AnswerResponseDto + { + + public string Id { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + + public string QuestionId { get; set; } = string.Empty; + + [Column(TypeName = "datetime")] + public DateTime? PubDate { get; set; } + public UserShortDto UserShort { get; set; } = new UserShortDto(); + public bool Confirm { get; set; } + public bool MostConfirm { get; set; } + public List? SubAnserwer { get; set; } + + } + + public class SubAnswerResponseDto + { + public Guid Id { get; set; } + public Guid PreAnswerId { get; set; } + public string Content { get; set; } = string.Empty; + [Column(TypeName = "datetime")] + public DateTime? PubDate { get; set; } + + public UserShortDto? UserShort { get; set; } + + } + +} diff --git a/VNH.Application/DTOs/Catalog/Forum/Answer/CreateAnswerDto.cs b/VNH.Application/DTOs/Catalog/Forum/Answer/CreateAnswerDto.cs new file mode 100644 index 0000000..9212d5a --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Forum/Answer/CreateAnswerDto.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.DTOs.Catalog.Users; + +namespace VNH.Application.DTOs.Catalog.Forum.Answer +{ + public class CreateAnswerDto + { + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid? AuthorId { get; set; } + public string QuestionId { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + + } + + public class SubAnswerDto + { + public Guid Id { get; set; } = Guid.NewGuid(); + public Guid PreAnswerId { get; set; } + + public string Content { get; set; } = string.Empty; + + public Guid AuthorId { get; set; } + + + } +} diff --git a/VNH.Application/DTOs/Catalog/Forum/Question/CreateQuestionDto.cs b/VNH.Application/DTOs/Catalog/Forum/Question/CreateQuestionDto.cs new file mode 100644 index 0000000..dd8ed45 --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Forum/Question/CreateQuestionDto.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VNH.Application.DTOs.Catalog.Forum.Question +{ + public class CreateQuestionDto + { + public Guid? Id { get; set; } = Guid.NewGuid(); + + public string? Title { get; set; } = string.Empty; + public string? Content { get; set; } = string.Empty; + public List? Tag { get; set; } + + } +} diff --git a/VNH.Application/DTOs/Catalog/Forum/Question/QuestionFpkDto.cs b/VNH.Application/DTOs/Catalog/Forum/Question/QuestionFpkDto.cs new file mode 100644 index 0000000..8c28c79 --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Forum/Question/QuestionFpkDto.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VNH.Application.DTOs.Catalog.Forum.Question +{ + public class QuestionFpkDto + { + public string QuestionId { get; set; } = string.Empty; + public string UserId { get; set; } = string.Empty; + } +} diff --git a/VNH.Application/DTOs/Catalog/Forum/Question/QuestionResponseDto.cs b/VNH.Application/DTOs/Catalog/Forum/Question/QuestionResponseDto.cs new file mode 100644 index 0000000..f64f0a4 --- /dev/null +++ b/VNH.Application/DTOs/Catalog/Forum/Question/QuestionResponseDto.cs @@ -0,0 +1,21 @@ + +using VNH.Application.DTOs.Catalog.HashTags; +using VNH.Application.DTOs.Catalog.Users; + +namespace VNH.Application.DTOs.Catalog.Forum.Question +{ + public class QuestionResponseDto + { + public string Id { get; set; } =string.Empty; + public string Title { get; set; } = string.Empty; + public string Content { get; set; } = string.Empty; + public DateTime? CreateAt { get; set; } + public DateTime? UpdateAt { get; set; } + public List Tags { get; set; } = new List(); + public UserShortDto UserShort { get; set; } = new UserShortDto(); + public int ViewNumber { get; set; } = 0; + public int CommentNumber { get; set; } = 0; + public int SaveNumber { get; set; } = 0; + + } +} diff --git a/VNH.Application/DTOs/Catalog/Posts/CreatePostDto.cs b/VNH.Application/DTOs/Catalog/Posts/CreatePostDto.cs index 477efee..2f56b4d 100644 --- a/VNH.Application/DTOs/Catalog/Posts/CreatePostDto.cs +++ b/VNH.Application/DTOs/Catalog/Posts/CreatePostDto.cs @@ -8,9 +8,8 @@ public class CreatePostDto public string? Id { get; set; } = Guid.NewGuid().ToString(); public string Title { get; set; } = string.Empty; public string Content { get; set; } = string.Empty; - public IFormFile? Image { get; set; } + public IFormFile? Image { get; set; } public Guid TopicId { get; set; } public List? Tag { get; set; } } } - \ No newline at end of file diff --git a/VNH.Application/DTOs/Catalog/Posts/QuestionResponseDto.cs b/VNH.Application/DTOs/Catalog/Posts/QuestionResponseDto.cs deleted file mode 100644 index 3e65a4d..0000000 --- a/VNH.Application/DTOs/Catalog/Posts/QuestionResponseDto.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.EntityFrameworkCore.Metadata.Internal; -using System.ComponentModel.DataAnnotations.Schema; -using VNH.Application.DTOs.Catalog.HashTags; -using VNH.Application.DTOs.Catalog.Users; -using VNH.Domain; - -namespace VNH.Application.DTOs.Catalog.Posts -{ - public class QuestionResponseDto - { - public string Id { get; set; } = string.Empty; - public string SubId { get; set; } = string.Empty; - public string Title { get; set; } = string.Empty; - public string Content { get; set; } = string.Empty; - public string Image { get; set; } = string.Empty; - public DateTime? CreatedAt { get; set; } - public DateTime? UpdatedAt { get; set; } - public string TopicName { get; set; } = string.Empty; - public List Tags { get; set; } = new List(); - public UserShortDto UserShort { get; set; } = new UserShortDto(); - public int ViewNumber { get; set; } = 0; - public int CommentNumber { get; set; } = 0; - public int LikeNumber { get; set; } = 0; - public int SaveNumber { get; set; } = 0; - } -} \ No newline at end of file diff --git a/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs b/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs new file mode 100644 index 0000000..ebc64f9 --- /dev/null +++ b/VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs @@ -0,0 +1,25 @@ +using VNH.Application.DTOs.Catalog.Forum.Answer; +using VNH.Application.DTOs.Common.ResponseNotification; +using VNH.Domain; + +namespace VNH.Application.Interfaces.Catalog.Forum +{ + public interface IAnswerService + { + + Task>> GetAnswer(string questionId); + Task>> CreateAnswer(AnswerQuestionDto answer); + Task>> UpdateAnswer(AnswerQuestionDto answer); + Task> DeteleAnswer(string id); + + + Task> CreateSubAnswer(SubAnswerQuestionDto subAnswer); + + Task> UpdateSubAnswer(SubAnswerQuestionDto answer); + Task> DeteleSubAnswer(string id); + + Task> ConfirmOrNoConfirm(AnswerFpkDto answerFpk); + + + } +} diff --git a/VNH.Application/Interfaces/Catalog/Forum/IQuestionService.cs b/VNH.Application/Interfaces/Catalog/Forum/IQuestionService.cs new file mode 100644 index 0000000..4c79bfb --- /dev/null +++ b/VNH.Application/Interfaces/Catalog/Forum/IQuestionService.cs @@ -0,0 +1,27 @@ + + +using VNH.Application.DTOs.Catalog.Forum.Question; +using VNH.Application.DTOs.Catalog.HashTags; +using VNH.Application.DTOs.Catalog.Posts; +using VNH.Application.DTOs.Common.ResponseNotification; + +namespace VNH.Application.Interfaces.Catalog.Forum +{ + public interface IQuestionService + { + Task> Create(CreateQuestionDto requestDto, string name); + Task> Update(CreateQuestionDto requestDto, string name); + + Task> Detail(string Id); + Task>> GetAll(); + Task> Delete(string id, string email); + Task> AddOrRemoveSaveQuestion(QuestionFpkDto questionFpk); + + Task> GetSave(QuestionFpkDto questionFpk); + + Task>> GetAllTag(int numberTag); + Task>> GetQuestionByTag(string tag); + + + } +} diff --git a/VNH.Application/Mappers/AnswerMapper.cs b/VNH.Application/Mappers/AnswerMapper.cs new file mode 100644 index 0000000..8d51120 --- /dev/null +++ b/VNH.Application/Mappers/AnswerMapper.cs @@ -0,0 +1,23 @@ +using AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.DTOs.Catalog.Forum.Answer; +using VNH.Domain; + +namespace VNH.Application.Mappers +{ + public class AnswerMapper : Profile + { + + public AnswerMapper() { + CreateMap().ReverseMap(); + + CreateMap().ReverseMap(); + + + } + } +} diff --git a/VNH.Application/Mappers/QuestionMapper.cs b/VNH.Application/Mappers/QuestionMapper.cs new file mode 100644 index 0000000..ede9432 --- /dev/null +++ b/VNH.Application/Mappers/QuestionMapper.cs @@ -0,0 +1,21 @@ +using AutoMapper; + +using VNH.Application.DTOs.Catalog.Forum.Question; +using VNH.Domain; + +namespace VNH.Application.Mappers +{ + public class QuestionMapper : Profile + + { + public QuestionMapper() + { + + CreateMap().ReverseMap(); + + CreateMap().ReverseMap(); + + + } + } +} diff --git a/VNH.Domain/Entities/Answer.cs b/VNH.Domain/Entities/Answer.cs index fb21464..5d01931 100644 --- a/VNH.Domain/Entities/Answer.cs +++ b/VNH.Domain/Entities/Answer.cs @@ -24,6 +24,9 @@ public Answer() public Guid? AuthorId { get; set; } [Column(TypeName = "datetime")] public DateTime? PubDate { get; set; } + + [Column(TypeName = "datetime")] + public DateTime? UpdateAt { get; set; } public bool? Confirm { get; set; } public bool? MostConfirm { get; set; } diff --git a/VNH.Domain/Entities/Question.cs b/VNH.Domain/Entities/Question.cs index 44ac3d5..20e24c6 100644 --- a/VNH.Domain/Entities/Question.cs +++ b/VNH.Domain/Entities/Question.cs @@ -26,14 +26,17 @@ public Question() public int? ViewNumber { get; set; } public Guid? AuthorId { get; set; } [Column(TypeName = "datetime")] - public DateTime? PubDate { get; set; } - public Guid? QuestionTagId { get; set; } + public DateTime? UpdateAt { get; set; } + + [Column(TypeName = "datetime")] + public DateTime CreateAt { get; set; } + [ForeignKey("AuthorId")] [InverseProperty("Questions")] public virtual User Author { get; set; } - [InverseProperty("IdNavigation")] - public virtual QuestionTag QuestionTag { get; set; } + [InverseProperty("Question")] + public virtual ICollection QuestionTag { get; set; } [InverseProperty("Question")] public virtual ICollection QuestionLikes { get; set; } [InverseProperty("Question")] diff --git a/VNH.Domain/Entities/QuestionTag.cs b/VNH.Domain/Entities/QuestionTag.cs index b9a03f3..45a1bc7 100644 --- a/VNH.Domain/Entities/QuestionTag.cs +++ b/VNH.Domain/Entities/QuestionTag.cs @@ -15,9 +15,11 @@ public partial class QuestionTag public Guid Id { get; set; } public Guid? TagId { get; set; } - [ForeignKey("Id")] + public Guid? QuestionId { get; set; } + + [ForeignKey("QuestionId")] [InverseProperty("QuestionTag")] - public virtual Question IdNavigation { get; set; } + public virtual Question Question { get; set; } [ForeignKey("TagId")] [InverseProperty("QuestionTags")] public virtual Tag Tag { get; set; } diff --git a/VNH.Domain/Entities/SubAnswer.cs b/VNH.Domain/Entities/SubAnswer.cs index cc572d6..8ee6eb8 100644 --- a/VNH.Domain/Entities/SubAnswer.cs +++ b/VNH.Domain/Entities/SubAnswer.cs @@ -19,6 +19,9 @@ public partial class SubAnswer [Column(TypeName = "datetime")] public DateTime? PubDate { get; set; } + [Column(TypeName = "datetime")] + public DateTime? UpdateAt { get; set; } + [ForeignKey("AuthorId")] [InverseProperty("SubAnswers")] public virtual User Author { get; set; } diff --git a/VNH.Infrastructure/DependencyInjectionInfrastructure.cs b/VNH.Infrastructure/DependencyInjectionInfrastructure.cs index 4840d2d..36802bd 100644 --- a/VNH.Infrastructure/DependencyInjectionInfrastructure.cs +++ b/VNH.Infrastructure/DependencyInjectionInfrastructure.cs @@ -30,6 +30,8 @@ using VNH.Infrastructure.Implement.Catalog.Reports; using VNH.Application.Interfaces.Documents; using VNH.Infrastructure.Implement.Catalog.Documents; +using VNH.Application.Interfaces.Catalog.Forum; +using VNH.Infrastructure.Implement.Catalog.Forum; namespace VNH.Infrastructure { @@ -131,6 +133,8 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi services.AddScoped(); services.AddScoped(); services.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddSignalR(); diff --git a/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs b/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs new file mode 100644 index 0000000..a47899f --- /dev/null +++ b/VNH.Infrastructure/Implement/Catalog/Forum/AnswerService.cs @@ -0,0 +1,237 @@ +using AutoMapper; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.SignalR; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VNH.Application.DTOs.Catalog.Forum.Answer; +using VNH.Application.DTOs.Catalog.Forum.Question; +using VNH.Application.DTOs.Catalog.HashTags; +using VNH.Application.DTOs.Catalog.Posts; +using VNH.Application.DTOs.Catalog.Users; +using VNH.Application.DTOs.Common.ResponseNotification; +using VNH.Application.Interfaces.Catalog.Forum; +using VNH.Domain; +using VNH.Infrastructure.Presenters; +using VNH.Infrastructure.Presenters.Migrations; + +namespace VNH.Infrastructure.Implement.Catalog.Forum +{ + public class AnswerService : IAnswerService + { + private readonly UserManager _userManager; + private readonly VietNamHistoryContext _dataContext; + private readonly IHubContext _answerHubContext; + private readonly IMapper _mapper; + + + public AnswerService(UserManager userManager, IHubContext answerHubContext, + IMapper mapper, + VietNamHistoryContext vietNamHistoryContext) + { + _userManager = userManager; + _dataContext = vietNamHistoryContext; + _mapper = mapper; + _answerHubContext = answerHubContext; + } + + private UserShortDto? GetUserShort(List users, Guid? IdUser) + { + return users + .Where(x => x.Id.Equals(IdUser)) + .Select(x => new UserShortDto + { + Id = x.Id, + FullName = x.Fullname, + Image = x.Image + }) + .FirstOrDefault(); + } + + private List? GetSubAnswer(List subAnswer, List users) + { + List result = new(); + foreach (var item in subAnswer) + { + var answer = _mapper.Map(item); + answer.UserShort = GetUserShort(users, item.AuthorId); + result.Add(answer); + } + return result; + } + + public async Task>> GetAnswer(string questionId) + { + var question = await _dataContext.Questions.FirstAsync(x => x.Id.Equals(Guid.Parse(questionId))); + if (question == null) + { + return new ApiSuccessResult>(); + } + + var users = await _dataContext.User.ToListAsync(); + var answerQuestion = await _dataContext.Answers.Where(x => x.QuestionId.Equals(question.Id)).ToListAsync(); + var subAnswerQuestion = await _dataContext.SubAnswers.ToListAsync(); + var result = new List(); + foreach(var item in answerQuestion) + { + var subAnswer = subAnswerQuestion.Where(x => x.PreAnswerId.Equals(item.Id)).ToList(); + var answ = _mapper.Map(item); + answ.UserShort = GetUserShort(users, item.AuthorId); + if(subAnswer.Count > 0) + { + answ.SubAnswer = GetSubAnswer(subAnswer, users); + } + result.Add(answ); + } + return new ApiSuccessResult>(result); + } + + + + + public async Task>> CreateAnswer(AnswerQuestionDto answer) + { + var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(answer.QuestionId))); + 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"); + } + + Answer answerQuestion = _mapper.Map(answer); + answerQuestion.QuestionId = question.Id; + _dataContext.Answers.Add(answerQuestion); + await _dataContext.SaveChangesAsync(); + + var answers = await GetAnswer(answer.QuestionId); + await _answerHubContext.Clients.All.SendAsync("ReceiveAnswer", answers); + + return answers; + + } + + + public async Task>> UpdateAnswer(AnswerQuestionDto answer) + { + var questionAnswer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id == answer.Id); + if (questionAnswer == null) + { + return new ApiErrorResult>("Không tìm thấy câu hỏi bạn trả lời!"); + } + questionAnswer.Content = answer.Content; + questionAnswer.UpdateAt = DateTime.Now; + + _dataContext.Answers.Update(questionAnswer); + await _dataContext.SaveChangesAsync(); + + var answers = await GetAnswer(answer.QuestionId); + await _answerHubContext.Clients.All.SendAsync("ReceiveAnswer", answers); + + return answers; + } + + + public async Task> DeteleAnswer(string id) + { + var answer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id))); + if (answer == null) + { + return new ApiErrorResult("Không tìm thấy câu hỏi"); + } + _dataContext.Answers.Remove(answer); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(); + } + + + public async Task> CreateSubAnswer(SubAnswerQuestionDto subAnswer) + { + var answer = await _dataContext.Answers.FirstOrDefaultAsync(x => x.Id.Equals(subAnswer.PreAnswerId)); + 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; + _dataContext.SubAnswers.Add(sub); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult("Trả lời thành công"); + + } + + + public async Task> UpdateSubAnswer(SubAnswerQuestionDto subAnswer) + { + + var user = await _userManager.FindByIdAsync(subAnswer.AuthorId.ToString()); + var subAns = await _dataContext.SubAnswers.FirstOrDefaultAsync(x => x.Id == subAnswer.Id); + if (subAns == null) + { + return new ApiErrorResult("Không tìm thấy câu trả lời!"); + } + subAns.Content = subAnswer.Content; + subAns.UpdateAt = DateTime.Now; + + _dataContext.SubAnswers.Update(subAns); + await _dataContext.SaveChangesAsync(); + + + var subAnsResponse = _mapper.Map(subAns); + var useDto = new UserShortDto() + { + FullName = user.Fullname, + Id = user.Id, + Image = user.Image + }; + subAnsResponse.UserShort = useDto; + + return new ApiSuccessResult(subAnsResponse); + } + + public async Task> DeteleSubAnswer(string id) + { + var subAnswer = await _dataContext.SubAnswers.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id))); + if (subAnswer == null) + { + return new ApiErrorResult("Không tìm thấy câu trả lời"); + } + _dataContext.SubAnswers.Remove(subAnswer); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(); + } + + + public async Task> ConfirmOrNoConfirm(AnswerFpkDto answerFpk) + { + var answer = await _dataContext.Answers.FirstOrDefaultAsync(x=> x.Id.Equals(Guid.Parse(answerFpk.AnswerId))); + if(answer == null) + { + return new ApiErrorResult("Không tìm thấy câu trả lời"); + } + 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) + { + var vote = new AnswerVote() + { + Id = Guid.NewGuid(), + AnswerId = answer.Id, + UserId = Guid.Parse(answerFpk.UserId), + }; + _dataContext.AnswerVotes.Add(vote); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(voteNumber + 1); + } + else + { + _dataContext.AnswerVotes.Remove(check); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(voteNumber - 1); + } + } + } +} + diff --git a/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs b/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs new file mode 100644 index 0000000..6e644fc --- /dev/null +++ b/VNH.Infrastructure/Implement/Catalog/Forum/QuestionService.cs @@ -0,0 +1,338 @@ +using AutoMapper; +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Hosting; +using Microsoft.IdentityModel.Tokens; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Metadata; +using System.Text; +using VNH.Application.DTOs.Catalog.Forum.Question; +using VNH.Application.DTOs.Catalog.HashTags; +using VNH.Application.DTOs.Catalog.Posts; +using VNH.Application.DTOs.Catalog.Users; +using VNH.Application.DTOs.Common.ResponseNotification; +using VNH.Application.Interfaces.Catalog.Forum; +using VNH.Application.Interfaces.Common; +using VNH.Domain; +using VNH.Domain.Entities; +using VNH.Infrastructure.Implement.Common; +using VNH.Infrastructure.Presenters.Migrations; + +namespace VNH.Infrastructure.Implement.Catalog.Forum +{ + public class QuestionService : IQuestionService + { + + private readonly UserManager _userManager; + private readonly VietNamHistoryContext _dataContext; + private readonly IMapper _mapper; + + public QuestionService(UserManager userManager, + IMapper mapper, + VietNamHistoryContext vietNamHistoryContext) + { + _userManager = userManager; + _dataContext = vietNamHistoryContext; + _mapper = mapper; + } + + + public async Task> Create(CreateQuestionDto requestDto, string name) + { + var user = await _userManager.FindByEmailAsync(name); + var question = _mapper.Map(requestDto); + question.Id = Guid.NewGuid(); + question.CreateAt = DateTime.Now; + question.AuthorId = user.Id; + + try + { + _dataContext.Questions.Add(question); + await _dataContext.SaveChangesAsync(); + if (!requestDto.Tag.IsNullOrEmpty()) + { + foreach (var item in requestDto.Tag) + { + var tag = new Tag() + { + Id = Guid.NewGuid(), + Name = item + }; + var questiontag = new QuestionTag() + { + Id = Guid.NewGuid(), + TagId = tag.Id, + QuestionId = question.Id + }; + _dataContext.Tags.Add(tag); + _dataContext.QuestionTags.Add(questiontag); + } + await _dataContext.SaveChangesAsync(); + } + + + var questionResponse = _mapper.Map(question); + + var userDto = new UserShortDto() + { + FullName = user.Fullname, + Id = user.Id, + Image = user.Image, + }; + questionResponse.UserShort = userDto; + var listRequestTag = await _dataContext.QuestionTags.Where(x => x.QuestionId.Equals(Guid.Parse(questionResponse.Id))).Select(x => x.TagId).ToListAsync(); + + var tags = await _dataContext.Tags + .Where(x => listRequestTag.Any(TagId => TagId == x.Id)) + .ToListAsync(); + foreach (var tag in tags) + { + questionResponse.Tags.Add(new TagDto() + { + Name = tag.Name, + Id = tag.Id, + }); + } + return new ApiSuccessResult(questionResponse); + + } + catch (Exception ex) + { + return new ApiErrorResult("Lỗi lưu câu hỏi : " + ex.Message); + } + + + } + + public async Task> Update(CreateQuestionDto requestDto, string name) + { + var user = await _userManager.FindByEmailAsync(name); + + var updateQuestion = _dataContext.Questions.First(x => x.Id.Equals(requestDto.Id)); + 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)"); + } + + updateQuestion.UpdateAt = DateTime.Now; + updateQuestion.Content = requestDto.Content; + updateQuestion.Title = requestDto.Title; + try + { + _dataContext.Questions.Update(updateQuestion); + await _dataContext.SaveChangesAsync(); + + var tagOfQuestion = await _dataContext.QuestionTags.Where(x => x.QuestionId.Equals(updateQuestion.Id)).ToListAsync(); + _dataContext.QuestionTags.RemoveRange(tagOfQuestion); + + foreach (var item in requestDto.Tag) + { + var tag = new Tag() + { + Id = Guid.NewGuid(), + Name = item + }; + var questionTag = new QuestionTag() + { + QuestionId = requestDto.Id, + TagId = tag.Id + }; + _dataContext.QuestionTags.Add(questionTag); + _dataContext.Tags.Add(tag); + } + await _dataContext.SaveChangesAsync(); + + var questionResponse = _mapper.Map(updateQuestion); + + var useDto = new UserShortDto() + { + FullName = user.Fullname, + Id = user.Id, + Image = user.Image + }; + questionResponse.UserShort = useDto; + var listQuestionTag = await _dataContext.QuestionTags.Where(x => x.QuestionId.Equals(questionResponse.Id)).Select(x => x.TagId).ToListAsync(); + + var tags = await _dataContext.Tags + .Where(x => listQuestionTag.Any(TagId => TagId == x.Id)) + .ToListAsync(); + foreach (var tag in tags) + { + questionResponse.Tags.Add(new TagDto() + { + Name = tag.Name, + Id = tag.Id, + }); + } + + + return new ApiSuccessResult(questionResponse); + } + catch (Exception ex) + { + return new ApiErrorResult("Lỗi lưu câu h : " + ex.Message); + } + } + + public async Task> Detail(string Id) + { + var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(Id))); + if (question is null) + { + return new ApiErrorResult("Không tìm thấy câu hỏi"); + } + var user = await _userManager.FindByIdAsync(question.AuthorId.ToString()); + var questionResponse = _mapper.Map(question); + + var listQuestionTag = await _dataContext.QuestionTags.Where(x => x.QuestionId.Equals(Guid.Parse(questionResponse.Id))).Select(x => x.TagId).ToListAsync(); + var tags = await _dataContext.Tags + .Where(x => listQuestionTag.Any(TagId => TagId == x.Id)) + .ToListAsync(); + foreach (var tag in tags) + { + questionResponse.Tags.Add(new() + { + Name = tag.Name, + Id = tag.Id, + }); + } + questionResponse.UserShort = new() + { + FullName = user.Fullname, + Id = user.Id, + Image = user.Image + }; + question.ViewNumber += 1; + questionResponse.SaveNumber = await _dataContext.QuestionSaves.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); + questionResponse.CommentNumber = await _dataContext.Answers.Where(x => x.QuestionId.Equals(question.Id)).CountAsync(); + + _dataContext.Questions.Update(question); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(questionResponse); + } + + public async Task>> GetAll() + { + var questions = await _dataContext.Questions.ToListAsync(); + var users = await _dataContext.User.ToListAsync(); + + var result = new List(); + 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; + } + result.Add(question); + } + + return new ApiSuccessResult>(result); + } + + public async Task> Delete(string id, string userId) + { + var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(id)) && x.AuthorId.Equals(Guid.Parse(userId))); + if (question is null) + { + return new ApiErrorResult("Không tìm thấy câu hỏi"); + } + + _dataContext.Questions.Remove(question); + + await _dataContext.SaveChangesAsync(); + + return new ApiSuccessResult("Đã xóa câu hỏi"); + } + + public async Task> AddOrRemoveSaveQuestion(QuestionFpkDto questionFpk) + { + var question = await _dataContext.Questions.FirstOrDefaultAsync(x => x.Id.Equals(Guid.Parse(questionFpk.QuestionId))); + if (question is null) + { + return new ApiErrorResult("Không tìm thấy câu hỏi"); + } + var check = _dataContext.QuestionSaves.Where(x => x.QuestionId == question.Id && x.UserId == Guid.Parse(questionFpk.UserId)).FirstOrDefault(); + var mess = ""; + var saveNumber = await _dataContext.QuestionSaves.Where(x => x.QuestionId == question.Id).CountAsync(); + if (check is null) + { + var save = new QuestionSave() + { + Id = Guid.NewGuid(), + QuestionId = question.Id, + UserId = Guid.Parse(questionFpk.UserId) + }; + _dataContext.QuestionSaves.Add(save); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(saveNumber + 1); + } + else + { + _dataContext.QuestionSaves.Remove(check); + await _dataContext.SaveChangesAsync(); + return new ApiSuccessResult(saveNumber - 1); + } + + + } + public async Task> GetSave(QuestionFpkDto questionFpk) + { + var question = _dataContext.Questions.First(x => x.Id.Equals(Guid.Parse(questionFpk.QuestionId))); + var check = await _dataContext.QuestionSaves.Where(x => x.QuestionId.Equals(question.Id) && x.UserId == Guid.Parse(questionFpk.UserId)).FirstOrDefaultAsync(); + var reuslt = check != null; + return new ApiSuccessResult(reuslt); + } + public async Task>> GetAllTag(int numberTag) + { + var tags = await _dataContext.Tags + .GroupBy(x => x.Name) + .Select(group => new { Name = group.Key, Count = group.Sum(t => 1) }) + .OrderByDescending(tagName => tagName.Count) + .Take(numberTag) + .Select(group => group.Name) + .ToListAsync(); + return new ApiSuccessResult>(tags); + } + + + public async Task>> GetQuestionByTag(string tag) + { + var questions = await _dataContext.Questions + .Where(question => _dataContext.QuestionTags + .Any(questionTag => _dataContext.Tags + .Any(tagEntity => tagEntity.Name.ToLower().Contains(tag.ToLower()) && tagEntity.Id == questionTag.TagId) + && questionTag.QuestionId == question.Id)) + .ToListAsync(); + if (questions.IsNullOrEmpty()) + { + return new ApiSuccessResult>(new List()); + } + var users = await _dataContext.User.ToListAsync(); + + var result = new List(); + foreach (var item in questions) + { + var ques = _mapper.Map(item); + var userShort = users.First(x => x.Id == item.AuthorId); + if (userShort is not null) + { + ques.UserShort.FullName = userShort.Fullname; + ques.UserShort.Id = userShort.Id; + ques.UserShort.Image = userShort.Image; + } + result.Add(ques); + } + return new ApiSuccessResult>(result); + } + + + } + + +} diff --git a/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs b/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs index 9ec860e..bb08741 100644 --- a/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs +++ b/VNH.Infrastructure/Implement/Catalog/Posts/PostService.cs @@ -425,7 +425,7 @@ public async Task>> GetTopTags(int numberTag) .GroupBy(x => x.Name) .Select(group => new { Name = group.Key, Count = group.Sum(t => 1) }) .OrderByDescending(tagName => tagName.Count) - .Take(10) + .Take(numberTag) .Select(group => group.Name) .ToListAsync(); diff --git a/VNH.Infrastructure/Migrations/20231120064521_update question table.Designer.cs b/VNH.Infrastructure/Migrations/20231120064521_update question table.Designer.cs new file mode 100644 index 0000000..2339f4a --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231120064521_update question table.Designer.cs @@ -0,0 +1,1867 @@ +// +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("20231120064521_update question table")] + partial class updatequestiontable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.11") + .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("MostConfirm") + .HasColumnType("bit"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("QuestionId"); + + b.ToTable("Answer"); + }); + + modelBuilder.Entity("VNH.Domain.AnswerVote", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("AnswerId"); + + b.HasIndex("UserId"); + + b.ToTable("AnswerVote"); + }); + + modelBuilder.Entity("VNH.Domain.Course", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseName") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Course"); + }); + + modelBuilder.Entity("VNH.Domain.CourseComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseComment"); + }); + + modelBuilder.Entity("VNH.Domain.CourseRating", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Score") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseRating"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSave"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Document", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("VNH.Domain.DocumentSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DocumentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("UserId"); + + b.ToTable("DocumentSave"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.Notification", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Notification"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("IsRead") + .HasColumnType("int"); + + b.Property("NotificationId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationDetails"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PostId") + .IsRequired() + .HasColumnType("nvarchar(255)"); + + b.Property("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TagId"); + + b.ToTable("PostTags"); + }); + + modelBuilder.Entity("VNH.Domain.Exercise", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("QuizId") + .HasColumnType("uniqueidentifier"); + + b.Property("Time") + .HasColumnType("time"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.ToTable("Exercise"); + }); + + modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestMark") + .HasColumnType("float"); + + b.Property("TestTime") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ExerciseId"); + + b.HasIndex("UserId"); + + b.ToTable("ExerciseDetail"); + }); + + modelBuilder.Entity("VNH.Domain.Lesson", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UrlVideo") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("VNH.Domain.News", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasColumnType("text"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.ToTable("News"); + }); + + modelBuilder.Entity("VNH.Domain.Post", b => + { + b.Property("Id") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ViewNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TopicId"); + + b.HasIndex("UserId"); + + b.ToTable("Post"); + }); + + modelBuilder.Entity("VNH.Domain.PostComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostComment"); + }); + + modelBuilder.Entity("VNH.Domain.PostLike", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostLike"); + }); + + modelBuilder.Entity("VNH.Domain.PostReportDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Checked") + .HasColumnType("bit"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReportId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("ReportId"); + + b.HasIndex("UserId"); + + b.ToTable("PostReportDetail"); + }); + + modelBuilder.Entity("VNH.Domain.PostSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSave"); + }); + + modelBuilder.Entity("VNH.Domain.PostSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Question", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreateAt") + .HasColumnType("datetime"); + + b.Property("QuestionTagId") + .HasColumnType("uniqueidentifier"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UpdateAt") + .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("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TagId"); + + b.ToTable("QuestionTag"); + }); + + modelBuilder.Entity("VNH.Domain.Quiz", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Answer1") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer2") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer3") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer4") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Question") + .HasColumnType("nvarchar(max)"); + + b.Property("RightAnswer") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.ToTable("Quiz"); + }); + + modelBuilder.Entity("VNH.Domain.Report", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Report"); + + b.HasData( + new + { + Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), + CreatedAt = new DateTime(2023, 11, 20, 13, 45, 21, 422, DateTimeKind.Local).AddTicks(9106), + 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, 20, 13, 45, 21, 422, DateTimeKind.Local).AddTicks(9119), + 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, 20, 13, 45, 21, 422, DateTimeKind.Local).AddTicks(9128), + 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, 20, 13, 45, 21, 422, DateTimeKind.Local).AddTicks(9130), + 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, 20, 13, 45, 21, 422, DateTimeKind.Local).AddTicks(9132), + 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, 20, 13, 45, 21, 422, DateTimeKind.Local).AddTicks(9134), + 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, 20, 13, 45, 21, 422, DateTimeKind.Local).AddTicks(9136), + 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 = "96d770d8-a4ff-4dee-b4bd-04ca001bd966", + Name = "admin", + NormalizedName = "admin" + }, + new + { + Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), + ConcurrencyStamp = "cb600f97-e6e5-4637-bf30-2ebbd58b1b1f", + Name = "teacher", + NormalizedName = "teacher" + }, + new + { + Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), + ConcurrencyStamp = "2836b3ed-85bd-41f9-be79-b119bf758116", + 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("PreAnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("PreAnswerId"); + + b.ToTable("SubAnswer"); + }); + + modelBuilder.Entity("VNH.Domain.Tag", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Tag"); + }); + + modelBuilder.Entity("VNH.Domain.Topic", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Topic"); + }); + + modelBuilder.Entity("VNH.Domain.TopicDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TopicId"); + + b.ToTable("TopicDetail"); + }); + + modelBuilder.Entity("VNH.Domain.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("DateOfBirth") + .HasColumnType("datetime"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("Fullname") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("Image") + .HasMaxLength(3145728) + .HasColumnType("nvarchar(max)"); + + b.Property("Introduction") + .HasColumnType("nvarchar(max)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .HasColumnType("nvarchar(max)"); + + b.Property("NumberConfirm") + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("User"); + + b.HasData( + new + { + Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + AccessFailedCount = 0, + ConcurrencyStamp = "1f080d53-1ba8-40e4-933e-beec13bccc47", + DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), + Email = "admin@gmail.com", + EmailConfirmed = true, + Fullname = "Lương Xuân Nhất", + Gender = 0, + Image = "", + LockoutEnabled = false, + NormalizedEmail = "onionwebdev@gmail.com", + NormalizedUserName = "admin", + PasswordHash = "AQAAAAEAACcQAAAAEHTZdl4u/ySPUE8WUW2tg/Obhugs4eMLtK2evXlyfWMpo6GT+LxC4Nrq2dDO5kTBag==", + 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", "IdNavigation") + .WithOne("QuestionTag") + .HasForeignKey("VNH.Domain.QuestionTag", "Id") + .IsRequired() + .HasConstraintName("FK__QuestionTag__Id__2739D489"); + + b.HasOne("VNH.Domain.Tag", "Tag") + .WithMany("QuestionTags") + .HasForeignKey("TagId") + .HasConstraintName("FK__QuestionT__TagId__2645B050"); + + b.Navigation("IdNavigation"); + + 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/20231120064521_update question table.cs b/VNH.Infrastructure/Migrations/20231120064521_update question table.cs new file mode 100644 index 0000000..81acba4 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231120064521_update question table.cs @@ -0,0 +1,42 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class updatequestiontable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "PubDate", + table: "Question", + newName: "UpdateAt"); + + migrationBuilder.AddColumn( + name: "CreateAt", + table: "Question", + type: "datetime", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CreateAt", + table: "Question"); + + migrationBuilder.RenameColumn( + name: "UpdateAt", + table: "Question", + newName: "PubDate"); + + } + } +} diff --git a/VNH.Infrastructure/Migrations/20231120075940_update questiontag table.Designer.cs b/VNH.Infrastructure/Migrations/20231120075940_update questiontag table.Designer.cs new file mode 100644 index 0000000..856381f --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231120075940_update questiontag table.Designer.cs @@ -0,0 +1,1867 @@ +// +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("20231120075940_update questiontag table")] + partial class updatequestiontagtable + { + /// + 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("MostConfirm") + .HasColumnType("bit"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("QuestionId"); + + b.ToTable("Answer"); + }); + + modelBuilder.Entity("VNH.Domain.AnswerVote", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("AnswerId"); + + b.HasIndex("UserId"); + + b.ToTable("AnswerVote"); + }); + + modelBuilder.Entity("VNH.Domain.Course", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseName") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Course"); + }); + + modelBuilder.Entity("VNH.Domain.CourseComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseComment"); + }); + + modelBuilder.Entity("VNH.Domain.CourseRating", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Score") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseRating"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSave"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Document", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("VNH.Domain.DocumentSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DocumentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("UserId"); + + b.ToTable("DocumentSave"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.Notification", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Notification"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("IsRead") + .HasColumnType("int"); + + b.Property("NotificationId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationDetails"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PostId") + .IsRequired() + .HasColumnType("nvarchar(255)"); + + b.Property("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TagId"); + + b.ToTable("PostTags"); + }); + + modelBuilder.Entity("VNH.Domain.Exercise", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("QuizId") + .HasColumnType("uniqueidentifier"); + + b.Property("Time") + .HasColumnType("time"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.ToTable("Exercise"); + }); + + modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestMark") + .HasColumnType("float"); + + b.Property("TestTime") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ExerciseId"); + + b.HasIndex("UserId"); + + b.ToTable("ExerciseDetail"); + }); + + modelBuilder.Entity("VNH.Domain.Lesson", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UrlVideo") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("VNH.Domain.News", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasColumnType("text"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.ToTable("News"); + }); + + modelBuilder.Entity("VNH.Domain.Post", b => + { + b.Property("Id") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ViewNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TopicId"); + + b.HasIndex("UserId"); + + b.ToTable("Post"); + }); + + modelBuilder.Entity("VNH.Domain.PostComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostComment"); + }); + + modelBuilder.Entity("VNH.Domain.PostLike", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostLike"); + }); + + modelBuilder.Entity("VNH.Domain.PostReportDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Checked") + .HasColumnType("bit"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReportId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("ReportId"); + + b.HasIndex("UserId"); + + b.ToTable("PostReportDetail"); + }); + + modelBuilder.Entity("VNH.Domain.PostSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSave"); + }); + + modelBuilder.Entity("VNH.Domain.PostSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Question", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreateAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UpdateAt") + .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("TagId"); + + b.ToTable("QuestionTag"); + }); + + modelBuilder.Entity("VNH.Domain.Quiz", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Answer1") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer2") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer3") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer4") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Question") + .HasColumnType("nvarchar(max)"); + + b.Property("RightAnswer") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.ToTable("Quiz"); + }); + + modelBuilder.Entity("VNH.Domain.Report", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Report"); + + b.HasData( + new + { + Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), + CreatedAt = new DateTime(2023, 11, 20, 14, 59, 40, 9, DateTimeKind.Local).AddTicks(7611), + 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, 20, 14, 59, 40, 9, DateTimeKind.Local).AddTicks(7626), + 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, 20, 14, 59, 40, 9, DateTimeKind.Local).AddTicks(7628), + 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, 20, 14, 59, 40, 9, DateTimeKind.Local).AddTicks(7630), + 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, 20, 14, 59, 40, 9, DateTimeKind.Local).AddTicks(7633), + 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, 20, 14, 59, 40, 9, DateTimeKind.Local).AddTicks(7635), + 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, 20, 14, 59, 40, 9, DateTimeKind.Local).AddTicks(7638), + 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 = "3c8c3656-a093-436a-b933-f03b9d81e9cf", + Name = "admin", + NormalizedName = "admin" + }, + new + { + Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), + ConcurrencyStamp = "b20d6ee0-be88-4692-8caf-972dadeae732", + Name = "teacher", + NormalizedName = "teacher" + }, + new + { + Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), + ConcurrencyStamp = "0243427d-0e22-44e5-9b3b-9ad4a0a1af2d", + 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("PreAnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("PreAnswerId"); + + b.ToTable("SubAnswer"); + }); + + modelBuilder.Entity("VNH.Domain.Tag", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Tag"); + }); + + modelBuilder.Entity("VNH.Domain.Topic", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Topic"); + }); + + modelBuilder.Entity("VNH.Domain.TopicDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TopicId"); + + b.ToTable("TopicDetail"); + }); + + modelBuilder.Entity("VNH.Domain.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("DateOfBirth") + .HasColumnType("datetime"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("Fullname") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("Image") + .HasMaxLength(3145728) + .HasColumnType("nvarchar(max)"); + + b.Property("Introduction") + .HasColumnType("nvarchar(max)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .HasColumnType("nvarchar(max)"); + + b.Property("NumberConfirm") + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("User"); + + b.HasData( + new + { + Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + AccessFailedCount = 0, + ConcurrencyStamp = "97810ee5-1e9f-4e90-ab40-879967fc7712", + DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), + Email = "admin@gmail.com", + EmailConfirmed = true, + Fullname = "Lương Xuân Nhất", + Gender = 0, + Image = "", + LockoutEnabled = false, + NormalizedEmail = "onionwebdev@gmail.com", + NormalizedUserName = "admin", + PasswordHash = "AQAAAAEAACcQAAAAEIWL/TKj5ZHCyE4ZZl2ZXw+wZLwOQGc+y6AfMEtWMXlAeLUgpiUkcvSPhbOZfxa6NA==", + 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", "IdNavigation") + .WithOne("QuestionTag") + .HasForeignKey("VNH.Domain.QuestionTag", "Id") + .IsRequired() + .HasConstraintName("FK__QuestionTag__Id__2739D489"); + + b.HasOne("VNH.Domain.Tag", "Tag") + .WithMany("QuestionTags") + .HasForeignKey("TagId") + .HasConstraintName("FK__QuestionT__TagId__2645B050"); + + b.Navigation("IdNavigation"); + + 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/20231120075940_update questiontag table.cs b/VNH.Infrastructure/Migrations/20231120075940_update questiontag table.cs new file mode 100644 index 0000000..ecdd468 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231120075940_update questiontag table.cs @@ -0,0 +1,41 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class updatequestiontagtable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "QuestionTagId", + table: "Question"); + + migrationBuilder.AddColumn( + name: "QuestionId", + table: "QuestionTag", + type: "uniqueidentifier", + nullable: true); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "QuestionId", + table: "QuestionTag"); + + migrationBuilder.AddColumn( + name: "QuestionTagId", + table: "Question", + type: "uniqueidentifier", + nullable: true); + + } + } +} diff --git a/VNH.Infrastructure/Migrations/20231120083158_update questiontag table 2.Designer.cs b/VNH.Infrastructure/Migrations/20231120083158_update questiontag table 2.Designer.cs new file mode 100644 index 0000000..6816e85 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231120083158_update questiontag table 2.Designer.cs @@ -0,0 +1,1868 @@ +// +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("20231120083158_update questiontag table 2")] + partial class updatequestiontagtable2 + { + /// + 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("MostConfirm") + .HasColumnType("bit"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("QuestionId"); + + b.ToTable("Answer"); + }); + + modelBuilder.Entity("VNH.Domain.AnswerVote", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("AnswerId"); + + b.HasIndex("UserId"); + + b.ToTable("AnswerVote"); + }); + + modelBuilder.Entity("VNH.Domain.Course", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseName") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Course"); + }); + + modelBuilder.Entity("VNH.Domain.CourseComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseComment"); + }); + + modelBuilder.Entity("VNH.Domain.CourseRating", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Score") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseRating"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSave"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Document", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("VNH.Domain.DocumentSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DocumentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("UserId"); + + b.ToTable("DocumentSave"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.Notification", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Notification"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("IsRead") + .HasColumnType("int"); + + b.Property("NotificationId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationDetails"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PostId") + .IsRequired() + .HasColumnType("nvarchar(255)"); + + b.Property("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TagId"); + + b.ToTable("PostTags"); + }); + + modelBuilder.Entity("VNH.Domain.Exercise", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("QuizId") + .HasColumnType("uniqueidentifier"); + + b.Property("Time") + .HasColumnType("time"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.ToTable("Exercise"); + }); + + modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestMark") + .HasColumnType("float"); + + b.Property("TestTime") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ExerciseId"); + + b.HasIndex("UserId"); + + b.ToTable("ExerciseDetail"); + }); + + modelBuilder.Entity("VNH.Domain.Lesson", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UrlVideo") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("VNH.Domain.News", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasColumnType("text"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.ToTable("News"); + }); + + modelBuilder.Entity("VNH.Domain.Post", b => + { + b.Property("Id") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ViewNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TopicId"); + + b.HasIndex("UserId"); + + b.ToTable("Post"); + }); + + modelBuilder.Entity("VNH.Domain.PostComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostComment"); + }); + + modelBuilder.Entity("VNH.Domain.PostLike", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostLike"); + }); + + modelBuilder.Entity("VNH.Domain.PostReportDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Checked") + .HasColumnType("bit"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReportId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("ReportId"); + + b.HasIndex("UserId"); + + b.ToTable("PostReportDetail"); + }); + + modelBuilder.Entity("VNH.Domain.PostSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSave"); + }); + + modelBuilder.Entity("VNH.Domain.PostSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Question", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreateAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UpdateAt") + .HasColumnType("datetime"); + + b.Property("ViewNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Question"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionLike", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionLike"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Checked") + .HasColumnType("bit"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReportId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("ReportId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionReportDetail"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionSave"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionTag", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("TagId"); + + b.ToTable("QuestionTag"); + }); + + modelBuilder.Entity("VNH.Domain.Quiz", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Answer1") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer2") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer3") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer4") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Question") + .HasColumnType("nvarchar(max)"); + + b.Property("RightAnswer") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.ToTable("Quiz"); + }); + + modelBuilder.Entity("VNH.Domain.Report", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Report"); + + b.HasData( + new + { + Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), + CreatedAt = new DateTime(2023, 11, 20, 15, 31, 58, 283, DateTimeKind.Local).AddTicks(8992), + 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, 20, 15, 31, 58, 283, DateTimeKind.Local).AddTicks(9008), + 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, 20, 15, 31, 58, 283, DateTimeKind.Local).AddTicks(9012), + 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, 20, 15, 31, 58, 283, DateTimeKind.Local).AddTicks(9014), + 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, 20, 15, 31, 58, 283, DateTimeKind.Local).AddTicks(9015), + 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, 20, 15, 31, 58, 283, DateTimeKind.Local).AddTicks(9019), + 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, 20, 15, 31, 58, 283, DateTimeKind.Local).AddTicks(9022), + 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 = "aa8e1650-179c-4a94-9cbb-0cab7bc4de2f", + Name = "admin", + NormalizedName = "admin" + }, + new + { + Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), + ConcurrencyStamp = "2451c9c3-67fd-460d-bb03-41e8c983c567", + Name = "teacher", + NormalizedName = "teacher" + }, + new + { + Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), + ConcurrencyStamp = "8e52473d-a973-4bfd-a56d-5619b283c03c", + 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("PreAnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("PreAnswerId"); + + b.ToTable("SubAnswer"); + }); + + modelBuilder.Entity("VNH.Domain.Tag", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Tag"); + }); + + modelBuilder.Entity("VNH.Domain.Topic", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Topic"); + }); + + modelBuilder.Entity("VNH.Domain.TopicDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TopicId"); + + b.ToTable("TopicDetail"); + }); + + modelBuilder.Entity("VNH.Domain.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("DateOfBirth") + .HasColumnType("datetime"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("Fullname") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("Image") + .HasMaxLength(3145728) + .HasColumnType("nvarchar(max)"); + + b.Property("Introduction") + .HasColumnType("nvarchar(max)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .HasColumnType("nvarchar(max)"); + + b.Property("NumberConfirm") + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("User"); + + b.HasData( + new + { + Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + AccessFailedCount = 0, + ConcurrencyStamp = "ef9d9f06-80d5-4d94-94c0-11d815bfb947", + DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), + Email = "admin@gmail.com", + EmailConfirmed = true, + Fullname = "Lương Xuân Nhất", + Gender = 0, + Image = "", + LockoutEnabled = false, + NormalizedEmail = "onionwebdev@gmail.com", + NormalizedUserName = "admin", + PasswordHash = "AQAAAAEAACcQAAAAEG7Ij74W/Ytocnd8C5Edhh18X+HmKbQGkGt4aUoOlSEWSn/QAeYyKZO+QjjVFhkLeA==", + 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/20231120083158_update questiontag table 2.cs b/VNH.Infrastructure/Migrations/20231120083158_update questiontag table 2.cs new file mode 100644 index 0000000..266fb2c --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231120083158_update questiontag table 2.cs @@ -0,0 +1,52 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class updatequestiontagtable2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK__QuestionTag__Id__2739D489", + table: "QuestionTag"); + + + migrationBuilder.CreateIndex( + name: "IX_QuestionTag_QuestionId", + table: "QuestionTag", + column: "QuestionId"); + + migrationBuilder.AddForeignKey( + name: "FK__QuestionTag__Id__2739D489", + table: "QuestionTag", + column: "QuestionId", + principalTable: "Question", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK__QuestionTag__Id__2739D489", + table: "QuestionTag"); + + migrationBuilder.DropIndex( + name: "IX_QuestionTag_QuestionId", + table: "QuestionTag"); + + + migrationBuilder.AddForeignKey( + name: "FK__QuestionTag__Id__2739D489", + table: "QuestionTag", + column: "Id", + principalTable: "Question", + principalColumn: "Id"); + } + } +} diff --git a/VNH.Infrastructure/Migrations/20231121014823_add column UpdateAt for table Answer.Designer.cs b/VNH.Infrastructure/Migrations/20231121014823_add column UpdateAt for table Answer.Designer.cs new file mode 100644 index 0000000..ae8318a --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231121014823_add column UpdateAt for table Answer.Designer.cs @@ -0,0 +1,1871 @@ +// +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("20231121014823_add column UpdateAt for table Answer")] + partial class addcolumnUpdateAtfortableAnswer + { + /// + 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("MostConfirm") + .HasColumnType("bit"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("QuestionId"); + + b.ToTable("Answer"); + }); + + modelBuilder.Entity("VNH.Domain.AnswerVote", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("AnswerId"); + + b.HasIndex("UserId"); + + b.ToTable("AnswerVote"); + }); + + modelBuilder.Entity("VNH.Domain.Course", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseName") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Course"); + }); + + modelBuilder.Entity("VNH.Domain.CourseComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseComment"); + }); + + modelBuilder.Entity("VNH.Domain.CourseRating", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Score") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseRating"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSave"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Document", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("VNH.Domain.DocumentSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DocumentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("UserId"); + + b.ToTable("DocumentSave"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.Notification", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Notification"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("IsRead") + .HasColumnType("int"); + + b.Property("NotificationId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationDetails"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PostId") + .IsRequired() + .HasColumnType("nvarchar(255)"); + + b.Property("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TagId"); + + b.ToTable("PostTags"); + }); + + modelBuilder.Entity("VNH.Domain.Exercise", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("QuizId") + .HasColumnType("uniqueidentifier"); + + b.Property("Time") + .HasColumnType("time"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.ToTable("Exercise"); + }); + + modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestMark") + .HasColumnType("float"); + + b.Property("TestTime") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ExerciseId"); + + b.HasIndex("UserId"); + + b.ToTable("ExerciseDetail"); + }); + + modelBuilder.Entity("VNH.Domain.Lesson", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UrlVideo") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("VNH.Domain.News", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasColumnType("text"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.ToTable("News"); + }); + + modelBuilder.Entity("VNH.Domain.Post", b => + { + b.Property("Id") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ViewNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TopicId"); + + b.HasIndex("UserId"); + + b.ToTable("Post"); + }); + + modelBuilder.Entity("VNH.Domain.PostComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostComment"); + }); + + modelBuilder.Entity("VNH.Domain.PostLike", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostLike"); + }); + + modelBuilder.Entity("VNH.Domain.PostReportDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Checked") + .HasColumnType("bit"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReportId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("ReportId"); + + b.HasIndex("UserId"); + + b.ToTable("PostReportDetail"); + }); + + modelBuilder.Entity("VNH.Domain.PostSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSave"); + }); + + modelBuilder.Entity("VNH.Domain.PostSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Question", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreateAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UpdateAt") + .HasColumnType("datetime"); + + b.Property("ViewNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Question"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionLike", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionLike"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Checked") + .HasColumnType("bit"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReportId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("ReportId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionReportDetail"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionSave"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionTag", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("TagId"); + + b.ToTable("QuestionTag"); + }); + + modelBuilder.Entity("VNH.Domain.Quiz", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Answer1") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer2") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer3") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer4") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Question") + .HasColumnType("nvarchar(max)"); + + b.Property("RightAnswer") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.ToTable("Quiz"); + }); + + modelBuilder.Entity("VNH.Domain.Report", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Report"); + + b.HasData( + new + { + Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), + CreatedAt = new DateTime(2023, 11, 21, 8, 48, 23, 480, DateTimeKind.Local).AddTicks(6220), + 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, 21, 8, 48, 23, 480, DateTimeKind.Local).AddTicks(6265), + 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, 21, 8, 48, 23, 480, DateTimeKind.Local).AddTicks(6271), + 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, 21, 8, 48, 23, 480, DateTimeKind.Local).AddTicks(6276), + 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, 21, 8, 48, 23, 480, DateTimeKind.Local).AddTicks(6287), + 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, 21, 8, 48, 23, 480, DateTimeKind.Local).AddTicks(6293), + 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, 21, 8, 48, 23, 480, DateTimeKind.Local).AddTicks(6299), + 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 = "7b0fac8e-d69b-42f0-9297-ae69d464541c", + Name = "admin", + NormalizedName = "admin" + }, + new + { + Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), + ConcurrencyStamp = "77204fec-1ade-4423-87aa-24ca8fcab8ad", + Name = "teacher", + NormalizedName = "teacher" + }, + new + { + Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), + ConcurrencyStamp = "6e610eda-543a-490d-a3a7-55725384a36e", + 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("PreAnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("PreAnswerId"); + + b.ToTable("SubAnswer"); + }); + + modelBuilder.Entity("VNH.Domain.Tag", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Tag"); + }); + + modelBuilder.Entity("VNH.Domain.Topic", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Topic"); + }); + + modelBuilder.Entity("VNH.Domain.TopicDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TopicId"); + + b.ToTable("TopicDetail"); + }); + + modelBuilder.Entity("VNH.Domain.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("DateOfBirth") + .HasColumnType("datetime"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("Fullname") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("Image") + .HasMaxLength(3145728) + .HasColumnType("nvarchar(max)"); + + b.Property("Introduction") + .HasColumnType("nvarchar(max)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .HasColumnType("nvarchar(max)"); + + b.Property("NumberConfirm") + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("User"); + + b.HasData( + new + { + Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + AccessFailedCount = 0, + ConcurrencyStamp = "501e73f3-8ee6-4fd4-8b04-46c28c2ce1d2", + DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), + Email = "admin@gmail.com", + EmailConfirmed = true, + Fullname = "Lương Xuân Nhất", + Gender = 0, + Image = "", + LockoutEnabled = false, + NormalizedEmail = "onionwebdev@gmail.com", + NormalizedUserName = "admin", + PasswordHash = "AQAAAAEAACcQAAAAENICOb0t0UqlZQ2EC4KFMuRVhESBv/2Xzz197VB/tnt7ZD4+kfsoLTshwe+n+mVrMg==", + 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/20231121014823_add column UpdateAt for table Answer.cs b/VNH.Infrastructure/Migrations/20231121014823_add column UpdateAt for table Answer.cs new file mode 100644 index 0000000..4006ace --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231121014823_add column UpdateAt for table Answer.cs @@ -0,0 +1,30 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class addcolumnUpdateAtfortableAnswer : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "UpdateAt", + table: "Answer", + type: "datetime", + nullable: true); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "UpdateAt", + table: "Answer"); + } + } +} diff --git a/VNH.Infrastructure/Migrations/20231121030333_add column UpdateAt for table SubAnswer.Designer.cs b/VNH.Infrastructure/Migrations/20231121030333_add column UpdateAt for table SubAnswer.Designer.cs new file mode 100644 index 0000000..3402ab0 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231121030333_add column UpdateAt for table SubAnswer.Designer.cs @@ -0,0 +1,1874 @@ +// +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("20231121030333_add column UpdateAt for table SubAnswer")] + partial class addcolumnUpdateAtfortableSubAnswer + { + /// + 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("MostConfirm") + .HasColumnType("bit"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdateAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("QuestionId"); + + b.ToTable("Answer"); + }); + + modelBuilder.Entity("VNH.Domain.AnswerVote", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("AnswerId"); + + b.HasIndex("UserId"); + + b.ToTable("AnswerVote"); + }); + + modelBuilder.Entity("VNH.Domain.Course", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseName") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Course"); + }); + + modelBuilder.Entity("VNH.Domain.CourseComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseComment"); + }); + + modelBuilder.Entity("VNH.Domain.CourseRating", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Score") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseRating"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSave"); + }); + + modelBuilder.Entity("VNH.Domain.CourseSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("CourseSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Document", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Document"); + }); + + modelBuilder.Entity("VNH.Domain.DocumentSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DocumentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("UserId"); + + b.ToTable("DocumentSave"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.Notification", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Notification"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.NotificationDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("Date") + .HasColumnType("datetime2"); + + b.Property("IsRead") + .HasColumnType("int"); + + b.Property("NotificationId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("NotificationId"); + + b.HasIndex("UserId"); + + b.ToTable("NotificationDetails"); + }); + + modelBuilder.Entity("VNH.Domain.Entities.PostTag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PostId") + .IsRequired() + .HasColumnType("nvarchar(255)"); + + b.Property("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TagId"); + + b.ToTable("PostTags"); + }); + + modelBuilder.Entity("VNH.Domain.Exercise", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("QuizId") + .HasColumnType("uniqueidentifier"); + + b.Property("Time") + .HasColumnType("time"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.ToTable("Exercise"); + }); + + modelBuilder.Entity("VNH.Domain.ExerciseDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("TestMark") + .HasColumnType("float"); + + b.Property("TestTime") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ExerciseId"); + + b.HasIndex("UserId"); + + b.ToTable("ExerciseDetail"); + }); + + modelBuilder.Entity("VNH.Domain.Lesson", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CourseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("ExerciseId") + .HasColumnType("uniqueidentifier"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UrlVideo") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Lesson"); + }); + + modelBuilder.Entity("VNH.Domain.News", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Image") + .HasColumnType("text"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Url") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)"); + + b.HasKey("Id"); + + b.ToTable("News"); + }); + + modelBuilder.Entity("VNH.Domain.Post", b => + { + b.Property("Id") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Image") + .HasColumnType("nvarchar(max)"); + + b.Property("SubId") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.Property("ViewNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TopicId"); + + b.HasIndex("UserId"); + + b.ToTable("Post"); + }); + + modelBuilder.Entity("VNH.Domain.PostComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostComment"); + }); + + modelBuilder.Entity("VNH.Domain.PostLike", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostLike"); + }); + + modelBuilder.Entity("VNH.Domain.PostReportDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Checked") + .HasColumnType("bit"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReportId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("ReportId"); + + b.HasIndex("UserId"); + + b.ToTable("PostReportDetail"); + }); + + modelBuilder.Entity("VNH.Domain.PostSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSave"); + }); + + modelBuilder.Entity("VNH.Domain.PostSubComment", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("PreCommentId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PreCommentId"); + + b.HasIndex("UserId"); + + b.ToTable("PostSubComment"); + }); + + modelBuilder.Entity("VNH.Domain.Question", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreateAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("UpdateAt") + .HasColumnType("datetime"); + + b.Property("ViewNumber") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Question"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionLike", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionLike"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionReportDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Checked") + .HasColumnType("bit"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("ReportDate") + .HasColumnType("datetime2"); + + b.Property("ReportId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("ReportId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionReportDetail"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionSave", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("UserId"); + + b.ToTable("QuestionSave"); + }); + + modelBuilder.Entity("VNH.Domain.QuestionTag", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("QuestionId") + .HasColumnType("uniqueidentifier"); + + b.Property("TagId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("QuestionId"); + + b.HasIndex("TagId"); + + b.ToTable("QuestionTag"); + }); + + modelBuilder.Entity("VNH.Domain.Quiz", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Answer1") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer2") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer3") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Answer4") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Question") + .HasColumnType("nvarchar(max)"); + + b.Property("RightAnswer") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Id"); + + b.ToTable("Quiz"); + }); + + modelBuilder.Entity("VNH.Domain.Report", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Report"); + + b.HasData( + new + { + Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), + CreatedAt = new DateTime(2023, 11, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6450), + 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, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6463), + 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, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6465), + 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, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6468), + 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, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6470), + 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, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6472), + 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, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6474), + 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 = "12e5e898-54fb-436f-b388-3a86dab13fad", + Name = "admin", + NormalizedName = "admin" + }, + new + { + Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), + ConcurrencyStamp = "661a3ba6-1d96-4fee-a6c3-c6bb4226e93b", + Name = "teacher", + NormalizedName = "teacher" + }, + new + { + Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), + ConcurrencyStamp = "8354d441-e7d9-4c7a-b73d-44bd84e3d088", + 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("PreAnswerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PubDate") + .HasColumnType("datetime"); + + b.Property("UpdateAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.HasIndex("PreAnswerId"); + + b.ToTable("SubAnswer"); + }); + + modelBuilder.Entity("VNH.Domain.Tag", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.HasKey("Id"); + + b.ToTable("Tag"); + }); + + modelBuilder.Entity("VNH.Domain.Topic", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AuthorId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime"); + + b.HasKey("Id"); + + b.HasIndex("AuthorId"); + + b.ToTable("Topic"); + }); + + modelBuilder.Entity("VNH.Domain.TopicDetail", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("nvarchar(255)"); + + b.Property("TopicId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("PostId"); + + b.HasIndex("TopicId"); + + b.ToTable("TopicDetail"); + }); + + modelBuilder.Entity("VNH.Domain.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("DateOfBirth") + .HasColumnType("datetime"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("Fullname") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Gender") + .HasColumnType("int"); + + b.Property("Image") + .HasMaxLength(3145728) + .HasColumnType("nvarchar(max)"); + + b.Property("Introduction") + .HasColumnType("nvarchar(max)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .HasColumnType("nvarchar(max)"); + + b.Property("NumberConfirm") + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("User"); + + b.HasData( + new + { + Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), + AccessFailedCount = 0, + ConcurrencyStamp = "d22c9b5e-0177-4807-ac36-e61bb86cc5f5", + DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), + Email = "admin@gmail.com", + EmailConfirmed = true, + Fullname = "Lương Xuân Nhất", + Gender = 0, + Image = "", + LockoutEnabled = false, + NormalizedEmail = "onionwebdev@gmail.com", + NormalizedUserName = "admin", + PasswordHash = "AQAAAAEAACcQAAAAEFIJwgq3eV+hZm2d+7apMkFyGpxUYooCdajUXUKqWLSUwBa69VQf3AtsTvTaradpQQ==", + 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/20231121030333_add column UpdateAt for table SubAnswer.cs b/VNH.Infrastructure/Migrations/20231121030333_add column UpdateAt for table SubAnswer.cs new file mode 100644 index 0000000..580f348 --- /dev/null +++ b/VNH.Infrastructure/Migrations/20231121030333_add column UpdateAt for table SubAnswer.cs @@ -0,0 +1,31 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VNH.Infrastructure.Migrations +{ + /// + public partial class addcolumnUpdateAtfortableSubAnswer : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "UpdateAt", + table: "SubAnswer", + type: "datetime", + nullable: true); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "UpdateAt", + table: "SubAnswer"); + + } + } +} diff --git a/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs b/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs index 94cca6d..aeba9d9 100644 --- a/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs +++ b/VNH.Infrastructure/Migrations/VietNamHistoryContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.11") + .HasAnnotation("ProductVersion", "7.0.13") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -149,6 +149,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("QuestionId") .HasColumnType("uniqueidentifier"); + b.Property("UpdateAt") + .HasColumnType("datetime"); + b.HasKey("Id"); b.HasIndex("AuthorId"); @@ -756,16 +759,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Content") .HasColumnType("nvarchar(max)"); - b.Property("PubDate") + b.Property("CreateAt") .HasColumnType("datetime"); - b.Property("QuestionTagId") - .HasColumnType("uniqueidentifier"); - b.Property("Title") .HasMaxLength(500) .HasColumnType("nvarchar(500)"); + b.Property("UpdateAt") + .HasColumnType("datetime"); + b.Property("ViewNumber") .HasColumnType("int"); @@ -856,11 +859,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) 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"); @@ -924,49 +932,49 @@ protected override void BuildModel(ModelBuilder modelBuilder) new { Id = new Guid("d30e1353-0163-43c1-b757-7957981b0eda"), - CreatedAt = new DateTime(2023, 11, 18, 20, 17, 41, 588, DateTimeKind.Local).AddTicks(1571), + CreatedAt = new DateTime(2023, 11, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6450), 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, 18, 20, 17, 41, 588, DateTimeKind.Local).AddTicks(1586), + CreatedAt = new DateTime(2023, 11, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6463), 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, 18, 20, 17, 41, 588, DateTimeKind.Local).AddTicks(1588), + CreatedAt = new DateTime(2023, 11, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6465), 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, 18, 20, 17, 41, 588, DateTimeKind.Local).AddTicks(1590), + CreatedAt = new DateTime(2023, 11, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6468), 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, 18, 20, 17, 41, 588, DateTimeKind.Local).AddTicks(1592), + CreatedAt = new DateTime(2023, 11, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6470), 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, 18, 20, 17, 41, 588, DateTimeKind.Local).AddTicks(1594), + CreatedAt = new DateTime(2023, 11, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6472), 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, 18, 20, 17, 41, 588, DateTimeKind.Local).AddTicks(1596), + CreatedAt = new DateTime(2023, 11, 21, 10, 3, 33, 369, DateTimeKind.Local).AddTicks(6474), 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" }); @@ -995,21 +1003,21 @@ protected override void BuildModel(ModelBuilder modelBuilder) new { Id = new Guid("a18be9c0-aa65-4af8-bd17-00bd9344e575"), - ConcurrencyStamp = "680bc398-aef8-439a-b268-b7f73588b94c", + ConcurrencyStamp = "12e5e898-54fb-436f-b388-3a86dab13fad", Name = "admin", NormalizedName = "admin" }, new { Id = new Guid("cfafcfcd-d796-43f4-8ac0-ead43bd2f18a"), - ConcurrencyStamp = "ccfce868-876f-4240-abd0-3a0c4893eeb7", + ConcurrencyStamp = "661a3ba6-1d96-4fee-a6c3-c6bb4226e93b", Name = "teacher", NormalizedName = "teacher" }, new { Id = new Guid("5d4e4081-91f8-4fc0-b8eb-9860b7849604"), - ConcurrencyStamp = "51bf1f0f-5f05-473f-a48b-b102f8f06272", + ConcurrencyStamp = "8354d441-e7d9-4c7a-b73d-44bd84e3d088", Name = "student", NormalizedName = "student" }); @@ -1051,6 +1059,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("PubDate") .HasColumnType("datetime"); + b.Property("UpdateAt") + .HasColumnType("datetime"); + b.HasKey("Id"); b.HasIndex("AuthorId"); @@ -1195,7 +1206,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { Id = new Guid("d1f771da-b318-42f8-a003-5a15614216f5"), AccessFailedCount = 0, - ConcurrencyStamp = "f1c303ad-8432-4bb0-be7a-43d59b2c6dab", + ConcurrencyStamp = "d22c9b5e-0177-4807-ac36-e61bb86cc5f5", DateOfBirth = new DateTime(2002, 3, 18, 0, 0, 0, 0, DateTimeKind.Local), Email = "admin@gmail.com", EmailConfirmed = true, @@ -1205,7 +1216,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) LockoutEnabled = false, NormalizedEmail = "onionwebdev@gmail.com", NormalizedUserName = "admin", - PasswordHash = "AQAAAAEAACcQAAAAEGRCels5gTIO3nU1TVxHwe0txuW6KfZFFUojWI8PuPulbQk5JmdHXTmg6aLYNm8WMQ==", + PasswordHash = "AQAAAAEAACcQAAAAEFIJwgq3eV+hZm2d+7apMkFyGpxUYooCdajUXUKqWLSUwBa69VQf3AtsTvTaradpQQ==", PhoneNumberConfirmed = false, SecurityStamp = "", TwoFactorEnabled = false, @@ -1625,10 +1636,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("VNH.Domain.QuestionTag", b => { - b.HasOne("VNH.Domain.Question", "IdNavigation") - .WithOne("QuestionTag") - .HasForeignKey("VNH.Domain.QuestionTag", "Id") - .IsRequired() + b.HasOne("VNH.Domain.Question", "Question") + .WithMany("QuestionTag") + .HasForeignKey("QuestionId") .HasConstraintName("FK__QuestionTag__Id__2739D489"); b.HasOne("VNH.Domain.Tag", "Tag") @@ -1636,7 +1646,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("TagId") .HasConstraintName("FK__QuestionT__TagId__2645B050"); - b.Navigation("IdNavigation"); + b.Navigation("Question"); b.Navigation("Tag"); }); diff --git a/VNH.Infrastructure/Presenters/ChatSignalR.cs b/VNH.Infrastructure/Presenters/ChatSignalR.cs index 17f9d51..a12adf4 100644 --- a/VNH.Infrastructure/Presenters/ChatSignalR.cs +++ b/VNH.Infrastructure/Presenters/ChatSignalR.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.SignalR; +using VNH.Application.DTOs.Catalog.Forum.Answer; using VNH.Application.DTOs.Catalog.Posts; namespace VNH.Infrastructure.Presenters @@ -10,5 +11,11 @@ public async Task SendComment(CommentPostDto comment) // Broadcast the comment to all connected clients await Clients.All.SendAsync("ReceiveComment", comment); } + + public async Task SendAnswer(AnswerQuestionDto comment) + { + + await Clients.All.SendAsync("ReceiveAnswer", comment); + } } } diff --git a/VNH.Infrastructure/Presenters/DbContext/VietNamHistoryContext.cs b/VNH.Infrastructure/Presenters/DbContext/VietNamHistoryContext.cs index 13414bb..9b80fea 100644 --- a/VNH.Infrastructure/Presenters/DbContext/VietNamHistoryContext.cs +++ b/VNH.Infrastructure/Presenters/DbContext/VietNamHistoryContext.cs @@ -437,10 +437,9 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { entity.Property(e => e.Id).ValueGeneratedNever(); - entity.HasOne(d => d.IdNavigation) - .WithOne(p => p.QuestionTag) - .HasForeignKey(d => d.Id) - .OnDelete(DeleteBehavior.ClientSetNull) + entity.HasOne(d => d.Question) + .WithMany(p => p.QuestionTag) + .HasForeignKey(d => d.QuestionId) .HasConstraintName("FK__QuestionTag__Id__2739D489"); entity.HasOne(d => d.Tag) diff --git a/VNH.WebAPi/Controllers/AnswerController.cs b/VNH.WebAPi/Controllers/AnswerController.cs new file mode 100644 index 0000000..1862dc0 --- /dev/null +++ b/VNH.WebAPi/Controllers/AnswerController.cs @@ -0,0 +1,110 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Security.Claims; +using VNH.Application.DTOs.Catalog.Forum.Answer; +using VNH.Application.DTOs.Catalog.Posts; +using VNH.Application.Interfaces.Catalog.Forum; + +namespace VNH.WebAPi.Controllers +{ + + + [Route("Answer")] + [ApiController] + public class AnswerController : ControllerBase + { + private readonly IAnswerService _answerService; + + public AnswerController(IAnswerService answerService) + { + _answerService = answerService; + } + + + [HttpGet] + public async Task GetAnswers(string questionId) + { + var result = await _answerService.GetAnswer(questionId); + return result is null ? BadRequest(result) : Ok(result); + } + + [HttpPost()] + [Authorize] + public async Task CreateAnswer(AnswerQuestionDto answer) + { + var result = await _answerService.CreateAnswer(answer); + return result is null ? BadRequest(result) : Ok(result); + } + + [HttpPut] + [Authorize] + public async Task UpdateAnswer(AnswerQuestionDto answer) + { + var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; + if (id == null || !id.Equals(answer.AuthorId.ToString())) + { + return BadRequest(); + } + var result = await _answerService.UpdateAnswer(answer); + return result is null ? BadRequest(result) : Ok(result); + } + [HttpDelete] + [Authorize] + public async Task DeleteAnswer(string idAnswer) + { + var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; + if (id == null || !id.Equals(id)) + { + return BadRequest(); + } + var result = await _answerService.DeteleAnswer(idAnswer); + return result is null ? BadRequest(result) : Ok(result); + } + + + [HttpPost("SubAnswer")] + [Authorize] + public async Task CreateSubAnswer(SubAnswerQuestionDto subAnswer) + { + var result = await _answerService.CreateSubAnswer(subAnswer); + return result is null ? BadRequest(result) : Ok(result); + } + + [HttpPut("SubAnswer")] + [Authorize] + public async Task UpdateSubAnswer(SubAnswerQuestionDto subAnswer) + { + var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; + if (id == null || !id.Equals(subAnswer.AuthorId.ToString())) + { + return BadRequest(); + } + var result = await _answerService.UpdateSubAnswer(subAnswer); + return result is null ? BadRequest(result) : Ok(result); + } + + + [HttpDelete] + [Authorize] + public async Task DeleteSubAnswer(string idSubAnswer) + { + var id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; + if (id == null || !id.Equals(id)) + { + return BadRequest(); + } + var result = await _answerService.DeteleSubAnswer(idSubAnswer); + return result is null ? BadRequest(result) : Ok(result); + } + + [HttpPost("Vote")] + [Authorize] + public async Task Vote([FromForm] AnswerFpkDto answerFpk) + { + var result = await _answerService.ConfirmOrNoConfirm(answerFpk); + return result is null ? BadRequest(result) : Ok(result); + } + + + } +} diff --git a/VNH.WebAPi/Controllers/DocumentController.cs b/VNH.WebAPi/Controllers/DocumentController.cs index 1c025e4..8f52516 100644 --- a/VNH.WebAPi/Controllers/DocumentController.cs +++ b/VNH.WebAPi/Controllers/DocumentController.cs @@ -61,7 +61,7 @@ public async Task Delete(string Id) [HttpGet("Save")] [Authorize] - public async Task GetSaveDocs([FromQuery] DocumentFpkDto docsFpk) + public async Task GetSaveDocs([FromForm] DocumentFpkDto docsFpk) { var result = await _documentService.GetSave(docsFpk); return result is null ? BadRequest(result) : Ok(result); diff --git a/VNH.WebAPi/Controllers/QuestionController.cs b/VNH.WebAPi/Controllers/QuestionController.cs new file mode 100644 index 0000000..137d0d4 --- /dev/null +++ b/VNH.WebAPi/Controllers/QuestionController.cs @@ -0,0 +1,103 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using System.Security.Claims; +using VNH.Application.DTOs.Catalog.Forum.Question; +using VNH.Application.DTOs.Catalog.Posts; +using VNH.Application.Interfaces.Catalog.Forum; +using VNH.Application.Interfaces.Posts; +using VNH.Infrastructure.Implement.Catalog.Posts; + +namespace VNH.WebAPi.Controllers +{ + + [Route("Question")] + [ApiController] + public class QuestionController : ControllerBase + { + + private readonly IQuestionService _questionService; + + public QuestionController(IQuestionService questionService) + { + _questionService = questionService; + } + + + + [HttpPost] + [Authorize] + [Consumes("multipart/form-data")] + public async Task CreateQuestion([FromForm] CreateQuestionDto requestDto) + { + var result = await _questionService.Create(requestDto, User.Identity.Name); + return result is null ? BadRequest(result) : Ok(result); + } + + + + [HttpPut] + [Authorize] + [Consumes("multipart/form-data")] + public async Task UpdateQuestion([FromForm] CreateQuestionDto requestDto) + { + var result = await _questionService.Update(requestDto, User.Identity.Name); + return result == null ? BadRequest(result) : Ok(result); + } + + + [HttpGet("{id}")] + public async Task Detail(string id) + { + var result = await _questionService.Detail(id); + return result is null ? BadRequest(result) : Ok(result); + } + + + + [HttpGet] + public async Task Index() + { + var result = await _questionService.GetAll(); + return result is null ? BadRequest(result) : Ok(result); + } + + [HttpDelete] + public async Task Delete(string Id) + { + var result = await _questionService.Delete(Id, User.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? ""); + return result is null ? BadRequest(result) : Ok(result); + } + + + [HttpGet("Save")] + [Authorize] + public async Task GetSaveQuestion([FromForm] QuestionFpkDto questionFpk) + { + var result = await _questionService.GetSave(questionFpk); + return result is null ? BadRequest(result) : Ok(result); + } + [HttpPost("Save")] + [Authorize] + public async Task Save([FromForm] QuestionFpkDto questionFpk) + { + var result = await _questionService.AddOrRemoveSaveQuestion(questionFpk); + return result is null ? BadRequest(result) : Ok(result); + } + + + [HttpGet("AllTag")] + public async Task GetAllTag( int numberTag) + { + var result = await _questionService.GetAllTag(numberTag); + return result is null ? BadRequest(result) : Ok(result); + } + + [HttpGet("FindByTag")] + public async Task GetQuestionByTag(string tag) + { + var result = await _questionService.GetQuestionByTag(tag); + return result is null ? BadRequest(result) : Ok(result); + } + + } +}