public async Task <ValidationResult> ValidateUpdateAsync(int id, ApiAWBuildVersionRequestModel model) { this.Database_VersionRules(); this.ModifiedDateRules(); this.VersionDateRules(); return(await this.ValidateAsync(model, id)); }
private async Task <ApiAWBuildVersionResponseModel> CreateRecord(ApiClient client) { var model = new ApiAWBuildVersionRequestModel(); model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), DateTime.Parse("1/1/1988 12:00:00 AM")); CreateResponse <ApiAWBuildVersionResponseModel> result = await client.AWBuildVersionCreateAsync(model); result.Success.Should().BeTrue(); return(result.Record); }
public void MapModelToBO() { var mapper = new BOLAWBuildVersionMapper(); ApiAWBuildVersionRequestModel model = new ApiAWBuildVersionRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM")); BOAWBuildVersion response = mapper.MapModelToBO(1, model); response.Database_Version.Should().Be("A"); response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.VersionDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }
public void MapResponseToRequest() { var mapper = new ApiAWBuildVersionModelMapper(); var model = new ApiAWBuildVersionResponseModel(); model.SetProperties(1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM")); ApiAWBuildVersionRequestModel response = mapper.MapResponseToRequest(model); response.Database_Version.Should().Be("A"); response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.VersionDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }
public virtual async Task <IActionResult> Create([FromBody] ApiAWBuildVersionRequestModel model) { CreateResponse <ApiAWBuildVersionResponseModel> result = await this.AWBuildVersionService.Create(model); if (result.Success) { return(this.Created($"{this.Settings.ExternalBaseUrl}/api/AWBuildVersions/{result.Record.SystemInformationID}", result)); } else { return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result)); } }
public virtual BOAWBuildVersion MapModelToBO( int systemInformationID, ApiAWBuildVersionRequestModel model ) { BOAWBuildVersion boAWBuildVersion = new BOAWBuildVersion(); boAWBuildVersion.SetProperties( systemInformationID, model.Database_Version, model.ModifiedDate, model.VersionDate); return(boAWBuildVersion); }
public void CreatePatch() { var mapper = new ApiAWBuildVersionModelMapper(); var model = new ApiAWBuildVersionRequestModel(); model.SetProperties("A", DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM")); JsonPatchDocument <ApiAWBuildVersionRequestModel> patch = mapper.CreatePatch(model); var response = new ApiAWBuildVersionRequestModel(); patch.ApplyTo(response); response.Database_Version.Should().Be("A"); response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.VersionDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }
public virtual async Task <CreateResponse <ApiAWBuildVersionResponseModel> > Create( ApiAWBuildVersionRequestModel model) { CreateResponse <ApiAWBuildVersionResponseModel> response = new CreateResponse <ApiAWBuildVersionResponseModel>(await this.aWBuildVersionModelValidator.ValidateCreateAsync(model)); if (response.Success) { var bo = this.bolAWBuildVersionMapper.MapModelToBO(default(int), model); var record = await this.aWBuildVersionRepository.Create(this.dalAWBuildVersionMapper.MapBOToEF(bo)); response.SetRecord(this.bolAWBuildVersionMapper.MapBOToModel(this.dalAWBuildVersionMapper.MapEFToBO(record))); } return(response); }
private async Task <ApiAWBuildVersionRequestModel> PatchModel(int id, JsonPatchDocument <ApiAWBuildVersionRequestModel> patch) { var record = await this.AWBuildVersionService.Get(id); if (record == null) { return(null); } else { ApiAWBuildVersionRequestModel request = this.AWBuildVersionModelMapper.MapResponseToRequest(record); patch.ApplyTo(request); return(request); } }
public async void Create() { var mock = new ServiceMockFacade <IAWBuildVersionRepository>(); var model = new ApiAWBuildVersionRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <AWBuildVersion>())).Returns(Task.FromResult(new AWBuildVersion())); var service = new AWBuildVersionService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.AWBuildVersionModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLAWBuildVersionMapperMock, mock.DALMapperMockFactory.DALAWBuildVersionMapperMock); CreateResponse <ApiAWBuildVersionResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.AWBuildVersionModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiAWBuildVersionRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <AWBuildVersion>())); }
public async void Delete() { var mock = new ServiceMockFacade <IAWBuildVersionRepository>(); var model = new ApiAWBuildVersionRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new AWBuildVersionService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.AWBuildVersionModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLAWBuildVersionMapperMock, mock.DALMapperMockFactory.DALAWBuildVersionMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.AWBuildVersionModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); }
public virtual async Task <UpdateResponse <ApiAWBuildVersionResponseModel> > Update( int systemInformationID, ApiAWBuildVersionRequestModel model) { var validationResult = await this.aWBuildVersionModelValidator.ValidateUpdateAsync(systemInformationID, model); if (validationResult.IsValid) { var bo = this.bolAWBuildVersionMapper.MapModelToBO(systemInformationID, model); await this.aWBuildVersionRepository.Update(this.dalAWBuildVersionMapper.MapBOToEF(bo)); var record = await this.aWBuildVersionRepository.Get(systemInformationID); return(new UpdateResponse <ApiAWBuildVersionResponseModel>(this.bolAWBuildVersionMapper.MapBOToModel(this.dalAWBuildVersionMapper.MapEFToBO(record)))); } else { return(new UpdateResponse <ApiAWBuildVersionResponseModel>(validationResult)); } }
public virtual async Task <IActionResult> Update(int id, [FromBody] ApiAWBuildVersionRequestModel model) { ApiAWBuildVersionRequestModel request = await this.PatchModel(id, this.AWBuildVersionModelMapper.CreatePatch(model)); if (request == null) { return(this.StatusCode(StatusCodes.Status404NotFound)); } else { UpdateResponse <ApiAWBuildVersionResponseModel> result = await this.AWBuildVersionService.Update(id, request); if (result.Success) { return(this.Ok(result)); } else { return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result)); } } }
public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiAWBuildVersionRequestModel> patch) { ApiAWBuildVersionResponseModel record = await this.AWBuildVersionService.Get(id); if (record == null) { return(this.StatusCode(StatusCodes.Status404NotFound)); } else { ApiAWBuildVersionRequestModel model = await this.PatchModel(id, patch); UpdateResponse <ApiAWBuildVersionResponseModel> result = await this.AWBuildVersionService.Update(id, model); if (result.Success) { return(this.Ok(result)); } else { return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result)); } } }