Exemplo n.º 1
0
        public long Insert(News mode)
        {
            if (string.IsNullOrEmpty(mode.MetaTite))
            {
                mode.MetaTite = HepperString.ToUnsignString(mode.Name);
            }
            if (string.IsNullOrEmpty(mode.Title))
            {
                mode.Title = mode.Name;
            }
            mode.ViewCount     = 0;
            mode.PublishedDate = DateTime.Now;
            db.News.Add(mode);
            db.SaveChanges();
            //Xử lý tag
            if (!string.IsNullOrEmpty(mode.Tags))
            {
                string[] tags = mode.Tags.Split(',');
                foreach (var tag in tags)
                {
                    var tagId      = HepperString.ToUnsignString(tag);
                    var existedTag = this.CheckTag(tagId);

                    //insert to to tag table
                    if (!existedTag)
                    {
                        this.InsertTag(tagId, tag);
                    }

                    //insert to content tag
                    this.InsertNewsTag(mode.NewsID, tagId);
                }
            }
            return(mode.NewsID);
        }
Exemplo n.º 2
0
        public bool Update(Category mode)
        {
            try
            {
                var bd = db.Categories.Find(mode.CategoryID);
                if (string.IsNullOrEmpty(mode.MetaTite))
                {
                    bd.MetaTite = HepperString.ToUnsignString(mode.Name);
                }
                else
                {
                    bd.MetaTite = mode.MetaTite;
                }
                if (string.IsNullOrEmpty(mode.SeoTite))
                {
                    bd.SeoTite = mode.Name;
                }
                else
                {
                    bd.SeoTite = mode.SeoTite;
                }
                // bd.CategoryID = mode.CategoryID;
                //bd.CreateBy = mode.CreateBy;
                //bd.CreateDate = mode.CreateDate;
                bd.Description  = mode.Description;
                bd.DisplayOrder = mode.DisplayOrder;
                bd.Image        = mode.Image;

                bd.LanguageID      = mode.LanguageID;
                bd.MetaDescription = mode.MetaDescription;
                bd.MetakeyWords    = mode.MetakeyWords;

                bd.ModifiedBy   = mode.ModifiedBy;
                bd.ModifiedDate = mode.ModifiedDate;
                bd.ParentID     = mode.ParentID;
                bd.Position     = mode.Position;

                bd.ShowOnHome = mode.ShowOnHome;
                bd.Status     = mode.Status;
                bd.Name       = mode.Name;


                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public bool Update(About mode)
        {
            try
            {
                var bd = db.Abouts.Find(mode.AboutID);
                if (string.IsNullOrEmpty(mode.MetaTite))
                {
                    bd.MetaTite = HepperString.ToUnsignString(mode.Name);
                }
                else
                {
                    bd.MetaTite = mode.MetaTite;
                }

                // bd.AboutID = mode.AboutID;
                //bd.CreateBy = mode.CreateBy;
                //bd.CreateDate = mode.CreateDate;
                bd.Description = mode.Description;
                bd.Phone       = mode.Phone;
                bd.Twitter     = mode.Twitter;
                bd.Video       = mode.Video;
                bd.Address     = mode.Address;
                bd.Detail      = mode.Detail;
                bd.Email       = mode.Email;
                bd.Facebook    = mode.Facebook;
                bd.Googleplus  = mode.Googleplus;

                bd.Image = mode.Image;

                bd.LanguageID      = mode.LanguageID;
                bd.MetaDescription = mode.MetaDescription;
                bd.MetakeyWords    = mode.MetakeyWords;

                bd.ModifiedBy   = mode.ModifiedBy;
                bd.ModifiedDate = mode.ModifiedDate;

                bd.Status = mode.Status;
                bd.Name   = mode.Name;


                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public bool Insert(About mode)
        {
            try
            {
                if (string.IsNullOrEmpty(mode.MetaTite))
                {
                    mode.MetaTite = HepperString.ToUnsignString(mode.Name);
                }

                db.Abouts.Add(mode);
                db.SaveChanges();
                return(true);
            }

            catch
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        public bool Insert(Category mode)
        {
            try
            {
                if (string.IsNullOrEmpty(mode.MetaTite))
                {
                    mode.MetaTite = HepperString.ToUnsignString(mode.Name);
                }
                if (string.IsNullOrEmpty(mode.SeoTite))
                {
                    mode.SeoTite = mode.Name;
                }
                db.Categories.Add(mode);
                db.SaveChanges();
                return(true);
            }

            catch
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        public long Update(News mode)
        {
            var bd = db.News.Find(mode.NewsID);

            if (string.IsNullOrEmpty(mode.MetaTite))
            {
                bd.MetaTite = HepperString.ToUnsignString(mode.Name);
            }
            else
            {
                bd.MetaTite = mode.MetaTite;
            }
            if (string.IsNullOrEmpty(mode.Title))
            {
                bd.MetaTite = mode.Name;
            }
            else
            {
                bd.MetaTite = mode.MetaTite;
            }

            //bd.NewsID = mode.NewsID;
            //bd.CreateBy = mode.CreateBy;
            //bd.CreateDate = mode.CreateDate;

            bd.CategoryID    = mode.CategoryID;
            bd.ContentHtml   = mode.ContentHtml;
            bd.Description   = mode.Description;
            bd.Name          = mode.Name;
            bd.PublishedDate = mode.PublishedDate;
            if (string.IsNullOrEmpty(mode.RelatedNewses))
            {
                bd.RelatedNewses = "";
            }
            else
            {
                bd.RelatedNewses = mode.RelatedNewses;
            }

            bd.ShowConment     = mode.ShowConment;
            bd.ShowShare       = mode.ShowShare;
            bd.UpTopHot        = mode.UpTopHot;
            bd.UpTopNew        = mode.UpTopNew;
            bd.ViewCount       = mode.ViewCount;
            bd.Image           = mode.Image;
            bd.LanguageID      = mode.LanguageID;
            bd.MetaDescription = mode.MetaDescription;
            bd.MetakeyWords    = mode.MetakeyWords;

            bd.ModifiedBy   = mode.ModifiedBy;
            bd.ModifiedDate = mode.ModifiedDate;

            bd.Status = mode.Status;

            bd.Source = mode.Source;


            db.SaveChanges();
            //Xử lý tag
            if (!string.IsNullOrEmpty(mode.Tags))
            {
                this.RemoveAllContentTag(mode.NewsID);
                string[] tags = mode.Tags.Split(',');
                foreach (var tag in tags)
                {
                    var tagId      = HepperString.ToUnsignString(tag);
                    var existedTag = this.CheckTag(tagId);

                    //insert to to tag table
                    if (!existedTag)
                    {
                        this.InsertTag(tagId, tag);
                    }

                    //insert to content tag
                    this.InsertNewsTag(mode.NewsID, tagId);
                }
            }
            return(mode.NewsID);
        }