Ejemplo n.º 1
0
        public ActionResult ThemMoiDonVi(ModelDonVi model)
        {
            if (ModelState.IsValid)
            {
                Content entity = new Content
                {
                    contentAlias      = model.Link,
                    contentUpdateTime = DateTime.Now,
                    contentParentId   = model.DonviCha,
                    contentName       = model.TenDonVi,
                    contentCreateTime = DateTime.Now,
                    isSort            = model.ThuTu,
                    isTrash           = false,
                    contentView       = 0,
                    contentLanguageId = 1,
                    contentKey        = "DONVIPHONGKHOA",
                    contentCreateUser = User.Identity.Name,
                    contentUpdateUser = User.Identity.Name
                };
                _services.Add(entity);
                _services.Save();
                entity.contentAlias = entity.contentAlias + "-" + entity.contentId;
                _services.Update(entity);
                _services.Save();
                return(RedirectToAction("Index", new { _parentId = entity.contentParentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)model.DonViId, "DONVIPHONGKHOA", 1);

            ViewBag.DonviCha = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(model));
        }
Ejemplo n.º 2
0
 public ActionResult Detail(Content entity)
 {
     if (ModelState.IsValid)
     {
         if (entity.contentId > 0)
         {
             Content model = _services.GetById((int)entity.contentId);
             model.contentMain  = entity.contentMain;
             model.description  = entity.description;
             model.contentId    = entity.contentId;
             model.thumbnail    = entity.thumbnail;
             model.modifiedTime = DateTime.Now;
             model.isSort       = entity.isSort;
             model.name         = entity.name;
             _services.Update(model);
             _services.Save();
         }
         else
         {
             Content model = new Content
             {
                 alias           = entity.alias,
                 name            = entity.name,
                 description     = entity.description,
                 thumbnail       = entity.thumbnail,
                 createTime      = DateTime.Now,
                 modifiedTime    = DateTime.Now,
                 ngayDang        = DateTime.Now,
                 allowComment    = false,
                 approved        = false,
                 approvedTime    = DateTime.Now,
                 approvedUser    = null,
                 authorName      = entity.authorName,
                 contentKey      = "Gallery",
                 contentMain     = entity.contentMain,
                 createUser      = User.Identity.Name,
                 isFeature       = false,
                 isHome          = false,
                 isNew           = false,
                 isSort          = entity.isSort,
                 isTrash         = false,
                 isView          = 0,
                 languageId      = entity.languageId,
                 metaDescription = entity.metaDescription,
                 metaKeyword     = entity.metaKeyword,
                 metaTitle       = entity.metaTitle,
                 modifiedUser    = User.Identity.Name,
                 oldId           = null,
                 parentId        = entity.parentId
             };
             _services.Add(model);
             _services.Save();
             model.alias = model.alias + "-" + model.contentId;
             _services.Update(model);
             _services.Save();
         }
         return(RedirectToAction("Index"));
     }
     return(View(entity));
 }
Ejemplo n.º 3
0
 public ActionResult ThemMoi(ModelLichCongTac model)
 {
     if (ModelState.IsValid)
     {
         Content entity = new Content
         {
             contentAlias      = model.Link,
             contentUpdateTime = DateTime.Now,
             contentParentId   = model.ParentId,
             contentName       = model.Name,
             contentCreateTime = DateTime.Now,
             contentBody       = model.Body,
             isTrash           = false,
             contentView       = 0,
             contentLanguageId = 1,
             contentKey        = "LICHCONGTAC",
             contentCreateUser = User.Identity.Name,
             contentUpdateUser = User.Identity.Name,
             isApproval        = true
         };
         _services.Add(entity);
         _services.Save();
         entity.contentAlias = entity.contentAlias + "-" + entity.contentId;
         _services.Update(entity);
         _services.Save();
         return(RedirectToAction("Index", new { _parentId = entity.contentParentId }));
     }
     if (User.IsInRole("Admin"))
     {
         IEnumerable <DropdownModel> category = _services.Dropdownlist(0, null, "DONVIPHONGKHOA", 1);
         ViewBag.ParentId = category.Select(x => new SelectListItem {
             Text = x.Text, Value = x.Value.ToString()
         });
     }
     else
     {
         var um                  = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext()));
         var user                = um.FindById(User.Identity.GetUserId());
         var _roleUser           = user.Roles.FirstOrDefault();
         ApplicationDbContext db = new ApplicationDbContext();
         var role                = db.Roles.Find(_roleUser.RoleId);
         var _Trained            = _servicesRoleFunction.GetByUserNameCode(role.Name, "TRAINED");
         IEnumerable <DropdownModel> category = _services.Dropdownlist2(_Trained.ChuyenMucId.GetValueOrDefault(), null, "DONVIPHONGKHOA", 1);
         ViewBag.ParentId = category.Select(x => new SelectListItem {
             Text = x.Text, Value = x.Value.ToString()
         });
     }
     return(View(model));
 }
