public virtual ActionResult Draft(Page newModel, string old_key, bool?preview, bool?published) { JsonResultEntry result = new JsonResultEntry(); try { newModel.Site = Site; var old = Manager.Get(Site, old_key); SavePosition(newModel); newModel.Published = false; newModel.UserName = User.Identity.Name; Manager.PageProvider.SaveAsDraft(newModel); if (published.HasValue && published.Value == true) { Manager.Publish(old, true, User.Identity.Name); result.RedirectUrl = GetReturnUrl(); } result.AddMessage("The item has been saved.".Localize()); } catch (Exception e) { result.AddException(e); } return(Json(result)); }
public virtual ActionResult ResetAll(string schemaName, FormType CurrentFormType) { JsonResultEntry resultEntry = new JsonResultEntry(ModelState); try { Schema schema = new Schema(Repository, schemaName); var formTypes = Enum.GetValues(typeof(FormType)); List <object> formList = new List <object>(); foreach (var t in formTypes) { formList.Add(new { Body = schema.GenerateForm((FormType)t), FormType = t.ToString() }); } resultEntry.Model = formList; } catch (Exception e) { resultEntry.AddException(e); } return(Json(resultEntry)); }
public virtual ActionResult Delete(string directoryPath, IEnumerable <string> filePaths, IEnumerable <string> directoryPaths) { var entry = new JsonResultEntry(); try { if (filePaths != null) { foreach (var f in filePaths) { FileManager.DeleteFile(Site, f); } } if (directoryPaths != null) { foreach (var d in directoryPaths) { FileManager.DeleteDirectory(Site, d); } } //entry.SetSuccess(); } catch (Exception e) { entry.SetFailed().AddException(e); } return(Json(entry)); }
public virtual ActionResult Upload(string file) { var entry = new JsonResultEntry(); try { if (ModelState.IsValid) { var files = this.HttpContext.Request.Files; if (files.Count == 0 || files[0].ContentLength == 0 || !files[0].FileName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)) { throw new KoobooException("Please upload a dll file."); } AssemblyManager.Upload(this.Site, files[0].FileName, files[0].InputStream); } else { entry.AddModelState(ModelState); } } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public virtual ActionResult Create(Schema schema, bool?finish) { JsonResultEntry resultEntry = new JsonResultEntry(ModelState); try { if (ModelState.IsValid) { Manager.Add(Repository, schema); this.ResetAllForm(schema.Name); if (finish.Value == true) { resultEntry.RedirectUrl = this.Url.Action("Index", Request.RequestContext.AllRouteValues().Merge("schemaName", schema.Name)); } else { resultEntry.RedirectUrl = this.Url.Action("Templates", Request.RequestContext.AllRouteValues().Merge("schemaName", schema.Name)); } } } catch (Exception e) { resultEntry.AddException(e); } return(Json(resultEntry)); }
public ActionResult Create(Slide model) { var resultEntry = new JsonResultEntry() { Success = false }; if (model != null) { var createBy = ""; model.Language = Culture; if (UserState != null && !CUtils.IsNullOrEmpty(UserState.UserName)) { createBy = CUtils.StrTrim(UserState.UserName); } model.CreateBy = createBy; SlideManager.Add(model); resultEntry.Success = true; resultEntry.AddMessage("Tạo mới Side thành công!"); resultEntry.RedirectUrl = Url.Action("Create", "Slide", new { area = "Auth" }); } else { resultEntry.Detail = "dư lieu null"; } return(Json(resultEntry)); }
public virtual ActionResult Edit(string folderName) { JsonResultEntry entry = new JsonResultEntry(); if (ModelState.IsValid) { try { var old = FolderManager.Get(Repository, folderName); var @new = FolderManager.Get(Repository, folderName); TryUpdateModel(@new); FolderManager.Update(Repository, @new, old); entry.Model = new { folderName = @new.FullName }; } catch (Exception e) { entry.AddException(e); } } else { entry.AddModelState(ModelState); } return(Json(entry)); }
public virtual ActionResult Delete(string[] model) { var entry = new JsonResultEntry(); try { foreach (var f in model) { if (string.IsNullOrEmpty(f)) { continue; } var folderPathArr = FolderHelper.SplitFullName(f); Manager.Remove(Repository, new TextFolder(Repository, folderPathArr)); } entry.SetSuccess(); } catch (Exception e) { entry.SetFailed().AddException(e); } return(Json(entry)); //return RedirectToIndex(); }
public virtual ActionResult Edit(T newModel, string old_key) { JsonResultEntry resultEntry = new JsonResultEntry() { Success = true }; try { if (ModelState.IsValid) { Update(newModel, old_key); //var fromPop = ControllerContext.RequestContext.GetRequestValue("FromPop"); //if (string.IsNullOrWhiteSpace(fromPop)) //{ // return RedirectToIndex(newModel.ToString()); //} } } catch (Exception e) { resultEntry.SetFailed().AddException(e); } resultEntry.AddModelState(ViewData.ModelState); return(Json(resultEntry)); }
public override ActionResult Create(CMS.Sites.Models.View model) { JsonResultEntry resultEntry = new JsonResultEntry() { Success = true }; try { if (ModelState.IsValid) { model.UserName = User.Identity.Name; Add(model); var pageRedirect = Request.Form["pageRedirect"] ?? ""; resultEntry.SetSuccess().RedirectUrl = pageRedirect.ToLower() == "false" ? Url.Action("Edit", ControllerContext.RequestContext.AllRouteValues().Merge("Name", model.Name)) : Url.Action("Index", this.ControllerContext.RequestContext.AllRouteValues()); } else { resultEntry.AddModelState(ModelState).SetFailed(); } } catch (Exception e) { resultEntry.SetFailed().AddException(e); } resultEntry.AddModelState(ViewData.ModelState); return Json(resultEntry); }
public virtual ActionResult Edit(TextFolder model, string fullName, string successController) { JsonResultEntry resultEntry = new JsonResultEntry() { Success = true }; try { if (ModelState.IsValid) { fullName = string.IsNullOrEmpty(fullName) ? model.FullName : fullName; var old = Manager.Get(Repository, fullName); model.Parent = old.Parent; Manager.Update(Repository, model, old); var fromPop = ControllerContext.RequestContext.GetRequestValue("FromPop"); resultEntry.Success = true; } } catch (Exception e) { resultEntry.SetFailed().AddException(e); } resultEntry.AddModelState(ViewData.ModelState); return(Json(resultEntry)); }
public override ActionResult Edit(CMS.Sites.Models.View newModel, string old_key) { JsonResultEntry entry = new JsonResultEntry(); try { if (ModelState.IsValid) { newModel.UserName = User.Identity.Name; Update(newModel, old_key); var pageRedirect = Request.Form["pageRedirect"]; entry.AddMessage("The item has been saved.".Localize()).SetSuccess().RedirectUrl = string.Equals(pageRedirect, "true", StringComparison.OrdinalIgnoreCase) ? this.Url.Action("Index", this.ControllerContext.RequestContext.AllRouteValues()) : null; } else { entry.AddModelState(ModelState); } } catch (Exception e) { entry.AddException(e); } return Json(entry); }
public ActionResult Create(Location model) { var resultEntry = new JsonResultEntry() { Success = false }; if (model != null) { var createBy = ""; if (UserState != null && !CUtils.IsNullOrEmpty(UserState.UserName)) { createBy = CUtils.StrTrim(UserState.UserName); } model.CreateBy = createBy; model.LocationValue = model.LocationName.ToUrlSegment(250).ToLower(); model.Culture = Culture; ServiceFactory.LocationManager.Add(model); resultEntry.Success = true; resultEntry.AddMessage("Tạo mới quận/huyện thành công!"); resultEntry.RedirectUrl = Url.Action("Create", "Location", new { area = "Auth", locationDiscountId = model.LocationDiscountId }); } else { resultEntry.Detail = "dư lieu null"; } return(Json(resultEntry)); }
public virtual ActionResult Ajax(LoginModel loginModel, int redirect) { var resultData = new JsonResultEntry(); try { if (UserServices.ValidateUser(loginModel.UserName, loginModel.Password) != null) { System.Web.Security.FormsAuthentication.SetAuthCookie(loginModel.UserName, loginModel.RememberMe); if (redirect == 0) { resultData.RedirectUrl = Request.UrlReferrer.ToString(); } else { resultData.RedirectUrl = System.Web.Security.FormsAuthentication.DefaultUrl; } } else { ModelState.AddModelError("UserName", "Username and/or password are incorrect.".Localize()); } resultData.AddModelState(ModelState); } catch (Exception e) { resultData.AddException(e); } return(Json(resultData)); }
public virtual ActionResult Rebroadcast(string folderName, string parentFolder, string[] docArr, string[] folderArr) { JsonResultEntry entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); if (docArr != null) { foreach (var doc in docArr) { if (string.IsNullOrEmpty(doc)) { continue; } var textContent = textFolder.CreateQuery().WhereEquals("UUID", doc).FirstOrDefault(); if (textContent != null) { Kooboo.CMS.Content.EventBus.Content.ContentEvent.Fire(ContentAction.Add, textContent); } } } entry.SetSuccess(); } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public ActionResult Create(Manufacters model) { var resultEntry = new JsonResultEntry() { Success = false }; if (model != null) { var createBy = ""; if (UserState != null && !CUtils.IsNullOrEmpty(UserState.UserName)) { createBy = CUtils.StrTrim(UserState.UserName); } model.CreateBy = createBy; model.ManufactShortName = model.ManufactName.ToUrlSegment(250).ToLower(); model.Culture = Culture; ServiceFactory.ManufacterManager.Add(model); resultEntry.Success = true; resultEntry.AddMessage("Tạo mới nhà sản xuất thành công!"); resultEntry.RedirectUrl = Url.Action("Create", "Manufacter", new { area = "Auth" }); } else { resultEntry.Detail = "dư lieu null"; } return(Json(resultEntry)); }
public virtual ActionResult PostFile() { var entry = new JsonResultEntry(); try { if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { var postFile = Request.Files[0]; var tempPath = Kooboo.Web.Url.UrlUtility.Combine(Site.VirtualPath, "Temp"); Kooboo.IO.IOUtility.EnsureDirectoryExists(Server.MapPath(tempPath)); var fileUrl = Kooboo.Web.Url.UrlUtility.Combine(tempPath, Guid.NewGuid() + Path.GetFileName(postFile.FileName)); postFile.SaveAs(Server.MapPath(fileUrl)); entry.Model = Url.Content(fileUrl); } else { entry.SetFailed().AddMessage("It is not a valid image file.".Localize()); } } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public virtual ActionResult Publish(string folderName, string parentFolder, string uuid) { var entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); TextContent textContent = schema.CreateQuery().WhereEquals("UUID", uuid).FirstOrDefault(); var published = (bool?)textContent["Published"]; if (published.HasValue && published.Value == true) { ServiceFactory.TextContentManager.Update(Repository, schema, uuid, new string[] { "Published" }, new object[] { false }, User.Identity.Name); } else { ServiceFactory.TextContentManager.Update(Repository, schema, uuid, new string[] { "Published" }, new object[] { true }, User.Identity.Name); } } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public virtual ActionResult Create(MediaFolder model, string folderName) { var entry = new JsonResultEntry(); if (ModelState.IsValid) { try { MediaFolder parent = null; if (!string.IsNullOrEmpty(folderName)) { parent = FolderHelper.Parse <MediaFolder>(Repository, folderName).AsActual(); } model.Parent = parent; FolderManager.Add(Repository, model); } catch (Exception e) { entry.AddException(e); } } else { entry.AddModelState(ModelState); } return(Json(entry)); }
public virtual ActionResult BatchUnpublish(string folderName, string parentFolder, string[] docArr) { JsonResultEntry entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); if (docArr != null) { foreach (var doc in docArr) { if (string.IsNullOrEmpty(doc)) { continue; } ServiceFactory.TextContentManager.Update(Repository, schema, doc, new string[] { "Published" }, new object[] { false }, User.Identity.Name); } } entry.SetSuccess(); } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public virtual ActionResult CopyContent(string schema, string uuid) { var result = new JsonResultEntry(); try { var content = Kooboo.CMS.Content.Services.ServiceFactory.TextContentManager.Copy(new Schema(Repository.Current, schema), uuid); result.Model = new { uuid = content.UUID, schema = content.SchemaName, published = string.Empty, editUrl = Url.Action("Edit", new { controller = "TextContent", Area = "Contents", RepositoryName = content.Repository, SiteName = Site.FullName, FolderName = content.FolderName, UUID = content.UUID }), summary = HttpUtility.HtmlAttributeEncode(content.GetSummary()) }; } catch (Exception e) { result.AddException(e); } return(Json(result)); }
public virtual ActionResult TempFile() { var entry = new JsonResultEntry(); try { if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { var postFile = Request.Files[0]; var repositoryPath = new RepositoryPath(Repository); var tempPath = Kooboo.Web.Url.UrlUtility.Combine(repositoryPath.VirtualPath, "Temp"); Kooboo.IO.IOUtility.EnsureDirectoryExists(Server.MapPath(tempPath)); var fileUrl = Kooboo.Web.Url.UrlUtility.Combine(tempPath, UniqueIdGenerator.GetInstance().GetBase32UniqueId(24) + Path.GetExtension(postFile.FileName)); postFile.SaveAs(Server.MapPath(fileUrl)); entry.Model = Url.Content(fileUrl); } else { entry.SetFailed().AddMessage("It is not a valid image file.".Localize()); } } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public virtual ActionResult Delete(AssemblyFile[] model) { var entry = new JsonResultEntry(); try { if (model != null) { foreach (var fileName in model) { if (!string.IsNullOrEmpty(fileName.FileName)) { AssemblyManager.Delete(Site, fileName.FileName); } } } entry.SetSuccess(); } catch (Exception e) { entry.SetFailed().AddException(e); } return(Json(entry)); //return RedirectToAction("Index"); }
public virtual ActionResult CrossPageSort(ContentSorter sourceContent, string folderName, int?page, int?pageSize, bool up = true) { var entry = new JsonResultEntry(); try { //page = page ?? 1; //pageSize = pageSize ?? 50; var textFolder = new TextFolder(Repository, folderName); var content = new TextFolder(Repository, folderName).CreateQuery().WhereEquals("UUID", sourceContent.UUID).FirstOrDefault(); TextContent destContent; if (up) { destContent = content.Previous(); } else { destContent = content.Next(); } if (destContent != null) { ServiceFactory.TextContentManager.Update(textFolder, sourceContent.UUID, "Sequence", destContent["Sequence"], User.Identity.Name); ServiceFactory.TextContentManager.Update(textFolder, destContent.UUID, "Sequence", content["Sequence"], User.Identity.Name); } } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public virtual ActionResult Edit(Schema newModel, string old_key, bool?finish, bool Next, bool resetAll) { JsonResultEntry resultEntry = new JsonResultEntry(ModelState); try { if (ModelState.IsValid) { var oldModel = Manager.Get(Repository, old_key); Manager.Update(Repository, newModel, oldModel); if (resetAll) { ResetAllForm(newModel.Name); } if (finish.Value == true) { resultEntry.RedirectUrl = this.Url.Action("Index", Request.RequestContext.AllRouteValues().Merge("schemaName", newModel.Name)); } else { resultEntry.RedirectUrl = this.Url.Action("Templates", Request.RequestContext.AllRouteValues().Merge("schemaName", newModel.Name)); } //} } } catch (Exception e) { resultEntry.AddException(e); } return(Json(resultEntry)); }
public virtual ActionResult ReconfigContent(IEnumerable <ContentSorter> list, string folderName, string uuid, string parentUUID) { JsonResultEntry entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); if (!string.IsNullOrEmpty(uuid) && string.Compare(uuid, parentUUID, true) != 0) { ServiceFactory.TextContentManager.Update(textFolder, uuid, new[] { "ParentUUID", "ParentFolder" }, new[] { parentUUID, folderName }, User.Identity.Name); } var schema = textFolder.GetSchema().AsActual(); foreach (var c in list) { ServiceFactory.TextContentManager.Update(Repository, schema, c.UUID, new string[] { "Sequence" }, new object[] { c.Sequence }, User.Identity.Name); } } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public virtual ActionResult Delete(Element[] model, ElementCategory[] categoryList) { JsonResultEntry entry = new JsonResultEntry(); try { var category = ControllerContext.RequestContext.GetRequestValue("Category"); if (model != null) { foreach (var m in model) { m.Category = category; Remove(m); } } if (categoryList != null) { foreach (var c in categoryList) { Manager.RemoveCategory(Site, c.Category); } } } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public virtual ActionResult Copy(string folderName, string parentFolder, string[] docArr, string[] folderArr) { JsonResultEntry entry = new JsonResultEntry(); try { TextFolder textFolder = new TextFolder(Repository, folderName).AsActual(); var schema = textFolder.GetSchema().AsActual(); if (docArr != null) { foreach (var doc in docArr) { if (string.IsNullOrEmpty(doc)) { continue; } ServiceFactory.TextContentManager.Copy(textFolder.GetSchema(), doc); } } entry.ReloadPage = true; entry.SetSuccess(); } catch (Exception e) { entry.AddException(e); } return(Json(entry)); }
public ActionResult Create(News model) { var resultEntry = new JsonResultEntry() { Success = false }; if (model != null) { model.Language = Culture; model.NewShortName = model.NewTitle.ToUrlSegment(250).ToLower(); var createBy = ""; if (UserState != null && !CUtils.IsNullOrEmpty(UserState.UserName)) { createBy = CUtils.StrTrim(UserState.UserName); } model.CreateBy = createBy; resultEntry.Success = true; resultEntry.AddMessage("Tạo mới tin tức thành công!"); resultEntry.RedirectUrl = Url.Action("Create", "News", new { area = "Auth" }); } else { resultEntry.Detail = "dư lieu null"; } return(Json(resultEntry)); }
public ActionResult Update(Customer model) { var resultEntry = new JsonResultEntry() { Success = false }; var exitsData = ""; if (model != null && !CUtils.IsNullOrEmpty(model.CustomerId)) { var customs = CustomerManager.Get(new Customer() { CustomerId = model.CustomerId }); if (customs != null) { CustomerManager.Update(model, customs); resultEntry.Success = true; resultEntry.AddMessage("Cập nhật khách hàng thành công!"); resultEntry.RedirectUrl = Url.Action("Search", "Customer", new { area = "Auth" }); } else { resultEntry.Success = true; exitsData = "Mã danh mục '" + model.CustomerId + "' không có trong hệ thống!"; } } else { resultEntry.Success = true; exitsData = "Mã danh mục trống!"; } resultEntry.AddMessage(exitsData); return(Json(resultEntry)); }