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 { 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); } }