public ActionResult Edit(Release EditEntity, int id, SEO POSTSEO, int SEOID = 0) { if (ModelState.IsValid) { var Entity = Uow.ReleaseRepository.GetByID(id); var mainImage = WebImage.GetImageFromRequest("UploadedMainImage"); var rectImage = WebImage.GetImageFromRequest("UploadedRectImage"); UpdateModel(Entity); if (mainImage != null) { Entity.MainImage = Server.MapPath("/Images/Releases/").SaveImage(mainImage); } if (rectImage != null) { Entity.RectImage = Server.MapPath("/Images/Releases/").SaveImage(rectImage); } Uow.Commit(); return(RedirectToAction("Index")); } ViewBag.Labels = Uow.ReleaseRepository.GetAllLabels().ToList(); return(View(EditEntity)); }
public ActionResult Create(News Entity, SEO SEOEntity, HttpPostedFileBase[] SEOfile) { if (ModelState.IsValid) { var image = WebImage.GetImageFromRequest("UploadedImage"); if (image != null) { Entity.MainImage = Server.MapPath("/Images/News/").SaveImage(image); } if (SEOEntity != null && SEOfile != null && SEOfile.Length > 0) { if (SEOfile != null) { SEOEntity.ogImage = SEOfile.FBSaveImages(Server.MapPath("/Images/SEO/"), "News"); } } Entity.Date_Creation = DateTime.Now; Uow.NewsRepository.Add(Entity); Uow.Commit(); return(RedirectToAction("Index")); } return(View(Entity)); }
public ActionResult Edit(News EditEntity, int id, SEO POSTSEO, int SEOID = 0) { if (ModelState.IsValid) { var Entity = Uow.NewsRepository.GetByID(id); var image = WebImage.GetImageFromRequest("UploadedImage"); UpdateModel(Entity); if (image != null) { Entity.MainImage = Server.MapPath("/Images/News/").SaveImage(image); } //if (SEOID > 0) //{ // var SEOEntity = repo.GetSEOByID(SEOID); // UpdateModel(SEOEntity); //} //else if (POSTSEO != null) // Entity.SEO_ID = Uow.NewsRepository.InsertSEO(POSTSEO); //if (SEOfile != null) // Entity.SEO.ogImage += SEOfile.FBSaveImages(Server.MapPath("/Images/SEO/"), "News"); Uow.Commit(); return(RedirectToAction("Index")); } return(View(EditEntity)); }
public static void SetPageSEO(Page page, SEO seo) { var title = seo.Title; if (title.NullableContains("{ONLY-SITENAME}")) { title = title.Replace("{ONLY-SITENAME}", string.Empty); page.Title = $"{AppConfig.SiteName}"; } if (title.NullableContains("{ONLY-TITLE}")) { title = title.Replace("{ONLY-TITLE}", string.Empty); page.Title = $"{title}"; } if (!seo.Title.NullableContains("{ONLY-SITENAME}") && !seo.Title.NullableContains("{ONLY-TITLE}")) { page.Title = $"{seo.Title} | {AppConfig.SiteName}"; } page.MetaDescription = seo.Description; page.MetaKeywords = seo.Keywords; }
public static void AddPageSEO(SEO entity) { var xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); var newTitleMeta = xmlDoc.CreateElement("meta"); newTitleMeta.SetAttribute("name", "title"); newTitleMeta.SetAttribute("content", entity.Title); var newDescriptionMeta = xmlDoc.CreateElement("meta"); newDescriptionMeta.SetAttribute("name", "description"); newDescriptionMeta.SetAttribute("content", entity.Description); var newKeywordMeta = xmlDoc.CreateElement("meta"); newKeywordMeta.SetAttribute("name", "keywords"); newKeywordMeta.SetAttribute("content", entity.Keywords); foreach (XmlNode page in xmlDoc.SelectNodes(pageXPath)) { if (page.Attributes["id"].Value == entity.ID) { page.AppendChild(newTitleMeta); page.AppendChild(newDescriptionMeta); page.AppendChild(newKeywordMeta); SaveXml(xmlDoc); break; } } }
public ActionResult RenderMetaData() { SEO model = new SEO(); IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); string domainAddress = homePage.UrlWithDomain(); //populate title or page name string title = CurrentPage.GetPropertyValue <string>("title"); model.Title = !string.IsNullOrEmpty(title) ? title : CurrentPage.Name; model.Description = CurrentPage.HasProperty("description") ? CurrentPage.GetPropertyValue <string>("description") : null; //for keyword we can use string, comma separated values model.Keywords = CurrentPage.HasProperty("keywords") ? CurrentPage.GetPropertyValue <string>("keywords") : null; if (CurrentPage.HasProperty("socialShareImage")) { int mediaId = CurrentPage.GetPropertyValue <int>("socialShareImage"); var mediaItem = Umbraco.Media(mediaId); model.ImageUrl = domainAddress.TrimEnd('/') + mediaItem.Url; } model.Url = CurrentPage.UrlWithDomain(); return(PartialView("~/Views/Partials/SiteLayout/_MetaData.cshtml", model)); }
protected bool UpsertSEO(IWithSEO Entity, int SEOID, SEO SEO, HttpPostedFileBase[] SEOfile, string ModelName) { try{ if (SEOID > 0) { var SEOEntity = Uow.SEORepository.GetByID(SEOID); UpdateModel(SEOEntity); } else if (SEO != null) { Uow.SEORepository.Add(SEO); Uow.Commit(); Entity.SeoId = SEO.SEO_ID; } if (SEOfile != null && SEOfile[0] != null) { Entity.SEO.ogImage += SEOfile.FBSaveImages(Server.MapPath("/Images/SEO/"), ModelName); } } catch { return(false); } return(true); }
public ActionResult Index() { ViewBag.CanonicalUrl = SEO.Home_Index_Canonical(); ViewBag.Title = SEO.Home_Index_Title(); ViewBag.Description = SEO.Home_Index_Description(); ViewBag.Keywords = SEO.Home_Index_Keywords(); return(View()); }
public ActionResult Gallery() { ViewBag.CanonicalUrl = SEO.Home_Gallery_Canonical(); ViewBag.Title = SEO.Home_Gallery_Title(); ViewBag.Description = SEO.Home_Gallery_Description(); ViewBag.Keywords = SEO.Home_Gallery_Keywords(); return(View()); }
public ActionResult Contact() { ViewBag.CanonicalUrl = SEO.Home_Contact_Canonical(); ViewBag.Title = SEO.Home_Contact_Title(); ViewBag.Description = SEO.Home_Contact_Description(); ViewBag.Keywords = SEO.Home_Contact_Keywords(); return(View()); }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this.Title = "Phàn nàn khiếu nại - Bếp Nhà Bạn"; SEO.ThemMetaDescript( this.Page.Header, "Công ty Bếp Nhà Bạn cung cấp những mặt hàng gia dụng chất lượng cao, chính hãng,Tư vấn, thiết kế, thi công tủ bếp chuyên nghiệp, tận tình."); } }
public ActionResult PageNotFound() { ViewBag.IsNoIndexNoFollow = "YES"; ViewBag.CanonicalUrl = SEO.Home_PageNotFound_Canonical(); ViewBag.Title = SEO.Home_PageNotFound_Title(); ViewBag.Description = SEO.Home_PageNotFound_Description(); ViewBag.Keywords = SEO.Home_PageNotFound_Keywords(); return(View()); }
private void SeoInit(SEO entity) { ViewData["Title"] = entity.Title; ViewData["KeyWords"] = entity.KeyWords; ViewData["Description"] = entity.Description; ViewData["MetaOwner"] = entity.MetaOwner; ViewData["Canonical"] = entity.Canonical; ViewData["OgUrl"] = entity.OgUrl; ViewData["OgTitle"] = entity.OgTitle; ViewData["OgDescription"] = entity.OgDescription; ViewData["Robots"] = Constants.Seo.indexFollow; }
public void Insert(SEO value) { using (var scope = _dbContextScopeFactory.Create()) { var dbContext = scope.DbContexts .Get <ApplicationDbContext>(); dbContext.Set <SEO>().Add(value); scope.SaveChanges(); } }
//AJAX: Admin/Blog/SEO/<PostSerial> public ActionResult SEO(Guid id) { ContentPage page = new ContentPage(id); SEO seo = page.seo; ViewBag.TypeOG = seo.GetOGOptions(seo.ogType); ViewBag.PostURL = "/admin/pages/seo"; ViewBag.ImageBase = "/blog"; SEOViewModel seoViewModel = new SEOViewModel(seo); return(PartialView("_SEO", seoViewModel)); }
public static SEO GetPageSEO(string id, PerformanceMode performanceMode) { var keyValue = new SEO(); var performanceKey = $"{uniqueKey}_{id}"; Func <string, SEO> fnc = GetPageSEOFromSettings; var args = new object[] { id }; PerformanceHelper.GetPerformance <SEO>(performanceMode, performanceKey, out keyValue, fnc, args); return(keyValue); }
private void ReleasesUpsert(Release Entity, SEO SEOEntity, HttpPostedFileBase[] SEOfile) { var rectImage = WebImage.GetImageFromRequest("UploadedRectImage"); if (rectImage != null) { Entity.RectImage = Server.MapPath("/Images/Releases/").SaveImage(rectImage, true, 315, 315); } InsertImage(Entity, "UploadedMainImage", "Releases"); UpsertSEO(Entity, SEOEntity.SEO_ID, SEOEntity, SEOfile, "Releases"); }
public void Delete(SEO value) { using (var scope = _dbContextScopeFactory.Create()) { var dbContext = scope.DbContexts .Get <ApplicationDbContext>(); var existed = dbContext.Set <SEO>().SingleOrDefault(c => c.ID == value.ID); dbContext.Set <SEO>().Remove(existed); scope.SaveChanges(); } }
public ActionResult SEO(SEO data) { if (!String.IsNullOrEmpty(Request["SiteUrl"])) { try { Int32 PageCount = 0; Int32 PageSize = 10; Int32 PageIndex = data.Page; Int32 RecordCount = 0; Uri uri = new Uri(data.SiteUrl); String _RecordCount = (String)db.ExecuteScalar("SELECT COUNT(id) FROM [t_submitsite]"); Int32.TryParse(_RecordCount, out RecordCount); PageCount = (Int32)Math.Ceiling((Decimal)RecordCount / (Decimal)PageSize); if (PageIndex < 1) { PageIndex = 1; } if (PageIndex > PageCount) { PageIndex = PageCount; } String Url = String.Format("/{0}/{1}/{2}/{3}?SiteUrl={4}", RouteData.Values["action"], "{0}", data.auto, data.time, HttpUtility.UrlEncode(Request["SiteUrl"])); String sql = String.Format("SELECT * FROM [t_submitsite] LIMIT {0} OFFSET {1}", PageSize, PageSize * (PageIndex - 1)); DataTable ds = db.ExecuteDataTable(sql); foreach (DataRow dr in ds.Rows) { String _url = String.Format(dr["url"].ToString(), uri.Host); dr["url"] = _url; } ViewData["NextPage"] = String.Format(Url, PageIndex + 1); ViewData["Host"] = uri.Scheme + "://" + uri.Host; ViewData["Table"] = ds; ViewData["PageString"] = PrintPage(Url, "black2", PageCount, PageIndex); } catch { Response.Write("错误的域名!"); Response.End(); } } return(View(data)); }
public ActionResult Edit(Artist EditEntity, int id, SEO POSTSEO, int SEOID = 0) { if (ModelState.IsValid) { var Entity = Uow.ArtistRepository.GetByID(id); UpdateModel(Entity); Uow.Commit(); return(RedirectToAction("Index")); } return(View(EditEntity)); }
public ActionResult ProductDetail(int productId) { ProductModelDetail modelDetail = _productBo.GetByProductId(productId); if (modelDetail != null && modelDetail.ProductId > 0 && modelDetail.Status == (int)Enums.ProductStatus.Active) { #region Redirect Permanent 301 var currentUrl = Request.RawUrl; string standardUrl = modelDetail.URL; string url301 = standardUrl; if (currentUrl.Contains("?utm_source")) { string strUtm = currentUrl.Substring(currentUrl.IndexOf("?utm_source"), currentUrl.Length - currentUrl.IndexOf("?utm_source")); url301 = string.Concat(url301, strUtm); } if (!currentUrl.Equals(url301)) { return(RedirectPermanent(string.Concat(Const.BaseUrlNoSlash, url301))); } #endregion #region Meta string strTitle = modelDetail.Name; string seoTitle = !string.IsNullOrEmpty(modelDetail.SEOTitle) ? modelDetail.SEOTitle : modelDetail.Name; string seoDesc = !string.IsNullOrEmpty(modelDetail.SEODescription) ? modelDetail.SEODescription : modelDetail.ShortDescription; if (string.IsNullOrEmpty(seoDesc) && seoDesc.Length > 160) { seoDesc = StringUtils.TrimText(seoDesc, 160); } string metaTags = SEO.Instance.BindingMeta(standardUrl, seoTitle, StringUtils.RemoveStrHtmlTags(seoDesc)); ViewBag.MetaTitle = seoTitle; ViewBag.Meta = metaTags; ViewBag.MetaFacebook = SEO.AddMetaFacebook(modelDetail.Name, "article", seoDesc, Const.BaseUrlNoSlash + standardUrl, BuildLink.CropImage(modelDetail.Avatar, Const.FacebookAvatar)); #endregion ViewBag.CateId = modelDetail.CateId; return(View(modelDetail)); } Response.StatusCode = 404; return(null); }
public ActionResult Edit(Page EditEntity, int id, SEO POSTSEO, HttpPostedFileBase[] SEOfile, int SEOID = 0) { if (ModelState.IsValid) { var Entity = Uow.PagesRepository.GetByID(id); UpdateModel(Entity); UpsertSEO(Entity, SEOID, POSTSEO, SEOfile, "Pages"); Uow.Commit(); return(RedirectToAction("Index")); } return(View(EditEntity)); }
public ActionResult Create(Page Entity, SEO SEOEntity, HttpPostedFileBase[] SEOfile) { if (ModelState.IsValid) { UpsertSEO(Entity, 0, SEOEntity, SEOfile, "Pages"); Entity.Date_Creation = DateTime.Now; Uow.PagesRepository.Add(Entity); Uow.Commit(); return(RedirectToAction("Index")); } return(View(Entity)); }
public ActionResult Create(News Entity, SEO SEOEntity, HttpPostedFileBase[] SEOfile) { if (ModelState.IsValid) { InsertImage(Entity, "UploadedImage", "News"); UpsertSEO(Entity, 0, SEOEntity, SEOfile, "News"); Entity.Date_Creation = DateTime.Now; Uow.NewsRepository.Add(Entity); Uow.Commit(); return(RedirectToAction("Index")); } return(View(Entity)); }
public virtual void Update(SEO Entity) { if (DbSet == null) { DbSet = DbContext.Set <SEO>(); } DbEntityEntry DbEntityEntry = DbContext.Entry(Entity); if (DbEntityEntry.State == EntityState.Detached) { DbSet.Attach(Entity); } DbEntityEntry.State = EntityState.Modified; }
public void Update(SEO value) { using (var scope = _dbContextScopeFactory.Create()) { var dbContext = scope.DbContexts .Get <ApplicationDbContext>(); var existed = dbContext.Set <SEO>() .SingleOrDefault(c => c.ID == value.ID); existed.Key = value.Key; existed.Description = value.Description; existed.Keywords = value.Keywords; scope.SaveChanges(); } }
public ActionResult Edit(Project EditEntity, int id, SEO POSTSEO, HttpPostedFileBase[] SEOfile, int SEOID = 0) { if (ModelState.IsValid) { var Entity = Uow.ProjectRepository.GetByID(id); UpdateModel(Entity); InsertImage(Entity, "UploadedImage", "Projects"); UpsertSEO(Entity, POSTSEO.SEO_ID, POSTSEO, SEOfile, "Projects"); Uow.Commit(); return(RedirectToAction("Index")); } return(View(EditEntity)); }
public ActionResult Edit(int id) { EditKat editkat = new EditKat(); editkat.Kategori = kf.Get(id); if (editkat.Kategori.SEOID > 1) { editkat.Seo = sf.Get(editkat.Kategori.SEOID); } else { SEO seo = new SEO(); editkat.Seo = seo; } return(View(editkat)); }
public ActionResult EditSEO(SEO seo, int katID) { if (seo.ID > 1) { sf.Update(seo); } else { if (ModelState.IsValid) { int id = sf.Insert(seo); kf.UpdateColumn("SEOID", id, katID); } } return(RedirectToAction("Index")); }
public virtual void Add(SEO Entity) { if (DbSet == null) { DbSet = DbContext.Set <SEO>(); } DbEntityEntry DbEntityEntry = DbContext.Entry(Entity); if (DbEntityEntry.State != EntityState.Detached) { DbEntityEntry.State = EntityState.Added; } else { DbSet.Add(Entity); } }