public async Task <ViewModels.DomainViewModel> QueryForDomainDataAsync(string domainName) { if (!Umbler.Infra.CrossCutting.StringHelper.IsValidDomain(domainName)) { return(new ViewModels.DomainViewModel() { Name = "Dominío Invalído" }); } var domain = await _domainRepository.GetByDomainNameAsync(domainName); if (domain == null) { domain = await FillDomainDataAsync(domainName); _domainRepository.Add(domain); } if (DateTime.Now.Subtract(domain.UpdatedAt).TotalMinutes > domain.Ttl) { var refreshedDomain = await FillDomainDataAsync(domainName); domain.HostedAt = refreshedDomain.HostedAt; domain.Name = refreshedDomain.Name; domain.Ip = refreshedDomain.Ip; domain.WhoIs = refreshedDomain.WhoIs; domain.UpdatedAt = refreshedDomain.UpdatedAt; domain.Ttl = refreshedDomain.Ttl; _domainRepository.Update(); } return(Adapters.DomainEntityToDomainViewModel.GetViewModel(domain)); }