public ActionResult Delete(int id) { ContentEntity content = _contentService.GetContentById(id); if (content == null) { return(HttpNotFound()); } _contentService.Delete(content); return(RedirectToAction("Index", "Home", null)); }
public ActionResult Delete(int id, ContentViewModel collection) { try { if (id > 0) { collection.UpdaterId = LogedInAdmin.Id; _contentService.Delete(_mapper.Map <Content>(collection)); return(RedirectToAction("Index")); } ModelState.AddModelError(string.Empty, GeneralMessages.EmptyId); return(View(collection)); } catch (Exception ex) { _logger.Error(ex); if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource)) { ModelState.AddModelError(string.Empty, ex.Message); } else { ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError); } return(View(collection)); } }
// GET: API/CleanupEvents public object Index() { var results = _eventSearchService.GetVenueEvents(new GetEventsConfiguration { EarliestDate = DateTime.MinValue, LatestDate = _dateTimeProvider.Now().AddDays(-3) }); foreach (var publishedContent in results) { var startDate = _umbracoWrapper.GetPropertyValue <DateTime>(publishedContent, "contentStartDateTime"); Log($"Deleting event: {publishedContent.Id}|{publishedContent.Name}|{startDate:yyyy MMMM dd}"); var content = _contentService.GetById(publishedContent.Id); RemoveEventMedia(content); _contentService.Delete(content); } _duplicatesService.RemoveDuplicates(); ExamineManager.Instance.RebuildIndex(); // TODO: Make some generic API Response type //return JsonConvert.SerializeObject(new ApiSuccessResponse(results)); return(results.Count()); }
public IActionResult Delete(int id) { var deleteRow = _IContentService.Delete(id); var delete = _uow.SaveChanges(); return(Json(delete)); }
private void SavePlaylistItems(IList <PlaylistItem> playlistContentItems, string playlist, IContentService contentService) { var playlistContentInformation = GetPlaylistContentInformation(playlist); if (playlistContentInformation.PlaylistId <= default(int)) { return; } foreach (var currentPlaylistItem in playlistContentInformation.PlaylistItemsContent) { var currentPlaylistItemContent = contentService.GetById(currentPlaylistItem.Id); contentService.Delete(currentPlaylistItemContent); } foreach (var playlistContentItem in playlistContentItems) { var content = contentService.Create(playlistContentItem.PlaylistItemTitle, playlistContentInformation.PlaylistId, DocumentTypes.PlaylistItem); content.SetValue(PropertyAliases.PlaylistItem.PlaylistItemTitle, playlistContentItem.PlaylistItemTitle); content.SetValue(PropertyAliases.PlaylistItem.PlaylistItemThumbnailUrl, playlistContentItem.PlaylistItemThumbnailUrl); content.SetValue(PropertyAliases.PlaylistItem.PlaylistItemVideoUrl, playlistContentItem.PlaylistItemVideoUrl); content.SetValue(PropertyAliases.PlaylistItem.PlaylistUploadDate, playlistContentItem.PlaylistUploadDate); contentService.SaveAndPublish(content); } }
public ActionResult Delete(int id) { var content = _contentService.GetById(id); _contentService.Delete(content); return(Ok(content)); }
public async Task <IActionResult> Delete(int id) { await _contentManager.Delete(id); TempData["message"] = "İçerik Silindi"; return(RedirectToAction("List")); }
private void DeleteExistedMailTemplates() { var mailTemplateFolderXpath = XPathHelper.GetXpath( _documentTypeAliasProvider.GetDataFolder(), _documentTypeAliasProvider.GetMailTemplateFolder()); var publishedContent = _umbracoHelper.TypedContentSingleAtXPath(mailTemplateFolderXpath); if (publishedContent == null) { return; } bool IsForRemove(IPublishedContent content) { var templateType = content.GetPropertyValue <NotificationTypeEnum>(UmbracoContentMigrationConstants.MailTemplate.EmailTypePropName); return(templateType.In(NotificationTypeEnum.CommentLikeAdded, NotificationTypeEnum.MonthlyMail)); } var publishedContentToRemove = publishedContent.Children.Where(IsForRemove); var contentToRemove = _contentService.GetByIds(publishedContentToRemove.Select(c => c.Id)).ToList(); contentToRemove.ForEach(c => _contentService.Delete(c)); }
private void Delete(IPublishedContent publishedContent) { var content = _contentService.GetById(publishedContent.Id); if (content != null) { _contentService.Delete(content); } }
private void DeleteAllVideos(IEnumerable <Video> videos) { foreach (var video in videos) { var videoContent = _contentService.GetById(video.Id); _contentService.Unpublish(videoContent); _contentService.Delete(videoContent); } }
public IActionResult Delete(Content content) { var result = _contentService.Delete(content); if (result.Success) { return(View(result)); } return(BadRequest(result.Message)); }
public IActionResult DeleteContent(int contentId) { Content content = _contentService.GetContentById(contentId); if (content != null) { _contentService.Delete(content); } return(RedirectToAction("Index")); }
public static void InitDelete(IContentService service, Func <int, IContent> GetById, Func <IEnumerable <int>, IEnumerable <IContent> > GetByIds, bool emptyAfterDelete = true) { if (emptyAfterDelete) { EmptyBin = () => service.EmptyRecycleBin(); } DeleteContent = DefaultDeleteContent(b => service.Delete(b), EmptyBin); DeleteContentById = DefaultDeleteContentById(GetById, DeleteContent); DeleteContentsByIds = DefaultDeleteContentsByIds(DeleteContentById); DeleteContents = DefaultDeleteContents(DeleteContent); }
public ActionResult DeleteArticle(int id) { var content = contentService.GetById(id); if (content != null) { contentService.Delete(content); return(Redirect("/")); } return(RedirectToCurrentUmbracoPage()); }
/// <inheritdoc /> public void DeleteContent(Guid contentId, CancellationToken cancellationToken) { var content = _contentService.GetById(contentId); if (content is not null) { if (!_contentService.Delete(content).Success) { _logger.LogWarning("Unable to delete content {ContentId}. Content does not exist.", contentId); } } }
public ActionResult Delete(int Id) { try { ContentService.Delete(Id); string Message = "Material deleted"; InternalNotification.Success(Message); } catch (Exception ex) { InternalNotification.Error(ex); } return(RedirectToAction("index")); }
public bool Delete(int id) { var entity = _ContentService.GetContentById(id); if (entity == null) { return(false); } if (_ContentService.Delete(entity)) { return(true); } return(false); }
protected override void DeleteItem(IContent item) { try { contentService.Delete(item); } catch (ArgumentNullException ex) { // we can get thrown a null argument exception by the notifer, // which is non critical! but we are ignoring this error. ! <= 8.1.5 if (!ex.Message.Contains("siteUri")) { throw ex; } } }
public async Task <JsonResult> Delete(short id) { try { var content = await _contentService.GetAll().FirstOrDefaultAsync(c => c.Id == id); await _contentService.Delete(content); return(new JsonResult(new { result = true })); } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 删除内容数据 /// </summary> /// <param name="form"></param> /// <returns></returns> public async Task <HandleResult> Delete([FromBody] JObject form) { string columnNum = form["columnNum"].ToStr(); if (!(form["ids"] is JArray ids) || ids.Count <= 0 || columnNum.IsEmpty()) { return(HandleResult.Error("无效数据")); } var cm = await _columnService.GetModelByNum(columnNum); if (cm == null || cm?.ModelTable == null) { return(HandleResult.Error("无效参数")); } return(await _service.Delete(cm?.ModelTable.SqlTableName, ids.Select(temp => temp.ToInt()).ToList())); }
public ActionResult Delete(ContentViewModel viewModel) { try { if (ModelState.IsValid) { var entity = Mapper.Map <ContentViewModel, Content>(viewModel); _contentService.Delete(entity); return(RedirectToAction("Index")); } } catch (Exception e) { ModelState.AddModelError("", e.Message); } return(View(viewModel)); }
public HttpResponseMessage Delete(int id) { var content = _contentService.GetContentById(id); if (content.Resources != null && content.Resources.Any()) { return(PageHelper.toJson(PageHelper.ReturnValue(false, "有资源关联无法删除!"))); } else { if (_contentService.Delete(content)) { return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据删除成功!"))); } else { return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据删除失败!"))); } } }
public ActionResult Delete(Guid contentId, Guid languageId) { try { _serviceContent.Delete(contentId, languageId); return(Ok()); } catch (InvalidTransactionException exception) { ModelState.AddModelError("ErrorMessage", exception.Message); return(BadRequest(ModelState)); } catch (Exception) { ModelState.AddModelError("ErrorMessage", Messages.DangerRecordNotFound); return(BadRequest(ModelState)); } }
public ExecutionResult Execute() { var mailTemplateXpath = XPathHelper.GetXpath( _documentTypeAliasProvider.GetDataFolder(), _documentTypeAliasProvider.GetMailTemplateFolder(), _documentTypeAliasProvider.GetMailTemplate()); var templates = _umbracoHelper.TypedContentAtXPath(mailTemplateXpath); var mailTemplateFolderXpath = XPathHelper.GetXpath(_documentTypeAliasProvider.GetDataFolder(), _documentTypeAliasProvider.GetMailTemplateFolder()); if (!templates.Any()) { var folder = _umbracoHelper.TypedContentSingleAtXPath(mailTemplateFolderXpath); if (folder != null) { var folderContent = _contentService.GetById(folder.Id); _contentService.Delete(folderContent); } } return(ExecutionResult.Success); }
/// <summary> /// Deletes the content specified by id. /// </summary> /// <param name="id">The node id to delete.</param> /// <param name="deletePermanently">if set to <c>true</c>, node will be deleted without moving to Trash (otherwise items is moved to Trash).</param> public static void DeleteContent(int id, bool deletePermanently) { ContentService.Delete(ContentService.GetById(id)); }
public async Task <IActionResult> Delete(int id) { await _contentService.Delete(id, _operatingUser.GetUserId(HttpContext)); return(Ok()); }
public bool DeleteItem(IContent node, QueuedItem queuedItem) { _logger.Info <PublishQueueService>("Deleting: {0}", () => node.Name); _contentService.Delete(node, queuedItem.UserId); return(true); }
public IActionResult Delete(int id, string type, string categoryId) { _contentService.Delete(id); return RedirectToAction("Index", new { type = type, categoryId }); }
protected override void DeleteItem(IContent item) => contentService.Delete(item);
public IActionResult Delete(Guid id) { _contentService.Delete(id); return(Ok()); }