public ActionResult Edit(ContentsModel input)
 {
     if (ModelState.IsValid)
     {
         var entity = new tb_Contents();
         entity.CategoryId       = input.CategoryId;
         entity.Content          = input.Content;
         entity.Date             = input.Date;
         entity.Description      = input.Description;
         entity.Id               = input.Id;
         entity.Meta_Description = input.Meta_Description;
         entity.Meta_Keyword     = input.Meta_Keyword;
         entity.Meta_Title       = input.Meta_Title;
         entity.Modified         = input.Modified;
         entity.Name             = input.Name;
         entity.Order            = input.Order;
         entity.ParentId         = input.ParentId;
         entity.Slug             = input.Slug;
         entity.Status           = input.Status;
         entity.Taxonomy         = input.Taxonomy;
         entity.Thumbnail        = input.Thumbnail;
         entity.Title            = input.Title;
         entity.UserId           = input.UserId;
         entity.View             = input.View;
         entity.Modified         = Convert.ToDateTime(input.Modified);
         Dao.Update(entity);
     }
     ViewBag.CategoryId = new SelectList(DaoCategories.ListAllByTaxonomy("Content"), "Id", "Title", input.CategoryId);
     return(View(input));
 }
Exemplo n.º 2
0
 public bool Update(tb_Contents entity)
 {
     try
     {
         db.Entry(entity).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
 public ActionResult Add(ContentsModel input)
 {
     if (ModelState.IsValid)
     {
         input.UserId   = SessionHelper.GetSessionUser().UserId;
         input.Taxonomy = input.Taxonomy ?? "Content";
         input.Status   = input.Status ?? true;
         input.View     = input.View ?? 0;
         input.Order    = input.Order ?? 0;
         input.Date     = input.Date ?? DateTime.Now;
         input.Modified = input.Modified ?? DateTime.Now;
         var entity = new tb_Contents();
         entity.CategoryId       = input.CategoryId;
         entity.Content          = input.Content;
         entity.Date             = input.Date;
         entity.Description      = input.Description;
         entity.Id               = input.Id;
         entity.Meta_Description = input.Meta_Description;
         entity.Meta_Keyword     = input.Meta_Keyword;
         entity.Meta_Title       = input.Meta_Title;
         entity.Modified         = input.Modified;
         entity.Name             = input.Name;
         entity.Order            = input.Order;
         entity.ParentId         = input.ParentId;
         entity.Slug             = input.Slug;
         entity.Status           = input.Status;
         entity.Taxonomy         = input.Taxonomy;
         entity.Thumbnail        = input.Thumbnail;
         entity.Title            = input.Title;
         entity.UserId           = input.UserId;
         entity.View             = input.View;
         long Id = Dao.Insert(entity);
         return(RedirectToAction("Edit", "Contents", new { Id = Id }));
     }
     ViewBag.CategoryId = new SelectList(DaoCategories.ListAllByTaxonomy("Content"), "Id", "Title", input.CategoryId);
     return(View(input));
 }
Exemplo n.º 4
0
 public long Insert(tb_Contents entity)
 {
     db.tb_Contents.Add(entity);
     db.SaveChanges();
     return(entity.Id);
 }