Ejemplo n.º 4
0
        public ActionResult Detail(ModelBanner entity)
        {
            if (ModelState.IsValid)
            {
                if (entity.Id > 0)
                {
                    var model = _services.GetById((int)entity.Id);
                    model.contentDescription = entity.Link;
                    model.contentBody        = entity.BodyContent;
                    model.contentId          = entity.Id;
                    model.contentThumbnail   = entity.Img;
                    model.contentName        = entity.Name;
                    model.contentParentId    = entity.ParentId;
                    model.isSort             = entity.IsSort;
                    _services.Update(model);
                    _services.Save();
                }
                else
                {
                    var model = new Content();
                    model.contentAlias       = entity.Alias;
                    model.contentBody        = entity.BodyContent;
                    model.contentDescription = entity.Link;
                    model.contentId          = entity.Id;
                    model.contentThumbnail   = entity.Img;
                    model.contentUpdateTime  = DateTime.Now;
                    model.contentParentId    = entity.ParentId;
                    model.contentName        = entity.Name;
                    model.contentCreateTime  = DateTime.Now;
                    model.isSort             = entity.IsSort;
                    model.isTrash            = false;
                    model.contentView        = 0;
                    model.contentLanguageId  = 1;
                    model.contentKey         = "BANNER";
                    _services.Add(model);
                    _services.Save();
                    model.contentAlias = model.contentAlias + "-" + model.contentId;
                    _services.Update(model);
                    _services.Save();
                }
                return(RedirectToAction("Index", new { _parentId = entity.ParentId }));
            }
            var category = _services.Dropdownlist(0, (int)entity.Id, "BANNER", _languageId);

            ViewBag.ParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }
Ejemplo n.º 5
0
        public ActionResult Display(string pageUrl, int?_pageIndex)
        {
            var entity = _services.GetByAlias(pageUrl);

            if (entity != null)
            {
                ViewBag.Title  = entity.contentName;
                entity.isView += 1;
                _services.Update(entity);
                _services.Save();
            }
            else
            {
                ViewBag.Title = _configSystemServices.GetValueByKey("SiteTitle");
            }
            return(View(entity));
        }
 public ActionResult Detail(ModelLichCongTac model)
 {
     if (ModelState.IsValid)
     {
         if (model.Id > 0)
         {
             Content entity = _services.GetById((int)model.Id);
             entity.contentAlias      = model.Link;
             entity.contentUpdateTime = DateTime.Now;
             entity.contentParentId   = model.ParentId;
             entity.contentBody       = model.Body;
             entity.contentName       = model.Name;
             entity.contentUpdateUser = User.Identity.Name;
             _services.Update(entity);
             _services.Save();
         }
         else
         {
             Content entity = new Content
             {
                 contentAlias      = model.Link,
                 contentUpdateTime = DateTime.Now,
                 contentParentId   = model.ParentId,
                 contentName       = model.Name,
                 contentCreateTime = DateTime.Now,
                 contentBody       = model.Body,
                 isTrash           = false,
                 contentView       = 0,
                 contentLanguageId = 1,
                 contentKey        = "LICHCONGTACTOANTRUONG",
                 contentCreateUser = User.Identity.Name,
                 contentUpdateUser = User.Identity.Name,
                 isApproval        = true
             };
             _services.Add(entity);
             _services.Save();
             entity.contentAlias = entity.contentAlias + "-" + entity.contentId;
             _services.Update(entity);
             _services.Save();
         }
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Ejemplo n.º 7
0
        public ActionResult ThemMoi(ModelContent model)
        {
            if (ModelState.IsValid)
            {
                Content entity = new Content
                {
                    contentAlias           = model.contentAlias,
                    contentDescription     = model.contentDescription,
                    contentThumbnail       = model.contentThumbnail,
                    contentMetaTitle       = model.contentMetaTitle,
                    contentUpdateTime      = DateTime.Now,
                    contentParentId        = model.contentParentId,
                    contentMetaDescription = model.contentMetaDescription,
                    contentName            = model.contentName,
                    contentCreateTime      = DateTime.Now,
                    isSort              = 1,
                    isTrash             = false,
                    contentView         = 0,
                    contentLanguageId   = 1,
                    contentKey          = "TINDAOTAO",
                    contentCreateUser   = User.Identity.Name,
                    contentMetaKeywords = model.contentMetaKeywords,
                    contentUpdateUser   = User.Identity.Name,
                    contentBody         = model.contentBody,
                    isFeature           = model.isFeature
                };
                _services.Add(entity);
                _services.Save();
                entity.contentAlias = entity.contentAlias + "-" + entity.contentId;
                _services.Update(entity);
                _services.Save();
                return(RedirectToAction("Index", new { _parentId = entity.contentParentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)model.contentId, "CHUYENMUCDAOTAO", 1);

            ViewBag.contentParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(model));
        }
Ejemplo n.º 8
0
        public ActionResult DetailCategory(modelCategories entity)
        {
            if (ModelState.IsValid)
            {
                if (entity.Id > 0)
                {
                    Content model = _services.GetById(entity.Id);
                    if (entity.Alias.Contains("-" + entity.Id))
                    {
                        model.contentAlias = entity.Alias;
                    }
                    else
                    {
                        model.contentAlias = entity.Alias + "-" + entity.Id;
                    }
                    model.contentDescription = entity.MetaDescription;
                    model.contentId          = entity.Id;
                    model.contentThumbnail   = entity.Img;
                    model.contentTitle       = entity.MetaTitle;
                    model.updateTime         = DateTime.Now;
                    model.parentId           = entity.ParentId;
                    model.note        = entity.Note;
                    model.isHome      = entity.IsHome;
                    model.contentName = entity.Name;
                    model.isSort      = entity.No.Value;
                    model.isTrash     = false;
                    model.contentKey  = "cnews";
                    model.isSort      = entity.No.GetValueOrDefault();
                    _services.Update(model);
                    _services.Save();
                    _serviceLog.Add(new ActionLog {
                        actionLogStatus = 1, actionLogTime = DateTime.Now, actionLogType = 1, actionNote = "Cập nhật chuyên mục tin tức Id:" + model.contentId + ":" + model.contentName, userIp = "", userName = User.Identity.Name
                    });
                    _serviceLog.Save();
                }
                else
                {
                    Content model = new Content
                    {
                        contentAlias       = entity.Alias,
                        contentDescription = entity.MetaDescription,
                        contentId          = entity.Id,
                        contentThumbnail   = entity.Img,
                        contentTitle       = entity.MetaTitle,
                        updateTime         = DateTime.Now,
                        parentId           = entity.ParentId,
                        note        = entity.Note,
                        contentName = entity.Name,
                        createTime  = DateTime.Now,
                        ngayBanHanh = DateTime.Now,
                        isSort      = entity.No.GetValueOrDefault(),
                        isHome      = entity.IsHome,
                        isTrash     = false,
                        isView      = 0,
                        languageId  = entity.LanguageId,
                        contentKey  = "cnews"
                    };
                    _services.Add(model);
                    _services.Save();
                    model.contentAlias = model.contentAlias + "-" + model.contentId;
                    _services.Update(model);
                    _services.Save();
                    _serviceLog.Add(new ActionLog {
                        actionLogStatus = 1, actionLogTime = DateTime.Now, actionLogType = 1, actionNote = "Thêm mới chuyên mục tin tức Id:" + model.contentId + ":" + model.contentName, userIp = "", userName = User.Identity.Name
                    });
                    _serviceLog.Save();
                }
                return(RedirectToAction("Category", new { _parentId = entity.ParentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, entity.Id, "cnews", entity.LanguageId);

            ViewBag.ParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }
Ejemplo n.º 9
0
        public ActionResult Detail(Content entity, string NgayViet)
        {
            DateTime _ngayDang = DateTime.Now;

            if (!string.IsNullOrEmpty(NgayViet))
            {
                _ngayDang = DateTime.ParseExact(NgayViet, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            if (ModelState.IsValid)
            {
                if (entity.contentId > 0)
                {
                    Content model = _services.GetById((int)entity.contentId);
                    if (entity.alias.Contains("-" + entity.contentId))
                    {
                        model.alias = entity.alias;
                    }
                    else
                    {
                        model.alias = entity.alias + "-" + entity.contentId;
                    }
                    model.contentMain  = entity.contentMain;
                    model.description  = entity.description;
                    model.contentId    = entity.contentId;
                    model.thumbnail    = entity.thumbnail;
                    model.modifiedTime = DateTime.Now;
                    model.parentId     = entity.parentId;
                    model.name         = entity.name;
                    model.ngayDang     = _ngayDang;
                    model.authorName   = entity.authorName;
                    model.isFeature    = entity.isFeature;
                    _services.Update(model);
                    _services.Save();
                }
                else
                {
                    Content model = new Content
                    {
                        alias           = entity.alias,
                        name            = entity.name,
                        description     = entity.description,
                        thumbnail       = entity.thumbnail,
                        createTime      = DateTime.Now,
                        modifiedTime    = DateTime.Now,
                        ngayDang        = _ngayDang,
                        allowComment    = false,
                        approved        = false,
                        approvedTime    = null,
                        approvedUser    = null,
                        authorName      = entity.authorName,
                        contentKey      = "TinTuc",
                        contentMain     = entity.contentMain,
                        createUser      = User.Identity.Name,
                        isFeature       = entity.isFeature,
                        isHome          = false,
                        isNew           = false,
                        isSort          = 0,
                        isTrash         = false,
                        isView          = 0,
                        languageId      = entity.languageId,
                        metaDescription = entity.metaDescription,
                        metaKeyword     = entity.metaKeyword,
                        metaTitle       = entity.metaTitle,
                        modifiedUser    = User.Identity.Name,
                        oldId           = null,
                        parentId        = entity.parentId
                    };
                    _services.Add(model);
                    _services.Save();
                    model.alias = model.alias + "-" + model.contentId;
                    _services.Update(model);
                    _services.Save();
                }
                return(RedirectToAction("Index", new { _parentId = entity.parentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)entity.contentId, "ChuyenMucTinTuc", entity.languageId);

            ViewBag.contentParentId = category.Select(x => new SelectListItem
            {
                Text  = x.Text,
                Value = x.Value.ToString()
            });
            return(View(entity));
        }
Ejemplo n.º 10
0
        public ActionResult Detail(Content entity)
        {
            if (ModelState.IsValid)
            {
                if (entity.contentId > 0)
                {
                    Content model = _services.GetById((int)entity.contentId);
                    model.alias        = entity.alias;
                    model.contentMain  = entity.contentMain;
                    model.description  = entity.description;
                    model.contentId    = entity.contentId;
                    model.thumbnail    = entity.thumbnail;
                    model.modifiedTime = DateTime.Now;
                    model.parentId     = entity.parentId;
                    model.name         = entity.name;
                    _services.Update(model);
                    _services.Save();
                }
                else
                {
                    Content model = new Content
                    {
                        alias           = entity.alias,
                        name            = entity.name,
                        description     = entity.description,
                        thumbnail       = entity.thumbnail,
                        createTime      = DateTime.Now,
                        modifiedTime    = DateTime.Now,
                        ngayDang        = DateTime.Now,
                        allowComment    = false,
                        approved        = false,
                        approvedTime    = DateTime.Now,
                        approvedUser    = null,
                        authorName      = entity.authorName,
                        contentKey      = "Banner",
                        contentMain     = entity.contentMain,
                        createUser      = User.Identity.Name,
                        isFeature       = false,
                        isHome          = false,
                        isNew           = false,
                        isSort          = 0,
                        isTrash         = false,
                        isView          = 0,
                        languageId      = entity.languageId,
                        metaDescription = entity.metaDescription,
                        metaKeyword     = entity.metaKeyword,
                        metaTitle       = entity.metaTitle,
                        modifiedUser    = User.Identity.Name,
                        oldId           = null,
                        parentId        = entity.parentId
                    };
                    _services.Add(model);
                    _services.Save();
                }
                return(RedirectToAction("Index", new { _parentId = entity.parentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)entity.contentId, "Banner", entity.languageId);

            ViewBag.contentParentId = category.Select(x => new SelectListItem
            {
                Text  = x.Text,
                Value = x.Value.ToString()
            });
            return(View(entity));
        }
Ejemplo n.º 11
0
        public ActionResult Detail(ModelMedia entity)
        {
            if (ModelState.IsValid)
            {
                if (entity.Id > 0)
                {
                    Content model = _services.GetById(entity.Id);
                    model.contentAlias       = entity.Alias;
                    model.contentBody        = entity.BodyContent;
                    model.contentDescription = entity.MetaDescription;
                    model.contentId          = entity.Id;
                    model.contentThumbnail   = entity.Img;
                    model.contentMetaTitle   = entity.MetaTitle;
                    if (string.IsNullOrEmpty(entity.CreateTime))
                    {
                        model.contentUpdateTime = DateTime.Now;
                    }
                    else
                    {
                        model.contentUpdateTime = DateTime.ParseExact(entity.CreateTime, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }

                    model.contentParentId    = entity.ParentId;
                    model.authorize          = entity.TacGia;
                    model.contentDescription = entity.Note;
                    model.contentName        = entity.Name;
                    model.isSort             = entity.Sort;
                    _services.Update(model);
                    _services.Save();
                }
                else
                {
                    Content model = new Content
                    {
                        contentAlias       = entity.Alias,
                        contentBody        = entity.BodyContent,
                        contentDescription = entity.MetaDescription,
                        contentId          = entity.Id,
                        contentThumbnail   = entity.Img,
                        contentMetaTitle   = entity.MetaTitle
                    };
                    if (string.IsNullOrEmpty(entity.CreateTime))
                    {
                        model.contentUpdateTime = DateTime.Now;
                    }
                    else
                    {
                        model.contentUpdateTime = DateTime.ParseExact(entity.CreateTime, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }

                    model.contentParentId    = entity.ParentId;
                    model.contentDescription = entity.Note;
                    model.contentName        = entity.Name;
                    model.contentCreateTime  = DateTime.Now;
                    model.isSort             = entity.Sort;
                    model.isTrash            = false;
                    model.contentView        = 0;
                    model.authorize          = entity.TacGia;
                    model.contentLanguageId  = 1;
                    model.contentKey         = "MEDIA";
                    _services.Add(model);
                    _services.Save();
                    model.contentAlias = model.contentAlias + "-" + model.contentId;
                    _services.Update(model);
                    _services.Save();
                }
                return(RedirectToAction("Index", new { _parentId = entity.ParentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, entity.Id, "CHUYENMUCMEDIA", 1);

            ViewBag.ParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }
Ejemplo n.º 12
0
        public ActionResult Detail(modelSuKienAnh entity)
        {
            if (ModelState.IsValid)
            {
                if (entity.Id > 0)
                {
                    Content model = _services.GetById(entity.Id);
                    if (entity.Alias.Contains("-" + entity.Id))
                    {
                        model.contentAlias = entity.Alias;
                    }
                    else
                    {
                        model.contentAlias = entity.Alias + "-" + entity.Id;
                    }
                    model.contentBody        = entity.BodyContent;
                    model.contentDescription = entity.MetaDescription;
                    model.contentId          = entity.Id;
                    model.contentThumbnail   = entity.Img;
                    model.contentTitle       = entity.MetaTitle;
                    if (string.IsNullOrEmpty(entity.CreateTime))
                    {
                        model.updateTime = DateTime.Now;
                    }
                    else
                    {
                        model.updateTime = DateTime.ParseExact(entity.CreateTime, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }
                    model.parentId    = entity.ParentId;
                    model.note        = entity.Note;
                    model.tacGia      = entity.TacGia;
                    model.isSort      = entity.Sort;
                    model.contentName = entity.Name;
                    model.contentKey  = "SuKienQuaAnh";
                    _services.Update(model);
                    _services.Save();
                    _serviceLog.Add(new ActionLog {
                        actionLogStatus = 1, actionLogTime = DateTime.Now, actionLogType = 1, actionNote = "Cập nhật sựa kiên qua ảnh Id:" + model.contentId + ":" + model.contentName, userIp = "", userName = User.Identity.Name
                    });
                    _serviceLog.Save();
                }
                else
                {
                    Content model = new Content
                    {
                        contentAlias       = entity.Alias,
                        contentBody        = entity.BodyContent,
                        contentDescription = entity.MetaDescription,
                        contentId          = entity.Id,
                        contentThumbnail   = entity.Img,
                        contentTitle       = entity.MetaTitle
                    };
                    if (string.IsNullOrEmpty(entity.CreateTime))
                    {
                        model.updateTime = DateTime.Now;
                    }
                    else
                    {
                        model.updateTime = DateTime.ParseExact(entity.CreateTime, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }

                    model.parentId    = entity.ParentId;
                    model.note        = entity.Note;
                    model.tacGia      = entity.TacGia;
                    model.contentName = entity.Name;
                    model.createTime  = DateTime.Now; model.ngayBanHanh = DateTime.Now;
                    model.isSort      = entity.Sort;
                    model.isTrash     = false;
                    model.isView      = 0;
                    model.languageId  = entity.LanguageId;
                    model.approval    = false;
                    model.contentKey  = "SuKienQuaAnh";
                    _services.Add(model);
                    _services.Save();
                    model.contentAlias = model.contentAlias + "-" + model.contentId;
                    _services.Update(model);
                    _services.Save();
                    _serviceLog.Add(new ActionLog {
                        actionLogStatus = 1, actionLogTime = DateTime.Now, actionLogType = 1, actionNote = "Thêm mới sự kiện qua ảnh Id:" + model.contentId + ":" + model.contentName, userIp = "", userName = User.Identity.Name
                    });
                    _serviceLog.Save();
                }
                return(RedirectToAction("Index", new { _parentId = entity.ParentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, entity.Id, "csukienquaanh", entity.LanguageId);

            ViewBag.ParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }
Ejemplo n.º 13
0
        public ActionResult Detail(ModelContent entity)
        {
            if (ModelState.IsValid)
            {
                if (entity.contentId > 0)
                {
                    Content model = _services.GetById((int)entity.contentId);
                    model.contentAlias       = entity.contentAlias;
                    model.contentBody        = entity.contentBody;
                    model.contentDescription = entity.contentDescription;
                    model.contentId          = entity.contentId;
                    model.contentThumbnail   = entity.contentThumbnail;
                    model.contentMetaTitle   = entity.contentMetaTitle;
                    model.contentUpdateTime  = DateTime.Now;
                    if (string.IsNullOrEmpty(entity.contentCreateTime))
                    {
                        model.contentCreateTime = DateTime.Now;
                    }
                    else
                    {
                        model.contentCreateTime = DateTime.ParseExact(entity.contentCreateTime, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }
                    model.contentParentId   = entity.contentParentId;
                    model.contentName       = entity.contentName;
                    model.contentUpdateUser = User.Identity.Name;
                    model.isNew             = entity.isNew;
                    model.isFeature         = entity.isFeature;
                    model.isApproval        = checkAdmin();
                    _services.Update(model);
                    _services.Save();
                }
                else
                {
                    Content model = new Content
                    {
                        contentAlias       = entity.contentAlias,
                        contentBody        = entity.contentBody,
                        contentDescription = entity.contentDescription,
                        contentId          = entity.contentId,
                        contentThumbnail   = entity.contentThumbnail,
                        contentMetaTitle   = entity.contentMetaTitle
                    };
                    model.contentUpdateTime = DateTime.Now;
                    model.contentParentId   = entity.contentParentId;
                    model.contentName       = entity.contentName;
                    if (string.IsNullOrEmpty(entity.contentCreateTime))
                    {
                        model.contentCreateTime = DateTime.Now;
                    }
                    else
                    {
                        model.contentCreateTime = DateTime.ParseExact(entity.contentCreateTime, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    }
                    model.isTrash           = false;
                    model.contentView       = 0;
                    model.contentLanguageId = 1;
                    model.contentUpdateUser = User.Identity.Name;
                    model.contentCreateUser = User.Identity.Name;
                    model.authorize         = entity.authorize;
                    model.contentKey        = "TINTUC";
                    model.isNew             = entity.isNew;
                    model.isFeature         = entity.isFeature;
                    _services.Add(model);
                    _services.Save();
                    model.contentAlias = model.contentAlias + "-" + model.contentId;
                    _services.Update(model);
                    _services.Save();
                }
                return(RedirectToAction("Index", new { _parentId = entity.contentParentId }));
            }
            IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)entity.contentId, "CHUYENMUCTINTUC", 1);

            ViewBag.contentParentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(entity));
        }
Ejemplo n.º 14
0
 public ActionResult Detail(Content entity, HttpPostedFileBase fileVideo)
 {
     if (ModelState.IsValid)
     {
         string _fileName = "";
         try
         {
             if (fileVideo.ContentLength > 0)
             {
                 _fileName = Path.GetFileName(fileVideo.FileName);
                 string _path = Path.Combine(Server.MapPath("~/FileVideo"), _fileName);
                 fileVideo.SaveAs(_path);
             }
         }
         catch
         {
         }
         if (entity.contentId > 0)
         {
             Content model = _services.GetById((int)entity.contentId);
             model.contentMain = entity.contentMain;
             if (!string.IsNullOrEmpty(_fileName))
             {
                 model.description = _fileName;
             }
             model.contentId    = entity.contentId;
             model.thumbnail    = entity.thumbnail;
             model.modifiedTime = DateTime.Now;
             model.isSort       = entity.isSort;
             model.name         = entity.name;
             _services.Update(model);
             _services.Save();
         }
         else
         {
             Content model = new Content
             {
                 alias           = entity.alias,
                 name            = entity.name,
                 description     = _fileName,
                 thumbnail       = entity.thumbnail,
                 createTime      = DateTime.Now,
                 modifiedTime    = DateTime.Now,
                 ngayDang        = DateTime.Now,
                 allowComment    = false,
                 approved        = false,
                 approvedTime    = DateTime.Now,
                 approvedUser    = null,
                 authorName      = entity.authorName,
                 contentKey      = "Video",
                 contentMain     = entity.contentMain,
                 createUser      = User.Identity.Name,
                 isFeature       = false,
                 isHome          = false,
                 isNew           = false,
                 isSort          = entity.isSort,
                 isTrash         = false,
                 isView          = 0,
                 languageId      = entity.languageId,
                 metaDescription = entity.metaDescription,
                 metaKeyword     = entity.metaKeyword,
                 metaTitle       = entity.metaTitle,
                 modifiedUser    = User.Identity.Name,
                 oldId           = null,
                 parentId        = entity.parentId
             };
             _services.Add(model);
             _services.Save();
             model.alias = model.alias + "-" + model.contentId;
             _services.Update(model);
             _services.Save();
         }
         return(RedirectToAction("Index"));
     }
     return(View(entity));
 }