private async Task AddItemToCache(IValidationServiceModel <T> item) { if (!this.CacheServiceIsUsable) { return; } if (item == null) { return; } string permalink = this.GetPermalink(item.ValidatedObject); if (string.IsNullOrWhiteSpace(permalink)) { return; } try { var model = new ValidationCacheServiceModel { Status = item.ValidationStatus }; await this.cacheService.Add(permalink, model); } catch { this.CacheServiceIsUsable = false; } }
private async Task MakeRequest(IValidationServiceModel <string> item) { try { var validatedObject = item.ValidatedObject; if (string.IsNullOrWhiteSpace(validatedObject)) { throw new ApplicationException($"URL address is null or whitespace: '{validatedObject}'."); } using (var client = new HttpClient()) { var response = await client.GetAsync(validatedObject); item.ValidationStatus = this.MapHttpStatusCodeToValidationStatus(response.StatusCode); } } catch (Exception e) { item.ValidationStatus = ValidationStatus.Undefined; item.ValidationException = e; } }