public async Task <ActionResult <int> > GetCompanyNameCount(string companyName) { if (companyName != null && companyName != "" && companyName != " ") { return(Ok(await _tenantRepository.CountWhere(tenant => tenant.CompanyName == companyName))); } else { return(BadRequest("please provide company name")); } }
public async Task <ActionResult <int> > GetUserCount(string tenantId, string userId) { if (await _tenantRepository.GetById(Guid.Parse(tenantId)) == null) { return(BadRequest("Tenant id is not valid")); } if (await _userRepository.GetById(Guid.Parse(userId)) == null) { return(BadRequest("User id is not valid")); } return(await _userRepository.CountWhere(user => user.TenantId == Guid.Parse(tenantId))); }
public async Task <ActionResult <CountDTO> > GetCountDetails(string tenantId) { if (tenantId != null && tenantId != "") { var usersCount = await _userRepository.CountWhere(user => user.TenantId == Guid.Parse(tenantId)); var contactCount = await _contactRepository.CountWhere(contact => contact.User.TenantId == Guid.Parse(tenantId)); var addressCount = await _addressRepository.CountWhere(address => address.Contact.User.TenantId == Guid.Parse(tenantId)); var tenantRecord = await _tenantRepository.GetById(Guid.Parse(tenantId)); var employeeCount = tenantRecord.CompanyStrength; return(Ok(new CountDTO { UserCount = usersCount, ContactCount = contactCount, AddressCount = addressCount, CompanyStrength = employeeCount })); } else { return(BadRequest("Cannot fetch data")); } }