public BodyEndViewModel BuildBodyEnd(WebsiteModel websiteModel, PageModel pageModel, CategoryModel categoryModel, ProductModel productModel) { string fileName = _memoryCache.Get("LitiumAppJs") as string; if (fileName == null) { lock (_lock) { fileName = _memoryCache.Get("LitiumAppJs") as string; if (fileName == null) { var file = _fileProvider.GetDirectoryContents("ui") .OfType <IFileInfo>() .FirstOrDefault(x => !x.IsDirectory && x.Name.StartsWith("app.", StringComparison.OrdinalIgnoreCase) && x.Name.EndsWith(".js", StringComparison.OrdinalIgnoreCase)); fileName = "/ui/" + file.Name; var changeToken = _fileProvider.Watch(fileName); _memoryCache.Set("LitiumAppJs", fileName, changeToken); } } } var viewModel = new BodyEndViewModel { FileName = fileName, TrackingScripts = _trackingScriptService.GetBodyEndScript(pageModel.Page) }; return(viewModel); }
public async Task <IActionResult> PutWebsiteModel(int id, WebsiteModel websiteModel) { if (id != websiteModel.id) { return(BadRequest()); } _context.Entry(websiteModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WebsiteModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Post([FromBody] WebsiteModel nieuweWebsite) { //voegt een service toe using (var context = new ApplicationDbContext()) { //Maakt een nieuwe website aan en voegt hem toe aan de context var website = new WebsiteModel() { Url = nieuweWebsite.Url, }; context.Websites.Add(website); //Voegt de elementen toe aan de site die net toegevoegt is aan de context foreach (var x in nieuweWebsite.Elements) { context.Elements.Add(new ElementModel() { Name = x.Name, Website = website }); } context.SaveChanges(); } }
public async Task <ActionResult <WebsiteModel> > PostWebsiteModel(WebsiteModel websiteModel) { _context.WebsiteModels.Add(websiteModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetWebsiteModel", new { id = websiteModel.id }, websiteModel)); }
/// <summary> /// Buid Sub Navigation Model /// </summary> /// <param name="currentPageModel"></param> /// <returns></returns> public async Task <SubNavigationLinkModel> BuildAsync() { _website = _requestModelAccessor.RequestModel.WebsiteModel; _channel = _requestModelAccessor.RequestModel.ChannelModel; _page = _requestModelAccessor.RequestModel.CurrentPageModel; var contentLink = new SubNavigationLinkModel(); var filterNavigation = _website.GetNavigationType(); var pageTypeName = _page.GetPageType(); // sub navigation if (_routeRequestInfoAccessor.RouteRequestInfo?.Data is ProductPageData productCatalogData) { contentLink = filterNavigation == NavigationType.Category ? CreateProductCategoryNavigation(productCatalogData) : CreateProductFilterNavigation(productCatalogData); } else if (pageTypeName != PageTemplateNameConstants.Brand && pageTypeName != PageTemplateNameConstants.ProductList && pageTypeName != PageTemplateNameConstants.SearchResult) { contentLink = await CreatePageNavigationAsync(); } return(contentLink); }
// Create model from entity. public CompanyModel(Company entity) { Name = entity.Name; Address = new AddressModel(entity.Address); PhoneNumber = new PhoneNumberModel(entity.PhoneNumber); Website = new WebsiteModel(entity.Website); }
public async Task <WebsiteModel> CreateOrUpdate(WebsiteModel model) { var websiteEntity = this.All().FirstOrDefault(w => w.Name == model.Name); if (websiteEntity != null) { websiteEntity.Url = model.Url; websiteEntity.Category = model.Category; websiteEntity.HomepageSnapshot = model.HomepageSnapshot; websiteEntity.LoginEmail = model.Login.Email; websiteEntity.LoginPassword = model.Login.Password; websiteEntity = await this.Update(websiteEntity); } else { var entity = new Website() { Name = model.Name, Url = model.Url, Category = model.Category, LoginEmail = model.Login.Email, LoginPassword = model.Login.Password, HomepageSnapshot = model.HomepageSnapshot, IsDeleted = false }; websiteEntity = await this.Add(entity); } model.Id = websiteEntity.Id; return(model); }
public async Task <IActionResult> WebOpenCommandAsync(WebsiteModel model) { if (!ModelState.IsValid) { return(View(model)); } if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User") { return(RedirectToAction(nameof(HomeController.Index), "Home")); } var websitevariables = new WebsiteVariables { Url = model.Url, Closed = model.Closed, Hidde = model.Hidde }; var method = new BaseCommands { Method = "Execute" }; var command = new WebsiteOpenModel { newBaseCommand = method, newWebsiteModel = websitevariables }; var bots = new GetBotsByStatusQuery { status = model.Force }; var botlist = await _mediator.Send(bots); var response = CommandExecute.TcpConnects(botlist, JsonConvert.SerializeObject(command).Replace(@"\", "")); return(Json(response)); }
public SubNavigationViewModelBuilder( RequestModelAccessor requestModelAccessor, RouteRequestInfoAccessor routeRequestInfoAccessor, CategoryService categoryService, MarketService marketService, PageService pageService, UrlService urlService, SearchQueryBuilderFactory searchQueryBuilderFactory, PageSearchService pageSearchService, AuthorizationService authorizationService, ICollection <IRenderingValidator <Category> > renderingValidators) { _requestModelAccessor = requestModelAccessor; _routeRequestInfoAccessor = routeRequestInfoAccessor; _categoryService = categoryService; _marketService = marketService; _pageService = pageService; _urlService = urlService; _searchQueryBuilderFactory = searchQueryBuilderFactory; _pageSearchService = pageSearchService; _website = _requestModelAccessor.RequestModel.WebsiteModel; _channel = _requestModelAccessor.RequestModel.ChannelModel; _page = _requestModelAccessor.RequestModel.CurrentPageModel; _authorizationService = authorizationService; _renderingValidators = renderingValidators; }
public int AddWebsite(WebsiteModel model) { model.Status = "Active"; model.DatePublished = DateTime.Now.ToShortDateString(); return(_firebase.AddWebsite(JsonConvert.SerializeObject(model))); }
public void Put([FromBody] WebsiteModel website) { using (var context = new ApplicationDbContext()) { context.Websites.Update(website); context.SaveChanges(); } }
public BodyStartViewModel BuildBodyStart(WebsiteModel websiteModel, PageModel pageModel, CategoryModel categoryModel, ProductModel productModel) { var viewModel = new BodyStartViewModel { TrackingScripts = _trackingScriptService.GetBodyStartScripts(pageModel.Page) }; return(viewModel); }
public ActionResult Create(string contactId) { var oid = ControllerHelpers.GetObjectId(contactId); var model = new WebsiteModel { ContactId = oid, }; return(View(model)); }
/// <summary> /// Gets the navigation type. /// </summary> public static NavigationType GetNavigationType(this WebsiteModel websiteModel) { if (websiteModel.Fields.GetValue <string>(AcceleratorWebsiteFieldNameConstants.NavigationTheme) == NavigationConstants.FilterBased) { return(NavigationType.Filter); } return(NavigationType.Category); }
public async Task <IViewComponentResult> InvokeAsync() { var model = new WebsiteModel() { WebsiteName = await Kztek_Library.Helpers.AppSettingHelper.GetStringFromAppSetting("WebConfig:WebsiteName") }; return(View(model)); }
private static WebsiteModel DownloadWebsite(string websiteURL) { WebsiteModel websiteModel = new WebsiteModel(); WebClient client = new WebClient(); websiteModel.WebsiteUrl = websiteURL; websiteModel.WebsiteData = client.DownloadString(websiteURL); return(websiteModel); }
public IActionResult Index() { var model = new WebsiteModel { Title = "Home Page", Environment = _appSettings.Environment }; return(View(model)); }
public ActionResult Delete(WebsiteModel model) { try { websiteService.RemoveContactWebsite(model.ContactId, model.Id); return(RedirectToAction("Index", new { id = model.ContactId })); } catch (Exception ex) { ViewBag.ErrorMessage = ex.Message; return(View(model)); } }
private void tsbWebsiteList_SelectedIndexChanged(object sender, EventArgs e) { WebsiteModel selectedWebsite = tsbWebsiteList.SelectedItem as WebsiteModel; if (selectedWebsite != null) { Model.UpdateWebsite(selectedWebsite); ResetEntityInformationPanel(); LoadAllEntities(); } }
public void TestCreateWebsiteAsync_ShouldNotThrowAnyException() { var websiteModel = new WebsiteModel() { CompanyId = 2, Name = "Website Create", UrlPath = "UrlPath Create", }; Assert.DoesNotThrowAsync(() => websiteService.CreateAsync(websiteModel)); }
public IActionResult AddWebsite([FromBody] WebsiteModel model) { try { return(Ok(_websiteLogic.AddWebsite(model))); } catch (Exception ex) { throw ex; } }
public string Render(TemplateModel model) { var menu = Menu.GetMenu(model.Request, model.Handler); var themeModel = Theme.GetModel(model.Request, model.Handler); var bundle = !model.Request.Server.Development; var websiteModel = new WebsiteModel(model.Request, model.Handler, model, Theme, themeModel, menu, Scripts.GetReferences(bundle), Styles.GetReferences(bundle)); return(Theme.Renderer.Render(websiteModel)); }
public IActionResult WebOpenCommand(WebsiteModel model) { if (!ModelState.IsValid) { return(View(model)); } if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User") { return(RedirectToAction(nameof(HomeController.Index), "Home")); } return(Json(true)); }
private static async Task <WebsiteModel> DownloadWebsite(Uri uri) { WebsiteModel output = new WebsiteModel(); WebClient client = new WebClient(); client.DownloadFile(uri, "localpage.html"); output.url = uri; output.data = client.DownloadString(uri); Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "localpage.html"); return(output); }
public void TestCreateWebsiteAsync_WithNotExistedCompany_ShouldThrowNotFoundException() { var websiteModel = new WebsiteModel() { CompanyId = 10, Name = "Website Create", UrlPath = "UrlPath Create", }; var ex = Assert.ThrowsAsync <NotFoundException>(() => websiteService.CreateAsync(websiteModel)); Assert.AreEqual(string.Format(Constants.MessageResponse.NotFoundError, nameof(Company), websiteModel.CompanyId.ToString()), ex.Message); }
public void TestCreateWebsiteyAsync_WithUrlPathOfWebsiteExisted_ShouldThrowValidationException() { var websiteModel = new WebsiteModel() { CompanyId = 1, Name = "Website Create", UrlPath = "fsoft", }; var ex = Assert.ThrowsAsync <ValidationException>(() => websiteService.CreateAsync(websiteModel)); Assert.AreEqual(Constants.MessageResponse.WebsiteUrlPathExisted, ex.Message); }
public IActionResult WordsStats(WebsiteModel model) { model.WordsStats = wordsCrawler.GetWordsStatistics(model.Address); if (model.WordsStats != null) { return(View("index", model)); } else { model.ErrorMessage = "Wrong Website Address!"; return(View("Index", model)); } }
public void TestCreateWebsiteAsync_WithCompanyAlreadyHasWebsite_ShouldThrowValidationException() { var websiteModel = new WebsiteModel() { CompanyId = 1, Name = "Website Create", UrlPath = "UrlPath Create", }; var ex = Assert.ThrowsAsync <ValidationException>(() => websiteService.CreateAsync(websiteModel)); Assert.AreEqual(Constants.MessageResponse.UniqueWebsitePerCompanyError, ex.Message); }
public async Task <IActionResult> Create(int elements) { if (ModelState.IsValid) { List <ElementModel> Elements = new List <ElementModel>(); WebsiteModel Model = new WebsiteModel(); Model.Name = Request.Form["Name"]; Model.Url = Request.Form["Url"]; for (int i = 1; i <= elements; i++) { ElementModel elementModel = new ElementModel(); string counter = i.ToString(); string name = "Element" + i; if (!String.IsNullOrEmpty(Request.Form[name])) { elementModel.Name = Request.Form[name]; Elements.Add(elementModel); } else { elements++; } } Model.Elements = Elements; var responseString = (String)null; try { var response = await Startup.client.PostAsJsonAsync("http://localhost:51226/api/websites", Model); responseString = await response.Content.ReadAsStringAsync(); } catch (Exception e) { } //return Content($"{responseString}"); return(RedirectToAction("/index")); } else { WebsiteModel Model = new WebsiteModel(); Model.Url = Request.Form["Url"]; Model.Name = Request.Form["Name"]; return(View(Model)); } }
public static WebsiteListViewModel ToListViewModel(this WebsiteModel model) { if (model == null) { throw new ArgumentNullException(nameof(WebsiteModel)); } return(new WebsiteListViewModel { Id = model.Id, Domain = model.Domain, AnalysisDate = model.AnalysisDate }); }