public JsonPatchDocument <ApiPipelineServerRequestModel> CreatePatch(ApiPipelineServerRequestModel model) { var patch = new JsonPatchDocument <ApiPipelineServerRequestModel>(); patch.Replace(x => x.PipelineStatusId, model.PipelineStatusId); patch.Replace(x => x.SaleId, model.SaleId); return(patch); }
public virtual ApiPipelineServerRequestModel MapServerResponseToRequest( ApiPipelineServerResponseModel response) { var request = new ApiPipelineServerRequestModel(); request.SetProperties( response.PipelineStatusId, response.SaleId); return(request); }
public void MapModelToEntity() { var mapper = new DALPipelineMapper(); ApiPipelineServerRequestModel model = new ApiPipelineServerRequestModel(); model.SetProperties(1, 1); Pipeline response = mapper.MapModelToEntity(1, model); response.PipelineStatusId.Should().Be(1); response.SaleId.Should().Be(1); }
public virtual Pipeline MapModelToEntity( int id, ApiPipelineServerRequestModel model ) { Pipeline item = new Pipeline(); item.SetProperties( id, model.PipelineStatusId, model.SaleId); return(item); }
public virtual async Task <CreateResponse <ApiPipelineServerResponseModel> > Create( ApiPipelineServerRequestModel model) { CreateResponse <ApiPipelineServerResponseModel> response = ValidationResponseFactory <ApiPipelineServerResponseModel> .CreateResponse(await this.PipelineModelValidator.ValidateCreateAsync(model)); if (response.Success) { Pipeline record = this.DalPipelineMapper.MapModelToEntity(default(int), model); record = await this.PipelineRepository.Create(record); response.SetRecord(this.DalPipelineMapper.MapEntityToModel(record)); await this.mediator.Publish(new PipelineCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiPipelineServerResponseModel> > Update( int id, ApiPipelineServerRequestModel model) { var validationResult = await this.PipelineModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Pipeline record = this.DalPipelineMapper.MapModelToEntity(id, model); await this.PipelineRepository.Update(record); record = await this.PipelineRepository.Get(id); ApiPipelineServerResponseModel apiModel = this.DalPipelineMapper.MapEntityToModel(record); await this.mediator.Publish(new PipelineUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiPipelineServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiPipelineServerResponseModel> .UpdateResponse(validationResult)); } }