Skip to content

Commit

Permalink
Fix bug14 (#122)
Browse files Browse the repository at this point in the history
* feat(Graph) : add get categories without pagination

* feat(Graph) : add get categories without pagination
  • Loading branch information
mahdijafariii authored Sep 9, 2024
1 parent f767e02 commit 67b1a70
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ public async Task<IActionResult> GetCategories(int pageNumber = 0, int pageSize
var paginatedCategories = await _categoryService.GetAllCategoriesAsync(pageNumber, pageSize);
return Ok(paginatedCategories);
}

[Authorize(Policy = "silver")]
[HttpGet("all-category-without-pagination")]
public async Task<IActionResult> GetAllCategoriesWithOutPagination()
{
var categories = await _categoryService.GetAllCategoriesWithoutPaginationAsync();
return Ok(categories);
}

[Authorize(Policy = "silver")]
[HttpPost]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<IActionResult> DeleteUser(Guid id)
return Ok(new { message = "User deleted successfully." });
}

[Authorize(Roles = "admin")]
[Authorize(Policy = "gold")]
[HttpPut("users/{id}")]
public async Task<IActionResult> UpdateUser(Guid id, [FromBody] UpdateAdminDto updateAdminDto)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async Task<IActionResult> UploadImage(IFormFile file)
return Ok(new { massage = "Uploaded successfully." });
}

[Authorize(Policy = "gold")]
[Authorize(Policy = "bronze")]
[HttpPut("update-user")]
public async Task<IActionResult> UpdateUser([FromBody] UpdateUserDto updateUserDto)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using AnalysisData.Models.GraphModel.Category;

namespace AnalysisData.Dtos.GraphDto.CategoryDto;

public class GetAllCategoryDto
{
public IEnumerable<Category> Categories;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public EmailService(IConfiguration configuration)
public async Task SendPasswordResetEmail(string toEmail, string resetLink, string token)
{

string htmlTemplatePath = @"Assets/email-template.html";
string htmlTemplatePath = @"email-template.html";
string htmlContent = File.ReadAllText(htmlTemplatePath);
string linkWithToken = $"{resetLink}?token={token}&email={toEmail}";
htmlContent = htmlContent.Replace("https://myfronti.abriment.com?token={token}&email={email}", linkWithToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public interface ICategoryService
Task UpdateAsync(UpdateCategoryDto newCategoryDto);
Task DeleteAsync(int id);
Task<Category> GetByIdAsync(int id);
Task<GetAllCategoryDto> GetAllCategoriesWithoutPaginationAsync();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public async Task<PaginationCategoryDto> GetAllCategoriesAsync(int pageNumber, i

return new PaginationCategoryDto(paginatedItems, pageNumber, totalCount);
}

public async Task<GetAllCategoryDto> GetAllCategoriesWithoutPaginationAsync()
{
var allCategoryDto = await _categoryRepository.GetAllAsync();
return new GetAllCategoryDto() { Categories = allCategoryDto};
}

public async Task AddAsync(NewCategoryDto categoryDto)
{
Expand Down

0 comments on commit 67b1a70

Please sign in to comment.