using AutobusApi.Application.Common.Interfaces; using AutobusApi.Domain.Entities; using MediatR; namespace AutobusApi.Application.Countries.Commands.CreateCountry; public class CreateCountryCommandHandler : IRequestHandler { private readonly IApplicationDbContext _dbContext; public CreateCountryCommandHandler(IApplicationDbContext dbContext) { _dbContext = dbContext; } public async Task Handle( CreateCountryCommand request, CancellationToken cancellationToken) { var country = new Country(); country.Name = request.Name; _dbContext.Countries.Add(country); await _dbContext.SaveChangesAsync(cancellationToken); return country.Id; } }