protected virtual void deleteObject(Type type, int id, BaseNoun parent = null) { if (parent != null && parent.Id <= 0) { throw new RESTAPIException("Parent noun (" + parent + ") must have a valid id"); } HttpWebResponse response = null; try { string restUrl = _serverURL + Constant.REST_BASE_PATH; if (parent != null) { restUrl += "/" + Noun.Base.BaseNoun.GetNoun(parent.GetType()) + "/" + parent.Id; } restUrl += "/" + Noun.Base.BaseNoun.GetNoun(type) + "/" + id; response = getRESTResponse(restUrl, "DELETE"); } finally { if (response != null) { response.Close(); } } }
// Initiates the test public void init() { Category projectCategory = GetProjectCategoryId(); ProjectKeywordCategory projectKeywordCategory = CreateProjectKeywordCategory(); ProjectKeyword projectKeyword = CreateProjectKeyword(projectKeywordCategory.Id); Field projectField = CreateField("project"); Field imageField = CreateField("image"); Project project = CreateProject(projectKeyword, projectField); KeywordCategory keywordCategory = CreateKeywordCategory(projectCategory.Id); Keyword keyword = CreateKeyword(keywordCategory.Id); Photographer photographer = CreatePhotographer(); AccessLevel accessLevel = GetRandomAccessLevel(); CopyrightPolicy copyrightPolicy = CreateCopyrightPolicy(); CopyrightHolder copyrightHolder = CreateCopyrightHolder(copyrightPolicy.Id); File file = UploadFile(projectCategory, project, imageField, keyword, photographer, accessLevel, copyrightHolder); Album album = CreateAlbum(file); bool isHeroImage = AttachHeroImage(file, project); List <Search> searches = CreateSearches(file, keywordCategory, keyword, imageField, photographer, copyrightHolder, accessLevel, project, album); if (VerifySearches(searches, file)) { BaseNoun[] nouns; if (superUser) { nouns = new BaseNoun[] { file, photographer, copyrightHolder, copyrightPolicy, album, keyword, keywordCategory, imageField, projectField, projectKeyword, projectKeywordCategory, project }; } else { nouns = new BaseNoun[] { file, album, keyword, keywordCategory, imageField, projectField, projectKeyword, projectKeywordCategory, project }; } if (this.deleteObjects) { DeleteNouns(nouns); } } }
public virtual void DeleteObject(BaseNoun noun, BaseNoun parent = null) { deleteObject(noun.GetType(), noun.Id, parent); }