public async Task <CompanyDto> Get(int id, int userId)
        {
            var company = await _companiesRepository.GetAsync(id, userId);

            if (company == null)
            {
                throw new ValidationException(Messages.CompanyDoesNotExist, nameof(Messages.CompanyDoesNotExist));
            }

            var companyDto = new CompanyDto()
            {
                Address            = company.Address,
                BrandName          = company.BrandName,
                Logo               = company.Logo,
                Name               = company.Name,
                RegistrationNumber = company.RegistrationNumber,
                VatNumber          = company.VatNumber
            };

            return(companyDto);
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> GetByUserId(string userId)
        {
            Guid      userIdGuid = Guid.Parse(userId);
            Companies dbCompany  = await _companiesRepository.GetAsync(userIdGuid);

            if (dbCompany == null)
            {
                return(NotFound());
            }
            Company company = dbCompany.Map <Companies, Company>();

            return(Ok(company));
        }
Esempio n. 3
0
        public async Task <EmployeeDto> Get(int id, int userId)
        {
            var employee = await _employeesRepository.GetAsync(id);

            if (employee == null)
            {
                throw new ValidationException(Messages.EmployeeDoesNotExist, nameof(Messages.EmployeeDoesNotExist));
            }

            var company = await _companiesRepository.GetAsync(employee.CompanyId, userId);

            if (company == null)
            {
                throw new ValidationException(Messages.EmployeeDoesNotExist, nameof(Messages.EmployeeDoesNotExist));
            }

            var employeeDto = new EmployeeDto()
            {
                CompanyId = employee.CompanyId,
                Position  = employee.Position
            };

            return(employeeDto);
        }