public async Task <IActionResult> CreateCompanyToUser([FromBody] CreateCompanyDto dto) { var user = await _userManager.GetByIdentityAsync(this); if (user == null) { return(Unauthorized()); } var mappedCompany = _mapper.Map <CreateCompanyDto, Company>(dto); var createdCompany = await _userCompanyService.AddCompanyToUserAsync(user, mappedCompany); if (createdCompany == null) { return(BadRequest("Can't create company")); } return(Created(Url.GetEntityByIdUrl(nameof(Get), "Company", createdCompany.Id.ToString(), Request.Scheme), _mapper.Map <Company, CompanyDto>(createdCompany))); }