public void Edit(WebpageModel model) { var record = _session.Single <Webpage>(x => x.Id == model.Id); record.Update(model); _session.CommitChanges(); }
public static WebpageViewModel ToViewModel(this WebpageModel model) { if (model == null) { throw new ArgumentNullException(nameof(WebpageViewModel)); } return(new WebpageViewModel { Id = model.Id, Path = model.Path, MaxResponseTime = model.MaxResponseTime, MinResponseTime = model.MinResponseTime, }); }
public async Task AnalyzeAsync(WebpageModel webpage) { var responseTimeArray = new double[NumberOfRequests]; TimeSpan requestTime; for (int i = 0; i < NumberOfRequests; i++) { requestTime = await _httpClientWatcher.GetResponseTimeAsync(webpage.Path); responseTimeArray[i] = requestTime.Milliseconds; } webpage.MinResponseTime = responseTimeArray.Min(); webpage.MaxResponseTime = responseTimeArray.Max(); }
private ContentModel Upgrade(EntryModel model, ContentModel newContentModel, ContentType targetType) { if (model.ContentType == targetType) { return(null); } ContentModel newModel = null; if (model.ContentType == ContentType.Note && targetType == ContentType.Webpage) { newModel = new WebpageModel(); var nowContent = newContentModel as NoteModel; UpgradeHelper.WriteValues(nowContent, (WebpageModel)newModel); } if (model.ContentType == ContentType.Note && targetType == ContentType.Person) { newModel = new PersonModel(); var nowContent = newContentModel as NoteModel; UpgradeHelper.WriteValues(nowContent, (PersonModel)newModel); } if (model.ContentType == ContentType.Note && targetType == ContentType.Book) { newModel = new BookModel(); var nowContent = newContentModel as NoteModel; UpgradeHelper.WriteValues(nowContent, (BookModel)newModel); } if (model.ContentType == ContentType.Webpage && targetType == ContentType.CreditCard) { newModel = new CreditCardModel(); var nowContent = newContentModel as WebpageModel; UpgradeHelper.WriteValues(nowContent, (CreditCardModel)newModel); } if (model.ContentType == ContentType.Webpage && targetType == ContentType.OnlineAccount) { newModel = new OnlineAccountModel(); var nowContent = newContentModel as WebpageModel; UpgradeHelper.WriteValues(nowContent, (OnlineAccountModel)newModel); } if (newModel != null) { model.ContentType = newModel.GetContentType(); } return(newModel); }
public async Task AnalyzeAsync(WebsiteModel website) { var urls = await _sitemapService.GetUrlsAsync(website.Domain); if (urls.Count > 0) { var webpages = new ConcurrentBag <WebpageModel>(); await urls.ParallelForEachAsync(async url => { WebpageModel webpage = new WebpageModel { Path = url.ToString(), Website = website }; await _webpageAnalyzer.AnalyzeAsync(webpage); webpages.Add(webpage); }, maxDegreeOfParallelism : 10); website.Webpages = webpages.ToList(); } }
public void Edit(WebpageModel model) { var record = _session.Single<Webpage>(x=>x.Id == model.Id); record.Update(model); _session.CommitChanges(); }
public void Delete(WebpageModel model) { _session.Delete(model); }
public void Add(WebpageModel model) { _session.Add(model); }
public void Delete(WebpageModel model) { _session.Delete(model); }
public void Add(WebpageModel model) { _session.Add(model); }
public static void WriteValues(WebpageModel source, OnlineAccountModel target) { WriteValues(source as NoteModel, target); target.WebpageUrl = source.WebpageUrl; }