Skip to content

Commit

Permalink
Merge pull request #909 from ita-social-projects/develop
Browse files Browse the repository at this point in the history
Stage update (#908)
  • Loading branch information
Adeodonne authored Dec 3, 2023
2 parents daea670 + ed8c6bc commit a9ec0aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
using AutoMapper;
using FluentResults;
using MediatR;
using Microsoft.Extensions.Localization;
using Streetcode.BLL.DTO.Streetcode;
using Streetcode.BLL.Interfaces.Logging;
using Streetcode.BLL.MediatR.Streetcode.Streetcode.GetAllShort;
using Streetcode.BLL.SharedResource;
using Streetcode.DAL.Entities.Streetcode;
using Streetcode.DAL.Enums;
using Streetcode.DAL.Repositories.Interfaces.Base;

namespace Streetcode.BLL.MediatR.Streetcode.Streetcode.GetCount
Expand All @@ -31,7 +26,17 @@ public GetStreetcodesCountHander(IRepositoryWrapper repositoryWrapper, IMapper m

public async Task<Result<int>> Handle(GetStreetcodesCountQuery request, CancellationToken cancellationToken)
{
var streetcodes = await _repositoryWrapper.StreetcodeRepository.GetAllAsync();
IEnumerable<StreetcodeContent> streetcodes;

if (request.onlyPublished)
{
streetcodes = await _repositoryWrapper.StreetcodeRepository
.GetAllAsync(s => s.Status == StreetcodeStatus.Published);
}
else
{
streetcodes = await _repositoryWrapper.StreetcodeRepository.GetAllAsync();
}

if (streetcodes != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

namespace Streetcode.BLL.MediatR.Streetcode.Streetcode.GetCount
{
public record GetStreetcodesCountQuery : IRequest<Result<int>>;
public record GetStreetcodesCountQuery(bool onlyPublished) : IRequest<Result<int>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public async Task<IActionResult> GetAllCatalog([FromQuery] int page, [FromQuery]
}

[HttpGet]
public async Task<IActionResult> GetCount()
public async Task<IActionResult> GetCount([FromQuery] bool? onlyPublished)
{
return HandleResult(await Mediator.Send(new GetStreetcodesCountQuery()));
return HandleResult(await Mediator.Send(new GetStreetcodesCountQuery(onlyPublished ?? false)));
}

[HttpGet("{url}")]
Expand Down

0 comments on commit a9ec0aa

Please sign in to comment.