private async static Task UpdateProject(ProjectServiceDefinition.ProjectServiceDefinitionClient projectClient) { var input = new UpdateProjectRequest { Id = 1, Name = "UPDATED - CIB Fejlesztés sok pénzért", CustomerId = 2 }; var reply = await projectClient.UpdateProjectAsync(input); }
protected override void ProcessRecord() { base.ProcessRecord(); UpdateProjectRequest request; try { request = new UpdateProjectRequest { WorkspaceId = WorkspaceId, ProjectKey = ProjectKey, UpdateProjectDetails = UpdateProjectDetails, OpcRequestId = OpcRequestId, IfMatch = IfMatch }; response = client.UpdateProject(request).GetAwaiter().GetResult(); WriteOutput(response, response.Project); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Update an existing project. /// </summary> /// <param name="request">Container for the necessary parameters to execute the UpdateProject service method.</param> /// /// <returns>The response from the UpdateProject service method, as returned by Mobile.</returns> /// <exception cref="Amazon.Mobile.Model.AccountActionRequiredException"> /// Account Action is required in order to continue the request. /// </exception> /// <exception cref="Amazon.Mobile.Model.BadRequestException"> /// The request cannot be processed because some parameter is not valid or the project /// state prevents the operation from being performed. /// </exception> /// <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.LimitExceededException"> /// There are too many AWS Mobile Hub projects in the account or the account has exceeded /// the maximum number of resources in some AWS service. You should create another sub-account /// using AWS Organizations or remove some resources and retry your 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/UpdateProject">REST API Reference for UpdateProject Operation</seealso> public UpdateProjectResponse UpdateProject(UpdateProjectRequest request) { var marshaller = new UpdateProjectRequestMarshaller(); var unmarshaller = UpdateProjectResponseUnmarshaller.Instance; return(Invoke <UpdateProjectRequest, UpdateProjectResponse>(request, marshaller, unmarshaller)); }
public async Task UpdateProjectAsync_NotExistingProject_Should() { // Arrange await this.fixture.ClearFactroInstanceAsync(); var projectApi = this.fixture.GetService <IProjectApi>(); var notExistingProjectId = Guid.NewGuid().ToString(); var updatedTitle = $"{BaseTestFixture.TestPrefix}{Guid.NewGuid().ToString()}"; var updateProjectRequest = new UpdateProjectRequest { Title = updatedTitle, }; // Act Func <Task> act = async() => await projectApi.UpdateProjectAsync(notExistingProjectId, updateProjectRequest); // Assert await act.Should().ThrowAsync <FactroApiException>(); using (new AssertionScope()) { var projects = (await this.fixture.GetProjectsAsync(projectApi)).ToList(); projects.Should().NotContain(project => project.Id == notExistingProjectId); } await this.fixture.ClearFactroInstanceAsync(); }
public IActionResult Put([FromBody] UpdateProjectRequest updateProjectRequest) { var project = new Project { Id = updateProjectRequest.Id, Name = updateProjectRequest.Name, Description = updateProjectRequest.Description, IsDone = updateProjectRequest.IsDone }; var updated = _projectService.UpdateProject(project); if (updated) { var getProjectResponse = new GetProjectResponse { Id = project.Id, Name = project.Name, Description = project.Description, IsDone = project.IsDone }; return(Ok(getProjectResponse)); } return(NotFound()); }
public async Task UpdateProjectAsync_ValidUpdate_ShouldUpdateProject() { // Arrange await this.fixture.ClearFactroInstanceAsync(); var projectApi = this.fixture.GetService <IProjectApi>(); var existingProject = await this.fixture.CreateTestProjectAsync(projectApi); var updatedTitle = $"{BaseTestFixture.TestPrefix}{Guid.NewGuid().ToString()}"; var updateProjectRequest = new UpdateProjectRequest { Title = updatedTitle, }; var updateProjectResponse = new UpdateProjectResponse(); // Act Func <Task> act = async() => updateProjectResponse = await projectApi.UpdateProjectAsync(existingProject.Id, updateProjectRequest); // Assert await act.Should().NotThrowAsync(); using (new AssertionScope()) { var projects = (await this.fixture.GetProjectsAsync(projectApi)).ToList(); projects.Should().ContainEquivalentOf(updateProjectResponse); projects.Single(x => x.Id == existingProject.Id).Title.Should().Be(updatedTitle); } await this.fixture.ClearFactroInstanceAsync(); }
public async Task UpdateProjectAsync_InvalidUpdate_ShouldNotUpdateeProject() { // Arrange await this.fixture.ClearFactroInstanceAsync(); var projectApi = this.fixture.GetService <IProjectApi>(); var existingProject = await this.fixture.CreateTestProjectAsync(projectApi); var notExistingOfficerId = Guid.NewGuid().ToString(); var updateProjectRequest = new UpdateProjectRequest { OfficerId = notExistingOfficerId, }; // Act Func <Task> act = async() => await projectApi.UpdateProjectAsync(existingProject.Id, updateProjectRequest); // Assert await act.Should().ThrowAsync <FactroApiException>(); using (new AssertionScope()) { var projects = (await this.fixture.GetProjectsAsync(projectApi)).ToList(); projects.Should().ContainEquivalentOf(existingProject); } await this.fixture.ClearFactroInstanceAsync(); }
public async Task <ProjectResponse> ExecuteAsync(int projectId, UpdateProjectRequest request) { var project = await Context.Projects.FindAsync(projectId); if (project == null) { return(null); } // TODO: Use Automapper here. project.Name = request.Name; project.Description = request.Description; for (int i = 0; i < request.RowVersion.Length; i++) { project.RowVersion[i] = request.RowVersion[i]; } await Context.SaveChangesAsync(); return(new ProjectResponse { Id = project.Id, Name = project.Name, Description = project.Description, RowVersion = project.RowVersion, OpenTasksCount = Context.Tasks.Count(t => t.ProjectId == projectId && t.Status != TaskStatus.Completed) }); }
public async Task <IActionResult> UpdateProjectAsync(int projectId, [FromBody] UpdateProjectRequest request, [FromServices] IUpdateProjectCommand command, [FromServices] IGetProjectQuery query) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string user = User.Identity.Name; var project = await query.RunAsync(projectId); try { var authorizationResult = await _authorizationService.AuthorizeAsync(User, project, Operations.Update); if (authorizationResult.Succeeded) { ProjectResponse response = await command.ExecuteAsync(projectId, request, user); return(response == null ? (IActionResult)NotFound("Project Not Found") : Ok(response)); } return(StatusCode(403, "Вы не можете изменить этот проект!")); } catch (ProjectLockedException) { return(BadRequest("В данный момент изменение проекта невозможно!")); } catch (DbUpdateConcurrencyException) { return(BadRequest("Ошибка параллелизма!")); } }
internal virtual UpdateProjectResponse UpdateProject(UpdateProjectRequest request) { var marshaller = UpdateProjectRequestMarshaller.Instance; var unmarshaller = UpdateProjectResponseUnmarshaller.Instance; return(Invoke <UpdateProjectRequest, UpdateProjectResponse>(request, marshaller, unmarshaller)); }
public async Task <IActionResult> UpdateProjectAsync(UpdateProjectRequest request) { var mappedProject = Mapper.Map <UpdateProjectRequest, Project>(request); var project = await _projectService.UpdateProjectAsync(mappedProject); return(Ok(project)); }
public async Task <Project> UpdateAsync(long projectId, UpdateProjectRequest request) { var project = await _projectRepository.GetByIdAsync(projectId); var country = await GetCountryAsync(request.CountryCode); project.Name = request.Name; project.CountryId = country.Id; project.Category = (Category)request.Category; project.Description = request.Description; project.ContactEmail = request.ContactEmail; project.IcoDate = request.IcoDate; project.Website = request.Website; project.WhitePaperLink = request.WhitePaperLink; project.Stage = (Stage)request.Stage; project.Facebook = request.Facebook; project.Reddit = request.Reddit; project.BitcoinTalk = request.BitcoinTalk; project.Telegram = request.Telegram; project.Github = request.Github; project.Medium = request.Medium; project.Twitter = request.Twitter; project.Linkedin = request.Linkedin; UpdateTeamMembers(request.TeamMembers, project); await _projectRepository.SaveChangesAsync(); return(project); }
/// <summary> /// Initiates the asynchronous execution of the UpdateProject operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UpdateProject 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/UpdateProject">REST API Reference for UpdateProject Operation</seealso> public virtual Task <UpdateProjectResponse> UpdateProjectAsync(UpdateProjectRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = UpdateProjectRequestMarshaller.Instance; var unmarshaller = UpdateProjectResponseUnmarshaller.Instance; return(InvokeAsync <UpdateProjectRequest, UpdateProjectResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// Initiates the asynchronous execution of the UpdateProject operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UpdateProject 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 EndUpdateProject /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mobile-2017-07-01/UpdateProject">REST API Reference for UpdateProject Operation</seealso> public virtual IAsyncResult BeginUpdateProject(UpdateProjectRequest request, AsyncCallback callback, object state) { var marshaller = UpdateProjectRequestMarshaller.Instance; var unmarshaller = UpdateProjectResponseUnmarshaller.Instance; return(BeginInvoke <UpdateProjectRequest>(request, marshaller, unmarshaller, callback, state)); }
/// <summary> /// Update an existing project. /// </summary> /// <param name="request">Container for the necessary parameters to execute the UpdateProject 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 UpdateProject service method, as returned by Mobile.</returns> /// <exception cref="Amazon.Mobile.Model.AccountActionRequiredException"> /// Account Action is required in order to continue the request. /// </exception> /// <exception cref="Amazon.Mobile.Model.BadRequestException"> /// The request cannot be processed because some parameter is not valid or the project /// state prevents the operation from being performed. /// </exception> /// <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.LimitExceededException"> /// There are too many AWS Mobile Hub projects in the account or the account has exceeded /// the maximum number of resources in some AWS service. You should create another sub-account /// using AWS Organizations or remove some resources and retry your 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/UpdateProject">REST API Reference for UpdateProject Operation</seealso> public virtual Task <UpdateProjectResponse> UpdateProjectAsync(UpdateProjectRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = UpdateProjectRequestMarshaller.Instance; options.ResponseUnmarshaller = UpdateProjectResponseUnmarshaller.Instance; return(InvokeAsync <UpdateProjectResponse>(request, options, cancellationToken)); }
internal virtual UpdateProjectResponse UpdateProject(UpdateProjectRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = UpdateProjectRequestMarshaller.Instance; options.ResponseUnmarshaller = UpdateProjectResponseUnmarshaller.Instance; return(Invoke <UpdateProjectResponse>(request, options)); }
public async Task <IActionResult> Update([FromBody] UpdateProjectRequest request) { using var session = _documentStore.OpenAsyncSession(); var user = await _platformAdminUserManager.GetByUniqueIdentifierAsync(User.Identity.Name, session); var project = await _projectUpdateManager.Update(request, session, user.Id); return(Ok(project)); }
/// <summary> /// Initiates the asynchronous execution of the UpdateProject operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the UpdateProject 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 EndUpdateProject /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/mobile-2017-07-01/UpdateProject">REST API Reference for UpdateProject Operation</seealso> public virtual IAsyncResult BeginUpdateProject(UpdateProjectRequest request, AsyncCallback callback, object state) { var options = new InvokeOptions(); options.RequestMarshaller = UpdateProjectRequestMarshaller.Instance; options.ResponseUnmarshaller = UpdateProjectResponseUnmarshaller.Instance; return(BeginInvoke(request, options, callback, state)); }
public async Task <IActionResult> UpdateExistingProject([FromBody] UpdateProjectRequest request) { var updateProjectResponse = new UpdateProjectResponse(); Logger.Info($"Update existing project request is received. Time in UTC: {DateTime.UtcNow}, request: {request.ToJson()}"); var commandHandlerResponse = await _projectMediator.Send(request); updateProjectResponse.HandleSuccess(commandHandlerResponse); return(Ok(updateProjectResponse)); }
public async Task <IActionResult> UpdateProjectAsync([FromBody] UpdateProjectRequest request, [FromServices] IUpdateProjectCommand command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ProjectResponse response = await command.ExecuteAsync(request); return(response == null ? (IActionResult)NotFound() : Ok(response)); }
public async Task UpdateProject([FromRoute] Guid id, [FromBody] UpdateProjectRequest request) => await _mediator.Send(new UpdateProjectCommand( id, request.Name, request.Description, request.RecruitingStatus, request.Type, request.Category ) );
public async Task <ProjectAboutResponse> PutAsync(long id, [FromBody] UpdateProjectRequest request) { if (!await _projectService.IsAuthorizedToEditProjectAsync(id, User.GetUserId())) { throw new AppErrorException(ErrorCode.UserNotAuthor); } var project = await _projectService.UpdateAsync(id, request); return(ProjectAboutResponse.Create(project)); }
public IActionResult UpdateProject(Guid id, [FromBody] UpdateProjectRequest req) { var userId = HttpContext.User.Claims.Single(x => x.Type == "Id").Value; var res = _projectService.Update(userId, id, req); if (!res.Success) { return(BadRequest(res)); } return(Ok(res)); }
public void UpdateProject(UpdateProjectRequest request) { var project = new Project { ProjectId = request.ProjectId, ProjectCollectionId = request.ProjectCollectionId, ParentProjectId = request.ParentProjectId, Name = request.Name }; component.UpdateProject(project); }
public async Task <OperationDto> UpdateProject(ProjectDto project, string organization = default, CancellationToken cancellationToken = default) { var request = new UpdateProjectRequest(organization ?? _options.Value.DefaultOrganization, project); request.Headers.Authorization = GetAuthZHeader(); var response = await SendAsync(request, cancellationToken); var operationReferenceDto = await response.Content.ReadFromJsonAsync <OperationDto>(null, cancellationToken); return(operationReferenceDto); }
public Result <UpdateProjectResponse> UpdateProject(Guid reference, UpdateProjectRequest request) { using var session = _apiDatabase.SessionFactory().OpenSession(); using var transaction = session.BeginTransaction(IsolationLevel.ReadCommitted); var project = session .Query <ProjectRecord>() .SingleOrDefault(x => x.Reference == reference); if (project == null) { return(Result <UpdateProjectResponse> .Failure($"Unable to find project with reference: {reference}.")); } var urlSlugResult = SlugService.FromText(request.Title, request.UrlSlug); if (urlSlugResult.IsFailure) { return(Result <UpdateProjectResponse> .From(urlSlugResult)); } project.Title = request.Title; project.UrlSlug = urlSlugResult.Value; project.StartedAt = request.StartedAt; project.Summary = request.Summary; project.Description = request.Description; project.SourceCodeUrl = request.SourceCodeUrl; project.PreviewImageUrl = request.PreviewImageUrl; project.DisplayOrder = request.DisplayOrder; project.ViewUrl = request.ViewUrl; project.Tags = request.Tags; session.Update(project); transaction.Commit(); return(Result <UpdateProjectResponse> .Of(new UpdateProjectResponse { Reference = project.Reference, Title = project.Title, UrlSlug = project.UrlSlug, StartedAt = project.StartedAt, Summary = project.Summary, Description = project.Description, SourceCodeUrl = project.SourceCodeUrl, PreviewImageUrl = project.PreviewImageUrl, DisplayOrder = project.DisplayOrder, CreatedAt = project.CreatedAt, ViewUrl = project.ViewUrl, Tags = project.Tags })); }
public async Task UpdateProjectAsync_InvalidProjectId_ShouldThrowArgumentNullException(string projectId) { // Arrange var projectApi = this.fixture.GetProjectApi(); var updateProjectRequest = new UpdateProjectRequest(); // Act Func <Task> act = async() => await projectApi.UpdateProjectAsync(projectId, updateProjectRequest); // Assert await act.Should().ThrowAsync <ArgumentNullException>(); }
public async Task <Project> UpdateProjectAsync(string id, string newName, bool?access, bool?notifications, string newOwnerEmail) { var req = new UpdateProjectRequest { Name = newName, Restricted = access, Notification = notifications, OwnerEmailOrId = newOwnerEmail }; var response = await Put <UpdateProjectRequest, Project>($"projects/{id}", req); return(response); }
public ProjectResponse UpdateProjet(UpdateProjectRequest request) { var projectToUpdate = _unitOfWork.ProjectRepository.GetByID(request.Id); projectToUpdate.Name = request.Name; projectToUpdate.CustomerId = request.CustomerId; projectToUpdate.ModifiedAt = DateTime.Now; projectToUpdate.ModifiedBy = 1; _unitOfWork.ProjectRepository.Save(); return(new ProjectResponse { Id = projectToUpdate.Id, Name = projectToUpdate.Name, CustomerId = projectToUpdate.CustomerId }); }
public async Task <ProjectResponse> ExecuteAsync(int projectId, UpdateProjectRequest request) { Project project = await _context.Projects.FindAsync(projectId); if (project == null) { return(null); } project = Mapper.Map <Project>(request); await _context.SaveChangesAsync(); return(Mapper.Map <ProjectResponse>(project)); }