Polianin Nikita
4fe25005af
All checks were successful
.NET Test Pipeline / build-and-test (pull_request) Successful in 1m19s
20 lines
891 B
C#
20 lines
891 B
C#
using MediatR;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Mirea.Api.DataAccess.Application.Common.Exceptions;
|
|
using Mirea.Api.DataAccess.Application.Interfaces.DbContexts.Schedule;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Mirea.Api.DataAccess.Application.Cqrs.Faculty.Commands.UpdateFaculty;
|
|
|
|
public class UpdateFacultyCommandHandler(IFacultyDbContext dbContext) : IRequestHandler<UpdateFacultyCommand>
|
|
{
|
|
public async Task Handle(UpdateFacultyCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var entity = await dbContext.Faculties.FirstOrDefaultAsync(f => f.Id == request.Id, cancellationToken: cancellationToken) ?? throw new NotFoundException(typeof(Domain.Schedule.Faculty), nameof(Domain.Schedule.Faculty.Id), request.Id);
|
|
|
|
entity.CampusId = request.CampusId;
|
|
|
|
await dbContext.SaveChangesAsync(cancellationToken);
|
|
}
|
|
} |