Skip to content

Commit

Permalink
#40 | Building history news
Browse files Browse the repository at this point in the history
  • Loading branch information
LuongXuanNhat committed Dec 5, 2023
1 parent b77cb28 commit 0749358
Show file tree
Hide file tree
Showing 32 changed files with 6,246 additions and 143 deletions.
8 changes: 4 additions & 4 deletions VNH.Application/Common/Contants/SystemConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ public static class SystemConstants
public const string Token = "Token";
public const string BaseAddress = "BaseAddress";

public const string UrlWeb = "https://vuanhpham25-001-site1.gtempurl.com/";
public const string ConnectString = "Data Source=SQL5106.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;User Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai";
//public const string UrlWeb = "https://vuanhpham25-001-site1.gtempurl.com/";
//public const string ConnectString = "Data Source=SQL5106.site4now.net;Initial Catalog=db_aa121e_vuanhpham25;User Id=db_aa121e_vuanhpham25_admin;Password=30102002Mai";

//public const string UrlWeb = "https://localhost:7138/";
//public const string ConnectString = "Data Source=.;Initial Catalog=VietNamHistory;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;";
public const string UrlWeb = "https://localhost:7138/";
public const string ConnectString = "Data Source=.;Initial Catalog=VietNamHistory;Integrated Security=True;Encrypt=true;TrustServerCertificate=true;";
}
}
3 changes: 3 additions & 0 deletions VNH.Application/DTOs/Catalog/Forum/Answer/AnswerFpkDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ namespace VNH.Application.DTOs.Catalog.Forum.Answer
{
public class AnswerFpkDto
{
public string QuestionId { get; set; } = string.Empty;
public string AnswerId { get; set; } = string.Empty;
public string UserId { get; set; } = string.Empty;
public string QuestionUserId { get; set; } = string.Empty;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public class AnswerQuestionDto

public Guid? Id { get; set; } = Guid.NewGuid();
public Guid? AuthorId { get; set; }

public string QuestionId { get; set; } = string.Empty;
public UserShortDto? UserShort { get; set; }
public string Content { get; set; } = String.Empty;
public DateTime? CreatedAt { get; set; } = DateTime.Now;
public DateTime? CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public bool Confirm { get; set; } = false;
public bool MostConfirm { get; set; } = false;
public int VoteNumber { get; set; } = 0;
public List<SubAnswerQuestionDto>? SubAnswer { get; set; } = new();

}
Expand All @@ -27,7 +27,7 @@ public class SubAnswerQuestionDto
public Guid AuthorId { get; set; }
public string Content { get; set; } = string.Empty;
[Column(TypeName = "datetime")]
public DateTime? CreatedAt { get; set; } = DateTime.Now;
public DateTime? CreatedAt { get; set; }
[Column(TypeName = "datetime")]
public DateTime? UpdatedAt { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions VNH.Application/Interfaces/Catalog/Forum/IAnswerService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using VNH.Application.DTOs.Catalog.Forum.Answer;
using VNH.Application.DTOs.Common;
using VNH.Application.DTOs.Common.ResponseNotification;
using VNH.Domain;

Expand All @@ -18,8 +19,7 @@ public interface IAnswerService
Task<ApiResult<string>> UpdateSubAnswer(SubAnswerQuestionDto answer);
Task<ApiResult<string>> DeteleSubAnswer(string id);

Task<ApiResult<int>> ConfirmOrNoConfirm(AnswerFpkDto answerFpk);


Task<ApiResult<NumberReponse>> ConfirmedByQuestioner(string answerId);
Task<ApiResult<NumberReponse>> VoteConfirmByUser(AnswerFpkDto answer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using VNH.Domain;

namespace VNH.Application.Interfaces.Catalog.NewsHistory
{
public interface INewsService
{
Task<List<News>> GetNews(string url);
}
}
1 change: 1 addition & 0 deletions VNH.Domain/Entities/Answer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public Answer()
public DateTime? UpdatedAt { get; set; }
public bool? Confirm { get; set; }
public bool? MostConfirm { get; set; }
public bool IsDeleted { get; set; } = false;

[ForeignKey("AuthorId")]
[InverseProperty("Answers")]
Expand Down
1 change: 1 addition & 0 deletions VNH.Domain/Entities/AnswerVote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public partial class AnswerVote
public Guid Id { get; set; }
public Guid? AnswerId { get; set; }
public Guid? UserId { get; set; }
public Guid? QuestionId { get; set; }

[ForeignKey("AnswerId")]
[InverseProperty("AnswerVotes")]
Expand Down
1 change: 1 addition & 0 deletions VNH.Domain/Entities/Course.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public Course()
[Column(TypeName = "datetime")]
public DateTime? UpdatedAt { get; set; }
public string Image { get; set; } = string.Empty;
public bool IsDeleted { get; set; } = false;
[ForeignKey("UserId")]
[InverseProperty("Courses")]
public virtual User User { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion VNH.Domain/Entities/Document.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Document()
[StringLength(500)]
public string Description { get; set; }
public string SubId { get; set; }

public bool IsDeleted { get; set; } = false;
public string FileName { get; set; }
[StringLength(255)]
[Unicode(false)]
Expand Down
2 changes: 2 additions & 0 deletions VNH.Domain/Entities/Lesson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public partial class Lesson
public string Description { get; set; }
public Guid? CourseId { get; set; }
public Guid? ExerciseId { get; set; }
public bool IsDeleted { get; set; } = false;

[ForeignKey("CourseId")]
[InverseProperty("Lessons")]
public virtual Course Course { get; set; }
[InverseProperty("IdNavigation")]
public virtual Exercise Exercise { get; set; }

}
}
4 changes: 0 additions & 4 deletions VNH.Domain/Entities/News.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ public partial class News
[Key]
public Guid Id { get; set; }
[Required]
[StringLength(255)]
public string Title { get; set; }
[Column(TypeName = "text")]
public string Description { get; set; } = string.Empty;
[Column(TypeName = "text")]
public string Image { get; set; } = string.Empty;
[Column(TypeName = "datetime")]
public DateTime? CreatedAt { get; set; }
[Required]
[StringLength(255)]
[Unicode(false)]
public string Url { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions VNH.Domain/Entities/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public Post()
public Guid UserId { get; set; }
public string Image { get; set; } = string.Empty;
public int ViewNumber { get; set; }
public bool IsDeleted { get; set; } = false;

[ForeignKey("TopicId")]
[InverseProperty("Posts")]
Expand Down
4 changes: 3 additions & 1 deletion VNH.Domain/Entities/Question.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public Question()

[Column(TypeName = "datetime")]
public DateTime CreatedAt { get; set; }

public bool IsDeleted { get; set; } = false;



[ForeignKey("AuthorId")]
[InverseProperty("Questions")]
Expand Down
1 change: 1 addition & 0 deletions VNH.Domain/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public User()
public Gender Gender { get; set; }
public string Image { get; set; } = string.Empty;
public string NumberConfirm { get; set; } // Confirm Email
public bool IsDeleted { get; set; } = false;
[InverseProperty("User")]
public virtual ICollection<AnswerVote> AnswerVotes { get; set; }
[InverseProperty("Author")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public AccountService(VietNamHistoryContext context,
public async Task<ApiResult<string>> Authenticate(LoginRequest request)
{
var user = await _userManager.FindByEmailAsync(request.Email);
if(user != null && user.IsDeleted)
{
user = null;
}

var errorMessages = new Dictionary<Func<bool>, string>
{
Expand Down Expand Up @@ -88,7 +92,8 @@ public async Task<string> GetToken(User user)
new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
new Claim(ClaimTypes.Email,user.Email),
new Claim(ClaimTypes.Role, string.Join(";",roles)),
new Claim(ClaimTypes.Name, user.UserName),
new Claim(ClaimTypes.Name, user.Email),
new Claim(ClaimTypes.Surname, user.Fullname),
};
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Tokens:Key"]));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
Expand Down
Loading

0 comments on commit 0749358

Please sign in to comment.