Example #1
0
 public ActionResult SaveSEO(SeoDetails seoDetails)
 {
     if (ModelState.IsValid)
     {
         EntityRepository.SaveSEO(seoDetails);
         TempData["message"] = string.Format("Seo has been saved");
         return(RedirectToAction("List", new { type = "SEO" }));
     }
     else
     {
         return(RedirectToAction("List", new { type = "SEO" }));
     }
 }
Example #2
0
        public void SaveSEO(SeoDetails seoDetails)
        {
            if (seoDetails.SEOId.Equals(Guid.Empty))
            {
                SEO dbSeo = new SEO
                {
                    SEOId              = Guid.NewGuid(),
                    MetaTagTitle       = seoDetails.MetaTagTitle,
                    MetaTagDescription = seoDetails.MetaTagDescription,
                    MetaTagKeyWords    = seoDetails.MetaTagKeyWords,
                    SEOTags            = seoDetails.SEOTags,
                    CustomTitle1       = seoDetails.CustomTitle1,
                    CustomTitle2       = seoDetails.CustomTitle2,
                    CustomImageTitle   = seoDetails.CustomImageTitle,
                    CustomImageAlt     = seoDetails.CustomImageAlt,
                    MetaRobots         = seoDetails.MetaRobots,
                    UrlKeyWord         = seoDetails.UrlKeyWord,
                    SEOImage           = seoDetails.SEOImage
                };
                context.SEO.Add(dbSeo);
            }
            else
            {
                SEO dbSeo = context.SEO.Find(seoDetails.SEOId);
                if (dbSeo != null)
                {
                    dbSeo.MetaTagTitle       = seoDetails.MetaTagTitle;
                    dbSeo.MetaTagDescription = seoDetails.MetaTagDescription;
                    dbSeo.MetaTagKeyWords    = seoDetails.MetaTagKeyWords;
                    dbSeo.SEOTags            = seoDetails.SEOTags;
                    dbSeo.CustomTitle1       = seoDetails.CustomTitle1;
                    dbSeo.CustomTitle2       = seoDetails.CustomTitle2;
                    dbSeo.CustomImageTitle   = seoDetails.CustomImageTitle;
                    dbSeo.CustomImageAlt     = seoDetails.CustomImageAlt;
                    dbSeo.MetaRobots         = seoDetails.MetaRobots;
                    dbSeo.UrlKeyWord         = seoDetails.UrlKeyWord;
                    dbSeo.SEOImage           = seoDetails.SEOImage;
                }
            }

            context.SaveChanges();
        }