public async Task <ActionResult <TenantReadDto> > GetTenantById(Guid tenantId) { var tenantFromRepo = await _tenantsRepo.GetTenantById(tenantId); if (tenantFromRepo == null) { return(NotFound()); } return(Ok(_mapper.Map <TenantReadDto>(tenantFromRepo))); }
public async Task <ActionResult <ClientReadDto> > CreateClient(ClientCreateDto clientCreateDto) { if (await _tenantsRepo.GetTenantById(clientCreateDto.TenantId) == null) { return(BadRequest(new { Error = "Invalid Tenant Id" })); } var clientToAdd = _mapper.Map <Client>(clientCreateDto); var newClient = await _clientsRepo.CreateClient(clientToAdd); return(CreatedAtRoute(nameof(GetClientById), new { newClient.ClientId }, _mapper.Map <ClientReadDto>(newClient))); }
public IEnumerable <Tenant> GetUser(int id) { return(_repo.GetTenantById(id)); }