public JsonResult Edit(ChronicleIM vm) { if (!ModelState.IsValid) { AR.Setfailure(GetModelErrorMessage()); return(Json(AR, JsonRequestBehavior.DenyGet)); } var old = _chronicleService.GetById(vm.Id); var chronicle = _mapper.Map(vm, old); //chronicle.Active = vm.Active; //chronicle.Year = vm.Year; //chronicle.Title = vm.Title; //chronicle.Month = vm.Month; //chronicle.Day = vm.Day; //chronicle = _mapper.Map<ChronicleIM, Chronicle>(vm); _chronicleService.Update(chronicle); var pageMeta = _pageMetaServices.GetPageMeta(ModelType.CHRONICLE, chronicle.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.CHRONICLE; if (pageMeta.Id > 0) { _pageMetaServices.Update(pageMeta); } else { _pageMetaServices.Create(pageMeta); } var chronicleVM = _mapper.Map <ChronicleVM>(chronicle); AR.Id = chronicle.Id; AR.Data = RenderPartialViewToString("_ChronicleItem", chronicleVM); AR.SetSuccess(String.Format(Messages.AlertUpdateSuccess, EntityNames.Chronicle)); return(Json(AR, JsonRequestBehavior.DenyGet)); }
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)); }
public async Task <JsonResult> Edit(VideoIM vm) { if (!ModelState.IsValid) { AR.Setfailure(GetModelErrorMessage()); return(Json(AR, JsonRequestBehavior.DenyGet)); } var video = _mapper.Map <VideoIM, Video>(vm); _videoServices.Update(video); var pageMeta = _pageMetaServices.GetPageMeta(ModelType.VIDEO, 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.Description; pageMeta.ModelType = ModelType.VIDEO; if (pageMeta.Id > 0) { _pageMetaServices.Update(pageMeta); } else { _pageMetaServices.Create(pageMeta); } // var videoVM = _mapper.Map<VideoVM>(video); AR.Id = video.Id; var data = await _videoServices.GetByIdWidthCategoryAsync(video.Id); AR.Data = RenderPartialViewToString("_VideoItem", data); AR.SetSuccess(String.Format(Messages.AlertUpdateSuccess, EntityNames.Video)); return(Json(AR, JsonRequestBehavior.DenyGet)); }
public JsonResult Edit(LinkCategoryIM vm) { if (!ModelState.IsValid) { AR.Setfailure(GetModelErrorMessage()); return(Json(AR, JsonRequestBehavior.DenyGet)); } var old = _categoryServices.GetById(vm.Id); var newCategory = _mapper.Map(vm, old); _categoryServices.Update(newCategory); var pageMeta = _pageMetaServices.GetPageMeta(ModelType.ARTICLECATEGORY, 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.ARTICLECATEGORY; if (pageMeta.Id > 0) { _pageMetaServices.Update(pageMeta); } else { _pageMetaServices.Create(pageMeta); } // var category = _mapper.Map<LinkCategoryVM>(newCategory); AR.Id = newCategory.Id; AR.Data = RenderPartialViewToString("_CategoryItem", newCategory); AR.SetSuccess(String.Format(Messages.AlertUpdateSuccess, EntityNames.LinkCategory)); return(Json(AR, JsonRequestBehavior.DenyGet)); }