Ejemplo n.º 1
0
 private void CreateOrChangeContentLang(SiteContainer context, Content instance, Content cache, Language lang)
 {
    
         ContentLang contenttLang = null;
         if (cache != null)
         {
             contenttLang = context.ContentLang.FirstOrDefault(p => p.ContentId == cache.Id && p.LanguageId == lang.Id);
         }
         if (contenttLang == null)
         {
             var newPostLang = new ContentLang
                                   {
                                       ContentId = instance.Id,
                                       LanguageId = lang.Id,
                                       Title = instance.Title,
                                       Text = HttpUtility.HtmlDecode(instance.Text),
                                       SeoDescription = instance.SeoDescription,
                                       SeoKeywords = instance.SeoKeywords
                                   };
             context.AddToContentLang(newPostLang);
         }
         else
         {
             contenttLang.Title = instance.Title;
             contenttLang.Text = HttpUtility.HtmlDecode(instance.Text);
             contenttLang.SeoDescription = instance.SeoDescription;
             contenttLang.SeoKeywords = instance.SeoKeywords;
         }
         context.SaveChanges();
    
 }
Ejemplo n.º 2
0
        public SiteModel(Language lang, SiteContainer context, string contentId)
        {
            Title = "Listelli";
            
            Content = context.Content.FirstOrDefault(c => c.Name == contentId) ?? context.Content.First(c => c.MainPage);
            IsHomePage = Content.MainPage;
            Content.CurrentLang = lang.Id;

            SeoDescription = Content.SeoDescription;
            SeoKeywords = Content.SeoKeywords;
        }
Ejemplo n.º 3
0
        public ActionResult Edit(Content model)
        {
            using (var context = new SiteContainer())
            {
                var cache = context.Content.FirstOrDefault(p => p.Id == model.Id);

                if (cache != null)
                {
                    var lang = context.Language.FirstOrDefault(p => p.Id == model.CurrentLang);
                    if (lang != null)
                    {
                        CreateOrChangeContentLang(context, model, cache, lang);
                    }
                }

                return RedirectToAction("Index", "Home",new{area="",id=cache.Name});
            }

            
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Content EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContent(Content content)
 {
     base.AddObject("Content", content);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Create a new Content object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="mainPage">Initial value of the MainPage property.</param>
 public static Content CreateContent(global::System.Int32 id, global::System.String name, global::System.Boolean mainPage)
 {
     Content content = new Content();
     content.Id = id;
     content.Name = name;
     content.MainPage = mainPage;
     return content;
 }