public ActionResult PublishTextContent(CreateTextContentPublishingQueueViewModel model, string @return) { var resultEntry = new JsonResultData(ModelState); if (ModelState.IsValid) { if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue) { resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty."); } else { TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual(); for (int i = 0, j = model.TextContents.Length; i < j; i++) { var content = textFolder.CreateQuery().WhereEquals("UUID", model.TextContents[i]).FirstOrDefault(); if (content != null) { foreach (string mapping in model.TextFolderMappings) { var queue = new RemotePublishingQueue() { PublishingObject = PublishingObject.TextContent, SiteName = Site.Name, UserId = User.Identity.Name, UtcCreationDate = DateTime.UtcNow, TextFolderMapping = mapping, ObjectUUID = content.IntegrateId, ObjectTitle = model.ObjectTitles[i], Status = QueueStatus.Pending }; if (model.Schedule) { if (model.UtcTimeToPublish.HasValue) { queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime(); } if (model.UtcTimeToUnpublish.HasValue) { queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime(); } } else { queue.UtcTimeToPublish = DateTime.UtcNow; } resultEntry.RunWithTry((data) => { _manager.Add(queue); }); } } } resultEntry.RedirectUrl = @return; } } return(Json(resultEntry)); }
public ActionResult PublishTextContent(CreateTextContentPublishingQueueViewModel model, string @return) { var resultEntry = new JsonResultData(ModelState); if (ModelState.IsValid) { if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue) { resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty".Localize()); } else if (model.Schedule) { TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual(); for (int i = 0, j = model.TextContents.Length; i < j; i++) { var content = textFolder.CreateQuery().WhereEquals("UUID", model.TextContents[i]).FirstOrDefault(); var queue = new LocalPublishingQueue(Site, Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10)) { PublishingObject = PublishingObject.TextContent, UserId = User.Identity.Name, UtcCreationDate = DateTime.UtcNow, ObjectUUID = content.IntegrateId, ObjectTitle = model.ObjectTitles[i], Status = QueueStatus.Pending }; if (model.UtcTimeToPublish.HasValue) { queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime(); } if (model.UtcTimeToUnpublish.HasValue) { queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime(); } resultEntry.RunWithTry((data) => { _manager.Add(queue); }); } resultEntry.RedirectUrl = @return; } else { TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual(); foreach (string uuid in model.TextContents) { Kooboo.CMS.Content.Services.ServiceFactory.TextContentManager.Update(textFolder, uuid, "Published", true, User.Identity.Name); } resultEntry.RedirectUrl = @return; } } return(Json(resultEntry)); }