public void Delete(Guid libraryId, DocumentGetOptions options) { var documentId = options.Id.HasValue ? options.Id.Value.ToString(CultureInfo.InvariantCulture) : options.ContentId.ToString("N"); var documentBeforeDelete = Get(libraryId, options); if (documentBeforeDelete == null) { return; } try { Events.OnBeforeDelete(documentBeforeDelete); } catch (Exception ex) { string message = string.Format("An exception of type {0} occurred in the PublicApi.Documents.Events.OnBeforeDelete() method for LibraryId: {1}, DocumentId: {2}. The exception message is: {3}", ex.GetType(), libraryId, documentId, ex.Message); SPLog.UnKnownError(ex, message); } listItemService.Delete(libraryId, options); ExpireTags(libraryId); try { Events.OnAfterDelete(documentBeforeDelete); } catch (Exception ex) { string message = string.Format("An exception of type {0} occurred in the PublicApi.Documents.Events.OnAfterDelete() method for LibraryId: {1}, DocumentId: {2}. The exception message is: {3}", ex.GetType(), libraryId, documentId, ex.Message); SPLog.UnKnownError(ex, message); } }
public async Task <IActionResult> DeleteConfirmed(int id) { var listItem = await _listItemService.GetById(id); await _listItemService.Delete(listItem); return(RedirectToAction("Details", "ShoppingLists", new { id = listItem.ShoppingListId })); }
public ActionResult Delete(int id) { if (!CheckPermission(ListsPermissions.ManageLists)) { return(new HttpUnauthorizedResult()); } var listItem = listItemService.GetById(id); listItemService.Delete(listItem); return(new AjaxResult().NotifyMessage("DELETE_ENTITY_COMPLETE")); }
public void Delete(Guid listId, SPListItemDeleteOptions options) { var itemsToDelete = new List <SPListItem>(); if (options.ItemIds != null && options.ItemIds.Count > 0) { itemsToDelete.AddRange(options.ItemIds.Select(id => Get(listId, new SPListItemGetOptions(id) { Url = options.Url }))); } if (options.ContentIds != null && options.ContentIds.Count > 0) { itemsToDelete.AddRange(options.ContentIds.Select(id => Get(listId, new SPListItemGetOptions(id) { Url = options.Url }))); } var contentIds = itemsToDelete.Select(item => item.ContentId).ToList(); try { itemsToDelete.ForEach(Events.OnBeforeDelete); } catch (Exception ex) { var ids = string.Join(", ", contentIds); string message = string.Format("An exception of type {0} occurred in the PublicApi.ListItems.Events.OnBeforeDelete() method ContentIds: {1}. The exception message is: {2}", ex.GetType(), ids, ex.Message); SPLog.UnKnownError(ex, message); } listItemService.Delete(listId, options); ExpireTags(listId); try { itemsToDelete.ForEach(Events.OnAfterDelete); } catch (Exception ex) { var ids = string.Join(", ", contentIds); string message = string.Format("An exception of type {0} occurred in the PublicApi.ListItems.Events.OnAfterDelete() method ContentIds: {1}. The exception message is: {2}", ex.GetType(), ids, ex.Message); SPLog.UnKnownError(ex, message); } }
public void DeleteListItem(ListItemModel listItemModel) { _log.Debug("userId={0}, {1}", userId, listItemModel); _listItemService.Delete(listItemModel.Id, listItemModel.ShoppingListId); Clients.Group(listItemModel.ShoppingListId.ToString()).listItemDeleted(listItemModel.Id); }