public IActionResult DeleteProject([FromBody] DeleteProjectRequest request) { var client = GetProjectClient(); client.RemoveProject(request.Id); return(Json(new { })); }
public async Task <BaseResponses <string> > Handle(DeleteProjectRequest request, CancellationToken cancellationToken) { BaseResponses <string> responce = null; using (var trx = unitOfWork.BeginTransaction()) { try { var project = await projectService.GetById(request.ProjectId); if (project.Status != Statuses.Confirmed.ToString()) { var result = await projectService.Delete(request.ProjectId); unitOfWork.SaveChanges(); responce = new BaseResponses <string>(result); } } catch (Exception ex) { trx.Rollback(); responce = new BaseResponses <string>(System.Net.HttpStatusCode.BadRequest, ex.Message); } return(responce); } }
public void DeletaProjetoComSucesso() { #region Inserindo um novo projeto string projectName = "DeletaProjetoComSucesso"; var projetoCriadoDB = projectsDBSteps.InseriProjetoDB(projectName); #endregion #region Parameters //Resultado Esperado string statusCodeExpected = "OK"; string statusDescriptionExpected = "Project with id " + projetoCriadoDB.ProjectId + " deleted."; #endregion DeleteProjectRequest deleteProjectRequest = new DeleteProjectRequest(projetoCriadoDB.ProjectId); IRestResponse <dynamic> response = deleteProjectRequest.ExecuteRequest(); var consultaProjetoDB = projectsDBSteps.ConsultaProjetoDB(projetoCriadoDB.ProjectId); Assert.Multiple(() => { Assert.AreEqual(statusCodeExpected, response.StatusCode.ToString(), "O StatusCode não é o esperado."); Assert.AreEqual(statusDescriptionExpected, response.StatusDescription, "O StatusDescription não é o esperado."); Assert.IsNull(consultaProjetoDB, "Um registro foi encontrado no banco de dados."); }); }
protected override void ProcessRecord() { base.ProcessRecord(); if (!ConfirmDelete("OCIDataintegrationProject", "Remove")) { return; } DeleteProjectRequest request; try { request = new DeleteProjectRequest { WorkspaceId = WorkspaceId, ProjectKey = ProjectKey, IfMatch = IfMatch, OpcRequestId = OpcRequestId }; response = client.DeleteProject(request).GetAwaiter().GetResult(); WriteOutput(response); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
protected override void ProcessRecord() { base.ProcessRecord(); if (!ConfirmDelete("OCIAianomalydetectionProject", "Remove")) { return; } DeleteProjectRequest request; try { request = new DeleteProjectRequest { ProjectId = ProjectId, IfMatch = IfMatch, OpcRequestId = OpcRequestId }; response = client.DeleteProject(request).GetAwaiter().GetResult(); WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId)); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
private async static Task DeleteProject(ProjectServiceDefinition.ProjectServiceDefinitionClient projectClient) { var input = new DeleteProjectRequest { Id = 2 }; var reply = await projectClient.DeleteProjectAsync(input); }
/// <summary> /// Delets a project in AWS Mobile Hub. /// </summary> /// <param name="request">Container for the necessary parameters to execute the DeleteProject service method.</param> /// /// <returns>The response from the DeleteProject service method, as returned by Mobile.</returns> /// <exception cref="Amazon.Mobile.Model.InternalFailureException"> /// The service has encountered an unexpected error condition which prevents it from /// servicing the request. /// </exception> /// <exception cref="Amazon.Mobile.Model.NotFoundException"> /// No entity can be found with the specified identifier. /// </exception> /// <exception cref="Amazon.Mobile.Model.ServiceUnavailableException"> /// The service is temporarily unavailable. The request should be retried after some /// time delay. /// </exception> /// <exception cref="Amazon.Mobile.Model.TooManyRequestsException"> /// Too many requests have been received for this AWS account in too short a time. The /// request should be retried after some time delay. /// </exception> /// <exception cref="Amazon.Mobile.Model.UnauthorizedException"> /// Credentials of the caller are insufficient to authorize the request. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mobile-2017-07-01/DeleteProject">REST API Reference for DeleteProject Operation</seealso> public DeleteProjectResponse DeleteProject(DeleteProjectRequest request) { var marshaller = new DeleteProjectRequestMarshaller(); var unmarshaller = DeleteProjectResponseUnmarshaller.Instance; return(Invoke <DeleteProjectRequest, DeleteProjectResponse>(request, marshaller, unmarshaller)); }
internal virtual DeleteProjectResponse DeleteProject(DeleteProjectRequest request) { var marshaller = DeleteProjectRequestMarshaller.Instance; var unmarshaller = DeleteProjectResponseUnmarshaller.Instance; return(Invoke <DeleteProjectRequest, DeleteProjectResponse>(request, marshaller, unmarshaller)); }
public IActionResult DeleteProject([FromBody] DeleteProjectRequest request) { using (var client = GetRestClient()) { client.DeleteProject(request.Id); return(Json(new { })); } }
/// <summary> /// Initiates the asynchronous execution of the DeleteProject operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteProject operation on AmazonMobileClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteProject /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mobile-2017-07-01/DeleteProject">REST API Reference for DeleteProject Operation</seealso> public virtual IAsyncResult BeginDeleteProject(DeleteProjectRequest request, AsyncCallback callback, object state) { var marshaller = DeleteProjectRequestMarshaller.Instance; var unmarshaller = DeleteProjectResponseUnmarshaller.Instance; return(BeginInvoke <DeleteProjectRequest>(request, marshaller, unmarshaller, callback, state)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteProject operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteProject operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/iot1click-projects-2018-05-14/DeleteProject">REST API Reference for DeleteProject Operation</seealso> public virtual Task <DeleteProjectResponse> DeleteProjectAsync(DeleteProjectRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = DeleteProjectRequestMarshaller.Instance; var unmarshaller = DeleteProjectResponseUnmarshaller.Instance; return(InvokeAsync <DeleteProjectRequest, DeleteProjectResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the DeleteProject operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DeleteProject operation on AmazonMobileClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDeleteProject /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mobile-2017-07-01/DeleteProject">REST API Reference for DeleteProject Operation</seealso> public virtual IAsyncResult BeginDeleteProject(DeleteProjectRequest request, AsyncCallback callback, object state) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteProjectRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteProjectResponseUnmarshaller.Instance; return(BeginInvoke(request, options, callback, state)); }
public async Task <IActionResult> DeletePartAsync(DeleteProjectRequest request) { var isDeleted = await _projectService.DeleteProjectAsync(new Project { ProjectId = request.ProjectId }); return(Ok(isDeleted)); }
internal virtual DeleteProjectResponse DeleteProject(DeleteProjectRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteProjectRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteProjectResponseUnmarshaller.Instance; return(Invoke <DeleteProjectResponse>(request, options)); }
/// <summary> /// Delets a project in AWS Mobile Hub. /// </summary> /// <param name="request">Container for the necessary parameters to execute the DeleteProject service method.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the DeleteProject service method, as returned by Mobile.</returns> /// <exception cref="Amazon.Mobile.Model.InternalFailureException"> /// The service has encountered an unexpected error condition which prevents it from /// servicing the request. /// </exception> /// <exception cref="Amazon.Mobile.Model.NotFoundException"> /// No entity can be found with the specified identifier. /// </exception> /// <exception cref="Amazon.Mobile.Model.ServiceUnavailableException"> /// The service is temporarily unavailable. The request should be retried after some /// time delay. /// </exception> /// <exception cref="Amazon.Mobile.Model.TooManyRequestsException"> /// Too many requests have been received for this AWS account in too short a time. The /// request should be retried after some time delay. /// </exception> /// <exception cref="Amazon.Mobile.Model.UnauthorizedException"> /// Credentials of the caller are insufficient to authorize the request. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mobile-2017-07-01/DeleteProject">REST API Reference for DeleteProject Operation</seealso> public virtual Task <DeleteProjectResponse> DeleteProjectAsync(DeleteProjectRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = DeleteProjectRequestMarshaller.Instance; options.ResponseUnmarshaller = DeleteProjectResponseUnmarshaller.Instance; return(InvokeAsync <DeleteProjectResponse>(request, options, cancellationToken)); }
public async Task <int> DeleteProject(DeleteProjectRequest request) { var ids = request.ProjectId.Split(",").Select(c => int.Parse(c)).ToList(); var projects = await _db.Project.Where(c => ids.Contains(c.Id)).ToListAsync(); _db.Project.RemoveRange(projects); return(await _db.SaveChangesAsync()); //return await _db.Database.ExecuteSqlCommandAsync("Delete From Project Where Id in {0}", request.ProjectId); }
public async Task <IActionResult> Delete(long projectId) { var deleteProjectRequest = new DeleteProjectRequest { ProjectId = projectId }; var response = await _projectApplicationService.Handle(deleteProjectRequest); return(RedirectToAction(nameof(Index))); }
public override async Task <DeleteProjectResponse> DeleteProject(DeleteProjectRequest request, ServerCallContext context) { var project = await dbContext.Projects.FindIfNullThrowAsync(request.ProjectId); dbContext.Projects.Remove(project); await dbContext.SaveChangesAsync(); return(new DeleteProjectResponse { }); }
public void DeletarProjetoParametroIncorreto() { #region Parameters string idTarefa = "@#%"; string resultadoEsperado = "BadRequest"; #endregion #region Action DeleteProjectRequest Solicitacao = new DeleteProjectRequest(idTarefa); IRestResponse <dynamic> Resposta = Solicitacao.ExecuteRequest(); #endregion Assert.AreEqual(resultadoEsperado, Resposta.StatusCode.ToString()); }
public void DeletarProjetoInexistente() { #region Parameters string idProjeto = "300"; string respostaEsperada = "Forbidden"; #endregion #region Action DeleteProjectRequest DeletarProjeto = new DeleteProjectRequest(idProjeto); IRestResponse <dynamic> Resposta = DeletarProjeto.ExecuteRequest(); #endregion Assert.AreEqual(respostaEsperada, Resposta.StatusCode.ToString()); }
public DeleteProjectResponse DeleteProject(DeleteProjectRequest project, UnitOfWork context) { var response = new DeleteProjectResponse(); var projectDb = context.Projects.GetItem(project.Id); foreach (var task in projectDb.Tasks) { context.Tasks.RemoveItem(task); } response.Count = context.Projects.RemoveItem(_mapper.Map <Project>(project)); return(response); }
/// <summary> /// 提供删除某个项目的能力 /// </summary> /// <param name="req"><see cref="DeleteProjectRequest"/></param> /// <returns><see cref="DeleteProjectResponse"/></returns> public DeleteProjectResponse DeleteProjectSync(DeleteProjectRequest req) { JsonResponseModel <DeleteProjectResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "DeleteProject"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteProjectResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
public async Task <IActionResult> DeleteProjectAsync(int projectId, [FromBody] DeleteProjectRequest request, [FromServices] IDeleteProjectCommand command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var response = await command.ExecuteAsync(projectId, request); if (!response) { return(NotFound()); } return(Ok()); }
public async Task <ProjectResponse> Handle(DeleteProjectRequest request) { var project = await _projectRepository.ReadById(request.ProjectId); if (project == default) { throw new ArgumentNullException(nameof(project)); } project.Manager.UpdateStatusTo(UserStatus.INACTIVE); await _userRepository.PersistChanges(); _projectRepository.Delete(project); await _projectRepository.PersistChanges(); return(project.Adapt <ProjectResponse>()); }
public IActionResult DeleteProject(string id) { var uc = _projectUseCaseFactory.DeleteProject; var request = new DeleteProjectRequest(HttpContext.Session.GetString("UserId")) { ProjectId = id, }; var presenter = _projectPresenterFactory.Default <DeleteProjectResponse>(HttpContext.Session, TempData, ModelState); if (!uc.Execute(presenter, request)) { return(NotFound()); } return(RedirectToAction(nameof(Index), "Users", new { id = HttpContext.Session.GetString("UserId") })); }
public void DeletarProjetoTokenIncorreto() { #region Parameters string idProjeto = "3"; string respostaEsperada = "Forbidden"; string descricaoErro = "API token not found"; string token = "1234"; #endregion #region Actions DeleteProjectRequest DeletarProjeto = new DeleteProjectRequest(idProjeto); DeletarProjeto.UpdateToken(token); IRestResponse <dynamic> Resposta = DeletarProjeto.ExecuteRequest(); #endregion Assert.AreEqual(Resposta.StatusCode.ToString(), respostaEsperada); Assert.AreEqual(Resposta.StatusDescription, descricaoErro); }
public void DeletaProjetoIdInexistente() { #region Parameters int projectId = 0; //Resultado Esperado string statusCodeExpected = "BadRequest"; string statusDescriptionExpected = "Invalid project id."; #endregion DeleteProjectRequest deleteProjectRequest = new DeleteProjectRequest(projectId); IRestResponse <dynamic> response = deleteProjectRequest.ExecuteRequest(); Assert.Multiple(() => { Assert.AreEqual(statusCodeExpected, response.StatusCode.ToString(), "O StatusCode não é o esperado."); Assert.AreEqual(statusDescriptionExpected, response.StatusDescription, "O StatusDescription não é o esperado."); }); }
public async Task <bool> ExecuteAsync(int projectId, DeleteProjectRequest request) { var project = await Context.Projects.FindAsync(projectId); if (project == null) { return(false); } //TODO: check project task status // TODO: Use Automapper here. for (int i = 0; i < request.RowVersion.Length; i++) { project.RowVersion[i] = request.RowVersion[i]; } Context.Projects.Remove(project); await Context.SaveChangesAsync(); return(true); }
public override Task <DeleteProjectResponse> DeleteProject(DeleteProjectRequest request, ServerCallContext context) { return(Task.FromResult(_projectManager.DeleteProject(request.Id))); }
public DeleteProjectResponse DeleteProject(DeleteProjectRequest request) { DeleteProjectResponse response = new DeleteProjectResponse(); response.ExceptionState = false; // TODO : Prevent Deletion on operation center _projectRepository.Remove(request.Id); _unitOfWork.Commit(); response.Projects = _projectRepository.FindAll().ConvertToProjectSummaryView(); return response; }
public static void Validate(this DeleteProjectRequest request) { Validators.ValidateId(request.Id, request.Context); Validators.MakeGoodOrBad(request.Context); }