public async Task<Response<int>> Handle(DeleteDepartmentTypeByIdCommand command, CancellationToken cancellationToken) { var departmentType = await _departmentTypeRepository.GetByIdAsync(command.DepartmentTypeById); if (departmentType == null) throw new ApiException($"Department Type Not Found."); await _departmentTypeRepository.DeleteAsync(departmentType); return new Response<int>(departmentType.DepartmentTypeId); }
public async Task <Response <DepartmentType> > Handle(GetDepartmentTypeByIdQuery query, CancellationToken cancellationToken) { var departmentType = await _departmentTypeRepository.GetByIdAsync(query.DepartmentTypeId); if (departmentType == null) { throw new ApiException($"Department Type Not Found."); } return(new Response <DepartmentType>(departmentType)); }
public async Task <Response <int> > Handle(UpdateDepartmentTypeCommand command, CancellationToken cancellationToken) { var departmentType = await _departmentTypeRepository.GetByIdAsync(command.DepartmentTypeId); if (departmentType == null) { throw new ApiException($"Department Type Not Found."); } else { departmentType.DepartmentTypeId = command.DepartmentTypeId; departmentType.DepartmentTypeName = command.DepartmentTypeName; await _departmentTypeRepository.UpdateAsync(departmentType); return(new Response <int>(departmentType.DepartmentTypeId)); } }