/// <summary> /// Deletes the group. /// </summary> /// <param name="itemRequestModel"></param> /// <param name="webUrl">The web URL.</param> /// <param name="accessToken">The access token.</param> /// <param name="currentUserEmail"></param> /// <param name="isUserAdmin"></param> /// <returns></returns> public override Group Delete(ItemRequestModel itemRequestModel, string webUrl, string accessToken, string currentUserEmail, bool isUserAdmin) { var group = itemRequestModel.Group; // User cannot delete a group they do not own if (!IsOwnerOrDesignee(group, currentUserEmail) && !isUserAdmin) { throw new Exception("You do not have permission to delete this group."); } // Non-admin cannot delete a locked group if (group.IsLocked && !isUserAdmin) { throw new Exception("You cannot delete a locked item."); } try { ProcessChildGroups(group, webUrl, accessToken); var deletedGroup = _groupRepository.Get(webUrl, group.Id, accessToken, SpApiConstants.Lists.GROUP_EXPAND); _groupRepository.Delete(webUrl, accessToken, group.Id); return(deletedGroup); } catch (Exception) { throw new Exception("Failed to delete group"); } }
/// <summary> /// Deletes the specified clause. /// </summary> public override Clause Delete(ItemRequestModel itemRequestModel, string webUrl, string accessToken, string currentUserEmail, bool isUserAdmin) { var clause = itemRequestModel.Clause; // User cannot delete a clause they do not own unless they are admin if (!IsOwnerOrDesignee(clause, currentUserEmail) && !isUserAdmin) { throw new Exception("You do not have permission to delete this clause."); } if (clause.IsLocked && !isUserAdmin) { throw new Exception("You cannot delete a locked item."); } try { var deletedClause = _clauseRepository.Get(webUrl, clause.Id, accessToken, SpApiConstants.Lists.CLAUSE_EXPAND); _clauseRepository.Delete(webUrl, accessToken, clause.Id); return(deletedClause); } catch (Exception) { throw new Exception("Failed to delete clause"); } }
public void Delete_ShouldRemoveTheItemFromTheDatabase() { IListItemsRepository repo = GetInMemoryListItemRepository(); var idToDelete = 1; repo.Delete(idToDelete); Assert.Null(repo.Get(idToDelete)); }
/// <summary> /// Deletes an external link /// </summary> /// <param name="externalLinkId"></param> /// <param name="webUrl"></param> /// <param name="accessToken"></param> public string DeleteExternalLink(int externalLinkId, string webUrl, string accessToken) { try { return(_externalLinksRepository.Delete(webUrl, accessToken, externalLinkId)); } catch (Exception) { throw new Exception("An error occured while deleting the link."); } }
public void Delete_ShouldKeepAllOtherItemsInTheDatebase() { IListItemsRepository repo = GetInMemoryListItemRepository(); var countBeforeDelete = repo.Get().Count(); var idToDelete = 1; repo.Delete(idToDelete); var countAfterDelete = repo.Get().Count(); Assert.NotEqual(countBeforeDelete, countAfterDelete); Assert.True(countAfterDelete == (countBeforeDelete - 1)); }
public virtual string Delete(string webUrl, int id, bool isLocked = false, string accessToken = "") { accessToken = GetAccessToken(accessToken); return(Repository.Delete(webUrl, accessToken, id)); }