/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateProjectResponse response = new UpdateProjectResponse(); return(response); }
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 UpdateProjectResponse UpdateProject(string projectId, ProjectDTO projectDTO) { UpdateProjectResponse projectResponse = new UpdateProjectResponse(false, projectId); XDocument xDoc = new XDocument(); try { // get XML based on ProjectDTO object using (var writer = xDoc.CreateWriter()) { var serializer = new DataContractSerializer(projectDTO.GetType()); serializer.WriteObject(writer, projectDTO); } // send the project to DB new ProjectDB(Utility.ConfigurationHelper.GPD_Connection).UpdateProject(projectId, xDoc); // project updated successful projectResponse.Status = true; } catch (Exception ex) { log.Error("Unable to update the project", ex); projectResponse.Message = "Unable to update the project"; } return(projectResponse); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateProjectResponse response = new UpdateProjectResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("LastModifiedDate", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.LastModifiedDate = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } } return(response); }
public static UpdateProjectResponse Unmarshall(UnmarshallerContext _ctx) { UpdateProjectResponse updateProjectResponse = new UpdateProjectResponse(); updateProjectResponse.HttpResponse = _ctx.HttpResponse; updateProjectResponse.Data = _ctx.StringValue("UpdateProject.Data"); updateProjectResponse.RequestId = _ctx.StringValue("UpdateProject.RequestId"); return(updateProjectResponse); }
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 static UpdateProjectResponse Unmarshall(UnmarshallerContext context) { UpdateProjectResponse updateProjectResponse = new UpdateProjectResponse(); updateProjectResponse.HttpResponse = context.HttpResponse; updateProjectResponse.Code = context.IntegerValue("UpdateProject.Code"); updateProjectResponse.Message = context.StringValue("UpdateProject.Message"); updateProjectResponse.RequestId = context.StringValue("UpdateProject.RequestId"); return(updateProjectResponse); }
public static UpdateProjectResponse Unmarshall(UnmarshallerContext context) { UpdateProjectResponse updateProjectResponse = new UpdateProjectResponse(); updateProjectResponse.HttpResponse = context.HttpResponse; updateProjectResponse.RequestId = context.StringValue("UpdateProject.RequestId"); updateProjectResponse.ErrorCode = context.StringValue("UpdateProject.ErrorCode"); updateProjectResponse.ErrorMessage = context.StringValue("UpdateProject.ErrorMessage"); updateProjectResponse.Success = context.BooleanValue("UpdateProject.Success"); updateProjectResponse._Object = context.StringValue("UpdateProject.Object"); return(updateProjectResponse); }
public static UpdateProjectResponse Unmarshall(UnmarshallerContext context) { UpdateProjectResponse updateProjectResponse = new UpdateProjectResponse(); updateProjectResponse.HttpResponse = context.HttpResponse; updateProjectResponse.RequestId = context.StringValue("UpdateProject.RequestId"); updateProjectResponse.Project = context.StringValue("UpdateProject.Project"); updateProjectResponse.CreateTime = context.StringValue("UpdateProject.CreateTime"); updateProjectResponse.ModifyTime = context.StringValue("UpdateProject.ModifyTime"); updateProjectResponse.ServiceRole = context.StringValue("UpdateProject.ServiceRole"); updateProjectResponse.CU = context.IntegerValue("UpdateProject.CU"); updateProjectResponse.Type = context.StringValue("UpdateProject.Type"); return(updateProjectResponse); }
public async Task UpdateProjectAsync_ValidRequest_ShouldReturnUpdatedProject() { // Arrange var existingProject = new GetProjectPayload { Id = Guid.NewGuid().ToString(), Description = "TestDescription", }; var updateProjectRequest = new UpdateProjectRequest { Description = "NewDescription", }; var expectedUpdatedProject = new UpdateProjectResponse { Id = existingProject.Id, Description = updateProjectRequest.Description, }; var expectedResponseContent = new StringContent(JsonConvert.SerializeObject(expectedUpdatedProject, this.fixture.JsonSerializerSettings)); var expectedResponse = new HttpResponseMessage { Content = expectedResponseContent, }; var projectApi = this.fixture.GetProjectApi(expectedResponse); var updateProjectResponse = new UpdateProjectResponse(); // Act Func <Task> act = async() => updateProjectResponse = await projectApi.UpdateProjectAsync(existingProject.Id, updateProjectRequest); // Assert await act.Should().NotThrowAsync(); using (new AssertionScope()) { updateProjectResponse.Id.Should().Be(existingProject.Id); updateProjectResponse.Description.Should().Be(expectedUpdatedProject.Description); } }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateProjectResponse response = new UpdateProjectResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("project", targetDepth)) { var unmarshaller = ProjectUnmarshaller.Instance; response.Project = unmarshaller.Unmarshall(context); continue; } } return response; }
public override async Task <ActionResult <UpdateProjectResponse> > HandleAsync(UpdateProjectRequest request, CancellationToken cancellationToken) { if (request.Name == null) { return(BadRequest()); } var existingProject = await _repository.GetByIdAsync(request.Id); // TODO: pass cancellation token if (existingProject == null) { return(NotFound()); } existingProject.UpdateName(request.Name); await _repository.UpdateAsync(existingProject); // TODO: pass cancellation token var response = new UpdateProjectResponse( project: new ProjectRecord(existingProject.Id, existingProject.Name) ); return(Ok(response)); }