feat: add a type of occupation update
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 2m41s
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 2m41s
This commit is contained in:
parent
af7e370494
commit
9b0e5a3f15
@ -0,0 +1,9 @@
|
|||||||
|
using MediatR;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Application.Cqrs.TypeOfOccupation.Commands.UpdateTypeOfOccupation;
|
||||||
|
|
||||||
|
public class UpdateTypeOfOccupationCommand : IRequest
|
||||||
|
{
|
||||||
|
public required int Id { get; set; }
|
||||||
|
public required string FullName { get; set; }
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MediatR;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Mirea.Api.DataAccess.Application.Common.Exceptions;
|
||||||
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
||||||
|
|
||||||
|
namespace Mirea.Api.DataAccess.Application.Cqrs.TypeOfOccupation.Commands.UpdateTypeOfOccupation;
|
||||||
|
|
||||||
|
public class UpdateTypeOfOccupationCommandHandler(ITypeOfOccupationDbContext dbContext) : IRequestHandler<UpdateTypeOfOccupationCommand>
|
||||||
|
{
|
||||||
|
public async Task Handle(UpdateTypeOfOccupationCommand request, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var entity = await dbContext.TypeOfOccupations.FirstOrDefaultAsync(t => t.Id == request.Id, cancellationToken: cancellationToken) ?? throw new NotFoundException(typeof(Domain.Schedule.TypeOfOccupation), nameof(Domain.Schedule.TypeOfOccupation.Id), request.Id);
|
||||||
|
|
||||||
|
entity.FullName = request.FullName;
|
||||||
|
|
||||||
|
await dbContext.SaveChangesAsync(cancellationToken);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user