fix bugs , push befor start fixing
parent
1fbf37dd82
commit
81762ecb64
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"ConnectionStrings": {
|
||||
"PostgresServer": "Host=185.220.227.123;port=5432;Username=postgres;Password=ub0J7sFFThkSBmkc0TzSKsCfheRnQpyu;Database=BrizcoDB",
|
||||
"Postgres": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Load Balance Hosts=true;Target Session Attributes=primary;Application Name=iGLS",
|
||||
"MartenDB": "Host=pg-0,pg-1;Username=igarsonAgent;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoMartenDB;"
|
||||
"Postgres": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoDB;Application Name=BrizCo",
|
||||
"MartenDB": "Host=pg-0;Username=postgres;Password=xHTpBf4wC+bBeNg2pL6Ga7VEWKFJx7VPEUpqxwPFfOc2YYTVwFQuHfsiqoVeT9+6;Database=BrizcoMartenDB;"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
<Using Include="Brizco.Domain.Dtos.RequestDtos" />
|
||||
<Using Include="Brizco.Domain.Entities" />
|
||||
<Using Include="Brizco.Domain.Entities.Users" />
|
||||
<Using Include="Brizco.Domain.Enums" />
|
||||
<Using Include="Brizco.Domain.Models.Settings" />
|
||||
<Using Include="Brizco.Infrastructure" />
|
||||
<Using Include="Brizco.Repository" />
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Brizco.Common.Models.Claims;
|
||||
using Brizco.Domain.Enums;
|
||||
using Brizco.Domain.Enums;
|
||||
|
||||
namespace Brizco.Api.Controllers;
|
||||
|
||||
|
@ -7,7 +6,6 @@ public class ActivityController : ICarterModule
|
|||
{
|
||||
public void AddRoutes(IEndpointRouteBuilder app)
|
||||
{
|
||||
|
||||
var group = app.NewVersionedApi("Activity")
|
||||
.MapGroup($"api/activity")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser());
|
||||
|
|
|
@ -13,8 +13,17 @@ public class NotificationController : ICarterModule
|
|||
.RequireAuthorization(builder=>builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("{id}/read",ReadNotificationAsync)
|
||||
.WithDisplayName("Read Notification")
|
||||
.WithDescription("Read notification , by JWT user id")
|
||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser())
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
}
|
||||
|
||||
private async Task<IResult> ReadNotificationAsync([FromRoute] Guid id, [FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new ReadNotificationCommand(id), cancellationToken));
|
||||
|
||||
private async Task<IResult> GetUserNotificationsAsync([FromQuery] int page, [FromQuery] int count,
|
||||
[FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new GetNotificationsQuery(page, count), cancellationToken));
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
7bec0081-0f19-4cf7-84a9-7deed79e4f61
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--<PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
@ -12,9 +12,9 @@
|
|||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.6.2" />
|
||||
</ItemGroup>-->
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!--<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
</ItemGroup>-->
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="MD.PersianDateTime.Standard" />
|
||||
|
|
|
@ -12,7 +12,7 @@ public class ShiftPlanService(IMediator mediator, IActivityService activityServi
|
|||
{
|
||||
var shiftPlan = await mediator.Send(createShiftPlanCommand, cancellationToken);
|
||||
await activityService.CreateActivitiesByShiftPlan(shiftPlan.Id, cancellationToken);
|
||||
await mediator.Send(new CreateShiftPlanNotificationsCommand(shiftPlan.Id), cancellationToken);
|
||||
await mediator.Send(new CreateShiftPlanNotificationsCommand(shiftPlan.Id,true), cancellationToken);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--<PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
@ -13,10 +13,10 @@
|
|||
<PackageReference Include="MediatR" Version="12.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.6" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||
</ItemGroup>-->
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<!--<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<LangVersion>10</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
@ -32,7 +32,7 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="4.1.0" />
|
||||
</ItemGroup>
|
||||
</ItemGroup>-->
|
||||
|
||||
|
||||
<Target Name="Mapster">
|
||||
|
|
|
@ -9,6 +9,7 @@ using Brizco.Domain.Entities.Complexes;
|
|||
using Brizco.Domain.Entities.Shifts;
|
||||
using Brizco.Domain.Entities.Tasks;
|
||||
using Mapster.Models;
|
||||
using Task = Brizco.Domain.Entities.Tasks.Task;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ using Brizco.Domain.Dtos.SmallDtos;
|
|||
using Brizco.Domain.Entities.Complexes;
|
||||
using Brizco.Domain.Entities.Tasks;
|
||||
using Mapster.Models;
|
||||
using Task = Brizco.Domain.Entities.Tasks.Task;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ using Brizco.Domain.Dtos.SmallDtos;
|
|||
using Brizco.Domain.Entities.Shifts;
|
||||
using Brizco.Domain.Entities.Tasks;
|
||||
using Mapster.Models;
|
||||
using Task = Brizco.Domain.Entities.Tasks.Task;
|
||||
|
||||
namespace Brizco.Domain.Mappers
|
||||
{
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
using Brizco.Domain.Dtos.LargeDtos;
|
||||
using Brizco.Domain.Entities.Complexes;
|
||||
using Brizco.Domain.Entities.ShiftPlans;
|
||||
using Brizco.Domain.Entities.Tasks;
|
||||
using MD.PersianDateTime.Standard;
|
||||
using Brizco.Domain.Entities.Tasks;
|
||||
using Task = Brizco.Domain.Entities.Tasks.Task;
|
||||
|
||||
namespace Brizco.Domain;
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<Using Include="Brizco.Domain.Entities.ShiftPlans" />
|
||||
<Using Include="Brizco.Domain.Entities.Shifts" />
|
||||
<Using Include="Brizco.Domain.Entities.Users" />
|
||||
<Using Include="Brizco.Domain.MartenEntities.Notifications" />
|
||||
<Using Include="Brizco.Repository.Abstracts" />
|
||||
<Using Include="Brizco.Repository.Extensions" />
|
||||
<Using Include="Brizco.Repository.Repositories.Marten" />
|
||||
|
|
|
@ -2,26 +2,22 @@
|
|||
|
||||
namespace Brizco.Repository.MartenHandlers.Notifications;
|
||||
|
||||
public class ReadNotificationCommandHandler : IRequestHandler<ReadNotificationCommand, bool>
|
||||
public class ReadNotificationCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService) : IRequestHandler<ReadNotificationCommand, bool>
|
||||
{
|
||||
private readonly IMartenRepositoryWrapper _martenRepositoryWrapper;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
|
||||
public ReadNotificationCommandHandler(IMartenRepositoryWrapper martenRepositoryWrapper, ICurrentUserService currentUserService)
|
||||
{
|
||||
_martenRepositoryWrapper = martenRepositoryWrapper;
|
||||
_currentUserService = currentUserService;
|
||||
}
|
||||
public async Task<bool> Handle(ReadNotificationCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var notification = await _martenRepositoryWrapper.SetRepository<Notification>()
|
||||
var notification = await martenRepositoryWrapper.SetRepository<Notification>()
|
||||
.GetEntityAsync(request.Id, cancellationToken);
|
||||
if (notification == null)
|
||||
throw new BaseApiException(ApiResultStatusCode.NotFound,"Notification not found");
|
||||
throw new BaseApiException(ApiResultStatusCode.NotFound, "Notification not found");
|
||||
if (!Guid.TryParse(currentUserService.UserId, out Guid userId))
|
||||
throw new BaseApiException(ApiResultStatusCode.NotFound, "User id is null");
|
||||
if (notification.UserId != userId)
|
||||
throw new BaseApiException(ApiResultStatusCode.NotFound, "This is not your notification");
|
||||
|
||||
notification.IsRead = true;
|
||||
|
||||
await _martenRepositoryWrapper.SetRepository<Notification>()
|
||||
await martenRepositoryWrapper.SetRepository<Notification>()
|
||||
.AddOrUpdateEntityAsync(notification, cancellationToken);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue