Exemplo n.º 1
0
        public ActionResult Add()
        {
            var vCategory = new VideoCategoryIM()
            {
                Active     = true,
                Importance = 0
            };

            return(PartialView("_Add", vCategory));
        }
Exemplo n.º 2
0
        public JsonResult Edit(VideoCategoryIM vm)
        {
            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }
            //var newCategory = _categoryServices.GetById(vm.Id);
            //newCategory.Title = vm.Title;
            //newCategory.SeoName = vm.SeoName;
            //newCategory.Importance = vm.Importance;
            //newCategory.Active = vm.Active;
            //newCategory.UpdatedBy = Site.CurrentUserName;
            //newCategory.UpdatedDate = DateTime.Now;
            var newCategory = _mapper.Map <VideoCategoryIM, VideoCategory>(vm);

            _categoryServices.Update(newCategory);

            var pageMeta = _pageMetaServices.GetPageMeta(ModelType.VIDEOCATEGORY, vm.Id.ToString());

            pageMeta = pageMeta ?? new PageMeta();

            pageMeta.ObjectId    = vm.Id.ToString();
            pageMeta.Title       = string.IsNullOrEmpty(vm.SEOTitle) ? vm.Title : vm.SEOTitle;
            pageMeta.Keyword     = string.IsNullOrEmpty(vm.Keywords) ? vm.Title : vm.Keywords.Replace(',', ',');
            pageMeta.Description = vm.SEODescription;
            pageMeta.ModelType   = ModelType.VIDEOCATEGORY;

            if (pageMeta.Id > 0)
            {
                _pageMetaServices.Update(pageMeta);
            }
            else
            {
                _pageMetaServices.Create(pageMeta);
            }


            //   var category = _mapper.Map<VideoCategoryVM>(newCategory);
            AR.Id   = newCategory.Id;
            AR.Data = RenderPartialViewToString("_CategoryItem", newCategory);

            AR.SetSuccess(String.Format(Messages.AlertUpdateSuccess, EntityNames.VideoCategory));
            return(Json(AR, JsonRequestBehavior.DenyGet));
        }
Exemplo n.º 3
0
        public JsonResult Add(VideoCategoryIM vm)
        {
            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }

            var newCategory = _mapper.Map <VideoCategoryIM, VideoCategory>(vm);
            //newCategory.CreatedBy = Site.CurrentUserName;
            //newCategory.CreatedDate = DateTime.Now;

            var result = _categoryServices.Create(newCategory);

            if (result != null)
            {
                var pageMeta = new PageMeta()
                {
                    ObjectId    = result.ToString(),
                    Title       = string.IsNullOrEmpty(vm.SEOTitle) ? vm.Title : vm.SEOTitle,
                    Keyword     = string.IsNullOrEmpty(vm.Keywords) ? vm.Title : vm.Keywords.Replace(',', ','),
                    Description = vm.SEODescription,
                    ModelType   = ModelType.VIDEOCATEGORY
                };
                _pageMetaServices.Create(pageMeta);
            }


            int count;
            var pageSize = SettingsManager.Video.PageSize;
            var list     = _categoryServices.GetPagedElements(0, pageSize, string.Empty, out count);

            AR.Data = RenderPartialViewToString("_CategoryList", list);
            AR.SetSuccess(String.Format(Messages.AlertCreateSuccess, EntityNames.VideoCategory));
            return(Json(AR, JsonRequestBehavior.DenyGet));
        }