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);
 }
Ejemplo n.º 2
0
            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));
            }
Ejemplo n.º 3
0
            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));
                }
            }