public async Task<Maybe<Department>> Handle(GetDepartmentById request, CancellationToken cancellationToken) { var chosenDepartment= await _context.Departments .Where(x => x.Id == request.Id) .Select(d => _mapper.Map<Department>(d)) .FirstOrDefaultAsync(); if (chosenDepartment == null) { _logger.LogError($"There is not a department with the Id '{request.Id}'..."); } return chosenDepartment != null ? Maybe<Department>.From(chosenDepartment) : Maybe<Department>.None; }
public object Get(GetDepartmentById request) { return(WithDb(db => Logic.GetById(request.Id))); }