public JsonPatchDocument <ApiPipelineStatusServerRequestModel> CreatePatch(ApiPipelineStatusServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiPipelineStatusServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
        public virtual ApiPipelineStatusServerRequestModel MapServerResponseToRequest(
            ApiPipelineStatusServerResponseModel response)
        {
            var request = new ApiPipelineStatusServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
        public virtual ApiPipelineStatusServerResponseModel MapServerRequestToResponse(
            int id,
            ApiPipelineStatusServerRequestModel request)
        {
            var response = new ApiPipelineStatusServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Exemple #4
0
        public void MapModelToEntity()
        {
            var mapper = new DALPipelineStatusMapper();
            ApiPipelineStatusServerRequestModel model = new ApiPipelineStatusServerRequestModel();

            model.SetProperties("A");
            PipelineStatus response = mapper.MapModelToEntity(1, model);

            response.Name.Should().Be("A");
        }
        public virtual PipelineStatus MapModelToEntity(
            int id,
            ApiPipelineStatusServerRequestModel model
            )
        {
            PipelineStatus item = new PipelineStatus();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
Exemple #6
0
        public virtual async Task <CreateResponse <ApiPipelineStatusServerResponseModel> > Create(
            ApiPipelineStatusServerRequestModel model)
        {
            CreateResponse <ApiPipelineStatusServerResponseModel> response = ValidationResponseFactory <ApiPipelineStatusServerResponseModel> .CreateResponse(await this.PipelineStatusModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                PipelineStatus record = this.DalPipelineStatusMapper.MapModelToEntity(default(int), model);
                record = await this.PipelineStatusRepository.Create(record);

                response.SetRecord(this.DalPipelineStatusMapper.MapEntityToModel(record));
                await this.mediator.Publish(new PipelineStatusCreatedNotification(response.Record));
            }

            return(response);
        }
Exemple #7
0
        public virtual async Task <UpdateResponse <ApiPipelineStatusServerResponseModel> > Update(
            int id,
            ApiPipelineStatusServerRequestModel model)
        {
            var validationResult = await this.PipelineStatusModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PipelineStatus record = this.DalPipelineStatusMapper.MapModelToEntity(id, model);
                await this.PipelineStatusRepository.Update(record);

                record = await this.PipelineStatusRepository.Get(id);

                ApiPipelineStatusServerResponseModel apiModel = this.DalPipelineStatusMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PipelineStatusUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiPipelineStatusServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiPipelineStatusServerResponseModel> .UpdateResponse(validationResult));
            }
        }