/// <summary> /// Deletes the specified tag. /// </summary> /// <param name="request">The request.</param> /// <returns> /// <c>DeleteTagResponse</c> with success status. /// </returns> public DeleteTagResponse Delete(DeleteTagRequest request) { if (request.Data == null || request.Id.HasDefaultValue()) { return(new DeleteTagResponse { Data = false }); } var itemToDelete = repository .AsQueryable <Module.Root.Models.Tag>() .Where(p => p.Id == request.Id) .FirstOne(); if (request.Data.Version > 0 && itemToDelete.Version != request.Data.Version) { throw new ConcurrentDataException(itemToDelete); } unitOfWork.BeginTransaction(); repository.Delete(itemToDelete); unitOfWork.Commit(); Events.RootEvents.Instance.OnTagDeleted(itemToDelete); return(new DeleteTagResponse { Data = true }); }
protected override void ProcessRecord() { base.ProcessRecord(); if (!ConfirmDelete("OCIIdentityTag", "Remove")) { return; } DeleteTagRequest request; try { request = new DeleteTagRequest { TagNamespaceId = TagNamespaceId, TagName = TagName, IfMatch = IfMatch }; response = client.DeleteTag(request).GetAwaiter().GetResult(); WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId)); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public ResponseMessage DeleteTag(DeleteTagRequest request) { ResponseMessage responseMessage = new ResponseMessage(); try { if (request.Id <= 0) { responseMessage.Errors.Add("The Id value is 0 or less"); } else { _context.Tag.Remove(new ToDoList.Entities.TagEntity { Id = request.Id }); _context.SaveChanges(); } if (!responseMessage.IsOk) { return(responseMessage); } } catch (Exception msg) { responseMessage.Errors.Add(msg.Message); } if (!responseMessage.IsOk) { return(responseMessage); } return(responseMessage); }
public DeleteTagResponse DeleteOpportunityTag(DeleteTagRequest request) { Logger.Current.Verbose("Request to delete the contact Tag."); Tag tag; if (request.TagId == 0) { tag = tagRepository.FindBy(request.TagName, request.AccountId); } else { tag = tagRepository.FindBy(request.TagId); } if (tag != null) { tagRepository.DeleteOpportunityTag(tag.Id, request.OpportunityID); unitOfWork.Commit(); //int count = indexingService.RemoveTag(tag.Id, tag.AccountID); //Logger.Current.Verbose("Removed the tag " + tag.Id + " from elastic search. Response count from elastic search" + count); return(new DeleteTagResponse()); } else { return(new DeleteTagResponse() { Exception = GetTagNotFoundException() }); } }
private static void DeleteTag(KmsClient kmsClient) { try { var req = new DeleteTagRequest { VersionId = "v1.0", KeyId = GetKeyByStatus.GetKeyByKeyStatus(kmsClient, "2"), Key = "key" }; var resp = kmsClient.DeleteTag(req); Console.WriteLine(resp.HttpStatusCode); } catch (RequestTimeoutException requestTimeoutException) { Console.WriteLine(requestTimeoutException.ErrorMessage); } catch (ServiceResponseException clientRequestException) { Console.WriteLine(clientRequestException.HttpStatusCode); Console.WriteLine(clientRequestException.ErrorCode); Console.WriteLine(clientRequestException.ErrorMsg); } catch (ConnectionException connectionException) { Console.WriteLine(connectionException.ErrorMessage); } }
public void Multiple() { var service = new DeleteTagService { RequestBuilder = ServerRequestBuilder.Instance }; var request = new DeleteTagRequest { Tag = "tag1" }; service.Execute(request, response => Debug.WriteLine("Deleted"), ExceptionHandler.Handle); }
/// <summary> /// 删除密钥标签 /// </summary> public async Task <DeleteTagResponse> DeleteTagAsync(DeleteTagRequest deleteTagRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("key_id", deleteTagRequest.KeyId.ToString()); urlParam.Add("key", deleteTagRequest.Key.ToString()); urlParam.Add("version_id", deleteTagRequest.VersionId.ToString()); string urlPath = HttpUtils.AddUrlPath("/{version_id}/{project_id}/kms/{key_id}/tags/{key}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", deleteTagRequest); HttpResponseMessage response = await DoHttpRequestAsync("DELETE", request); return(JsonUtils.DeSerializeNull <DeleteTagResponse>(response)); }
/// <summary>Snippet for DeleteTag</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void DeleteTagRequestObject() { // Create client DataCatalogClient dataCatalogClient = DataCatalogClient.Create(); // Initialize request argument(s) DeleteTagRequest request = new DeleteTagRequest { EntryName = EntryName.FromProjectLocationEntryGroupEntry("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]", "[ENTRY]"), }; // Make the request dataCatalogClient.DeleteTag(request); }
/// <summary> /// 删除资源标签 /// </summary> public DeleteTagResponse DeleteTag(DeleteTagRequest deleteTagRequest) { Dictionary <string, string> urlParam = new Dictionary <string, string>(); urlParam.Add("resource_type", deleteTagRequest.ResourceType.ToString()); urlParam.Add("resource_id", deleteTagRequest.ResourceId.ToString()); urlParam.Add("key", deleteTagRequest.Key.ToString()); string urlPath = HttpUtils.AddUrlPath("/v2/{project_id}/{resource_type}/{resource_id}/tags/{key}", urlParam); SdkRequest request = HttpUtils.InitSdkRequest(urlPath, "application/json", deleteTagRequest); HttpResponseMessage response = DoHttpRequestSync("DELETE", request); return(JsonUtils.DeSerializeNull <DeleteTagResponse>(response)); }
public async Task <IActionResult> Untag(string productName, string featureName, string tag, CancellationToken cancellationToken = default) { var request = new DeleteTagRequest() { ProductName = productName, FeatureName = featureName, Tag = tag }; await _mediator.Send(request, cancellationToken); return(NoContent()); }
public async Task <TagResponse> Handle(DeleteTagRequest request) { var tag = await _tagRepository.ReadById(request.TagId); if (tag == default) { throw new ArgumentNullException(nameof(tag)); } _tagRepository.Delete(tag); await _tagRepository.PersistChanges(); return(tag.Adapt <TagResponse>()); }
public async Task <IActionResult> Delete([BindRequired] long?tagId) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Index))); } var deleteTagRequest = new DeleteTagRequest { TagId = tagId.Value }; var response = await _tagApplicationService.Handle(deleteTagRequest); return(RedirectToAction(nameof(Index))); }
/// <summary> /// 本接口用于删除一对标签键和标签值 /// </summary> /// <param name="req"><see cref="DeleteTagRequest"/></param> /// <returns><see cref="DeleteTagResponse"/></returns> public DeleteTagResponse DeleteTagSync(DeleteTagRequest req) { JsonResponseModel <DeleteTagResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "DeleteTag"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteTagResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
public void Tags() { var service = new DeleteTagService { RequestBuilder = RequestBuilderHelper.Build() }; var helper = new AsyncTestHelper(); var request = new DeleteTagRequest { Tag = "myTag" }; service.Execute(request, response => helper.Callback(null), helper.HandleException); helper.Wait(); }
public DeleteTagResponse DeleteTag(DeleteTagRequest request) { Logger.Current.Verbose("Request to delete the contact Tag."); Tag tag;; if (request.TagId == 0) { tag = tagRepository.FindBy(request.TagName, request.AccountId); } else { tag = tagRepository.FindBy(request.TagId); } if (tag != null) { tagRepository.DeleteForContact(tag.Id, request.ContactID, request.AccountId); unitOfWork.Commit(); if (request.ContactID != 0) { contactService.ContactIndexing(new ContactIndexingRequest() { ContactIds = new List <int>() { request.ContactID }, Ids = new Dictionary <int, bool>() { { request.ContactID, true } }.ToLookup(o => o.Key, o => o.Value) }); } addToTopic(tag.Id, request.AccountId, request.ContactID, 0, false); return(new DeleteTagResponse()); } else { return(new DeleteTagResponse() { Exception = GetTagNotFoundException() }); } }
public async Task <ServiceResponse> DeleteTag(DeleteTagRequest request) { try { var tag = await _fileSystem.GetTag(request.Path, request.Name); if (tag == null) { throw new Exception($"Tag is not found: {request.Path} - {request.Name}"); } await _fileSystem.DeleteTag(tag); return(new ServiceResponse()); } catch (Exception exception) { _logger.LogWarning(exception, $"Could not delete tag: {request.Path} - {request.Name}"); return(new ServiceResponse <IFile>(exception)); } }
public async void TestDelete() { String accessToken = this.RandomString(); String etag = this.RandomString(); String tagId = this.RandomString(); DeleteTagRequest req = new DeleteTagRequest(); req.TagId = tagId; req.Etag = etag; MockAPI <Tags> mock = this.MockFor <Tags>( HttpMethod.Post, "/api/v1/tags.delete", m => m.WithContent(req.ToString()) .Respond("application/json", req.ToString()) ); APIResponse <dynamic> res = await mock.Instance.Delete(accessToken, tagId, etag, null); mock.Handler.VerifyNoOutstandingExpectation(); Assert.Equal(System.Net.HttpStatusCode.OK, res.Status); }
public IActionResult DeleteTag([FromBody] DeleteTagRequest request) { if (request == null) { return(BadRequest(new ErrorViewModel { ErrorCode = "400", ErrorMessage = "Please provide input information correctly." })); } if (request.TagId <= 0) { return(BadRequest(new ErrorViewModel { ErrorCode = "400", ErrorMessage = "Tag not found" })); } var tag = _tagRepository.FindById(request.TagId); if (tag == null) { return(BadRequest(new ErrorViewModel { ErrorCode = "400", ErrorMessage = "Tag not found" })); } var response = _tagServices.DeleteTag(tag); if (response != "OK") { return(BadRequest("Can not execute. Plz contact admin")); } return(Ok(response)); }
public async Task <ActionResult <DeleteTagResult> > DeleteTag([FromBody] DeleteTagRequest request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, Types.SitePermissions.WxUsers)) { return(Unauthorized()); } List <WxUserTag> tags = null; var(success, token, _) = await _wxManager.GetAccessTokenAsync(request.SiteId); if (success) { await _wxManager.DeleteUserTag(token, request.TagId); tags = await _wxManager.GetUserTagsAsync(token); } return(new DeleteTagResult { Tags = tags }); }
public async Task <IActionResult> Untag([FromRoute] DeleteTagRequest request, CancellationToken cancellationToken = default) { await _mediator.Send(request, cancellationToken); return(NoContent()); }
public async Task DeleteAsync(DeleteTagRequest request) => await _httpFacade.Delete($"{TagsBaseUrl(request.ProjectId)}/{request.TagName}");
/// <remarks/> public System.IAsyncResult BegindeleteTag(DeleteTagRequest DeleteTagRequest, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("deleteTag", new object[] { DeleteTagRequest}, callback, asyncState); }
/// <remarks/> public void deleteTagAsync(DeleteTagRequest DeleteTagRequest) { this.deleteTagAsync(DeleteTagRequest, null); }
/// <remarks/> public void deleteTagAsync(DeleteTagRequest DeleteTagRequest, object userState) { if ((this.deleteTagOperationCompleted == null)) { this.deleteTagOperationCompleted = new System.Threading.SendOrPostCallback(this.OndeleteTagOperationCompleted); } this.InvokeAsync("deleteTag", new object[] { DeleteTagRequest}, this.deleteTagOperationCompleted, userState); }
/// <summary> /// Deletes the specified tag. /// </summary> /// <param name="request">The request.</param> /// <returns> /// <c>DeleteTagResponse</c> with success status. /// </returns> public DeleteTagResponse Delete(DeleteTagRequest request) { if (request.Data == null || request.Id.HasDefaultValue()) { return new DeleteTagResponse { Data = false }; } var itemToDelete = repository .AsQueryable<Module.Root.Models.Tag>() .Where(p => p.Id == request.Id) .FirstOne(); if (request.Data.Version > 0 && itemToDelete.Version != request.Data.Version) { throw new ConcurrentDataException(itemToDelete); } unitOfWork.BeginTransaction(); repository.Delete(itemToDelete); unitOfWork.Commit(); Events.RootEvents.Instance.OnTagDeleted(itemToDelete); return new DeleteTagResponse { Data = true }; }