Beispiel #1
0
        public async Task <ActionResult <IEnumerable <EmployeeDto> > > GetEmployeesForCompany(Guid companyId,
                                                                                              [FromQuery] EmployeeDtoParameters parameters)
        {
            if (!await _companyRepositroy.CompanyExistsAsync(companyId))
            {
                return(NotFound());
            }
            var employees = await _companyRepositroy.GetEmployeesAsync(companyId, parameters);

            var employeeDtos = _mapper.Map <IEnumerable <EmployeeDto> >(employees);

            return(Ok(employeeDtos));
        }
Beispiel #2
0
        public async Task <IActionResult> DeleteCompany(Guid companyId)
        {
            var companyEntity = await _companyRepositroy.GetCompanyAsync(companyId);

            if (companyEntity == null)
            {
                return(NotFound());
            }

            await _companyRepositroy.GetEmployeesAsync(companyId, new EmployeeDtoParameters());

            _companyRepositroy.DeleteCompany(companyEntity);

            await _companyRepositroy.SaveAsync();

            return(NoContent());
        }