Beispiel #1
0
        public long Create(Content content)
        {
            //Xử lý alias
            if (string.IsNullOrEmpty(content.MetaTitle))
            {
                content.MetaTitle = StringHelper.ToUnsignString(content.Name);
            }
            content.CreatedDate = DateTime.Now;
            content.ViewCount = 0;
            db.Contents.Add(content);
            db.SaveChanges();

            //Xử lý tag
            if (!string.IsNullOrEmpty(content.Tags))
            {
                string[] tags = content.Tags.Split(',');
                foreach (var tag in tags)
                {
                    var tagId = StringHelper.ToUnsignString(tag);
                    var existedTag = this.CheckTag(tagId);

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

                    //insert to content tag
                    this.InsertContentTag(content.ID, tagId);

                }
            }

            return content.ID;
        }
        public long Edit(Content content)
        {
            //Xử lý Alias
            if (string.IsNullOrEmpty(content.MetaTitle))
            {
                content.MetaTitle = StringHelper.ToUnsignString(content.Name);
            }
            content.ModifiedDate = DateTime.Now;

            db.SaveChanges();

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

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

                    //Insert to content tag
                    this.InsertContentTag(content.ID, tagId);
                }
            }

            return content.ID;
        }
 public ActionResult Edit(Model.EF.Content model)
 {
     if (ModelState.IsValid)
     {
     }
     SetViewBag();
     return(View(model.CategoryID));
 }
        public ActionResult Edit(Content model)
        {
            if (ModelState.IsValid)
            {

            }
            SetViewBag(model.CategoryID);
            return View();
        }
 public ActionResult Edit(Content model)
 {
     if (ModelState.IsValid)
     {
         var dao = new ContentDao();
         var result = dao.Update(model);
         return RedirectToAction("Index");
     }
     SetViewBag(model.CategoryID);
     return View();
 }
 public ActionResult Create(Content model)
 {
     if (ModelState.IsValid)
     {
         var session = (UserLogin)Session[CommonConstants.USER_SESSION];
         model.CreatedBy = session.UserName;
         new ContentDao().Create(model);
         return RedirectToAction("Index");
     }
     SetViewBag();
     return View();
 }
        public ActionResult Create(Model.EF.Content model)
        {
            if (ModelState.IsValid)
            {
                var dao = new ContentDao();

                long id = dao.Insert(model);
                if (id > 0)
                {
                    setAL("Thêm tin tức thành công", "success");
                    return(RedirectToAction("Index", "Content"));
                }
                else
                {
                    setAL("Thêm tin tức không thành công", "error");
                    ModelState.AddModelError("", "Thêm User thành công");
                }
            }
            SetViewBag();
            return(View("Index"));
        }
Beispiel #8
0
        public long Update(Model.EF.Content buider)
        {
            var bd = db.Contents.Find(buider.ContentID);

            //   bd.ContentID = buider.BuilderID;
            bd.Name = buider.Name;

            //bd.CreateBy = buider.CreateBy;
            //bd.CreateDate = buider.CreateDate;
            bd.Description  = buider.Description;
            bd.Detail       = buider.Detail;
            bd.Image        = buider.Image;
            bd.Status       = buider.Status;
            bd.MetaTite     = buider.MetaTite;
            bd.ModifiedBy   = buider.ModifiedBy;
            bd.ModifiedDate = buider.ModifiedDate;
            bd.Status       = buider.Status;
            bd.TopHot       = buider.TopHot;
            bd.UsersRead    = buider.UsersRead;
            db.SaveChanges();
            return(buider.ContentID);
        }
Beispiel #9
0
 public ActionResult Edit(Content content)
 {
     var dao = new ContentDao();
     if (ModelState.IsValid)
     {
         var session = (UserLogin)Session[CommonConstants.USER_SESSION];
         content.ModifiedBy = session.UserName;
         var culture = Session[CommonConstants.CurrentCulture];
         content.Language = culture.ToString();
         var result = dao.Edit(content);
         if (result)
         {
             SetAlert("Cập nhật tin tức thành công!", "success");
             return RedirectToAction("Index");
         }
         else
         {
             ModelState.AddModelError("", "Cập nhật tin tức không thành công!");
         }
         return RedirectToAction("Index");
     }
     SetViewBag(content.CategoryID);
     return View();
 }
        public bool Update(Content entity)
        {
            try
            {
                var content = db.Contents.Find(entity.ID);
                content.CategoryID = entity.CategoryID;
                content.Name = entity.Name;
                if (entity.Description != null)
                {
                    content.Description = Regex.Replace(entity.Description, @"<[^>]*>", String.Empty);
                }
                content.Detail = entity.Detail;
                content.Image = entity.Image;
                content.File = entity.File;
                content.Language = entity.Language;
                content.MetaTitle = entity.MetaTitle;
                content.ModifiedDate = DateTime.Now;
                content.Status = entity.Status;

                db.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Beispiel #11
0
 public long Insert(Model.EF.Content buider)
 {
     db.Contents.Add(buider);
     db.SaveChanges();
     return(buider.ContentID);
 }
Beispiel #12
0
        public bool Edit(Content content)
        {
            try
            {
                var cont = db.Contents.Find(content.ID);
                cont.Name = content.Name;
                if (string.IsNullOrEmpty(content.MetaTitle))
                {
                    cont.MetaTitle = StringHelper.ToUnsignString(content.Name);
                }else {
                    cont.MetaTitle = content.MetaTitle;
                }
                cont.Description = content.Description;
                cont.Image = content.Image;
                cont.Detail = content.Detail;
                cont.MetaKeywords = content.MetaKeywords;
                cont.CategoryID = content.CategoryID;
                cont.MetaDescriptions = content.MetaDescriptions;
                cont.ModifiedDate = DateTime.Now;
                cont.Status = content.Status;
                //Xử lý tag
                if (!string.IsNullOrEmpty(content.Tags))
                {
                    this.RemoveAllContentTag(content.ID);
                    string[] tags = content.Tags.Split(',');
                    foreach (var tag in tags)
                    {
                        var tagId = StringHelper.ToUnsignString(tag);
                        var existedTag = this.CheckTag(tagId);

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

                        //insert to content tag
                        this.InsertContentTag(content.ID, tagId);
                    }
                }
                else
                {
                    cont.Tags = content.Tags;
                }
                db.SaveChanges();
                return true;
            }
            catch(Exception ex)
            {
                return false;
            }
        }