コード例 #1
0
        public JsonPatchDocument <ApiSpaceFeatureServerRequestModel> CreatePatch(ApiSpaceFeatureServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiSpaceFeatureServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
コード例 #2
0
        public virtual ApiSpaceFeatureServerRequestModel MapServerResponseToRequest(
            ApiSpaceFeatureServerResponseModel response)
        {
            var request = new ApiSpaceFeatureServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
コード例 #3
0
        public void MapModelToEntity()
        {
            var mapper = new DALSpaceFeatureMapper();
            ApiSpaceFeatureServerRequestModel model = new ApiSpaceFeatureServerRequestModel();

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

            response.Name.Should().Be("A");
        }
コード例 #4
0
        public virtual ApiSpaceFeatureServerResponseModel MapServerRequestToResponse(
            int id,
            ApiSpaceFeatureServerRequestModel request)
        {
            var response = new ApiSpaceFeatureServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
コード例 #5
0
        public virtual SpaceFeature MapModelToEntity(
            int id,
            ApiSpaceFeatureServerRequestModel model
            )
        {
            SpaceFeature item = new SpaceFeature();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
コード例 #6
0
        public virtual async Task <CreateResponse <ApiSpaceFeatureServerResponseModel> > Create(
            ApiSpaceFeatureServerRequestModel model)
        {
            CreateResponse <ApiSpaceFeatureServerResponseModel> response = ValidationResponseFactory <ApiSpaceFeatureServerResponseModel> .CreateResponse(await this.SpaceFeatureModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                SpaceFeature record = this.DalSpaceFeatureMapper.MapModelToEntity(default(int), model);
                record = await this.SpaceFeatureRepository.Create(record);

                response.SetRecord(this.DalSpaceFeatureMapper.MapEntityToModel(record));
                await this.mediator.Publish(new SpaceFeatureCreatedNotification(response.Record));
            }

            return(response);
        }
コード例 #7
0
        public virtual async Task <UpdateResponse <ApiSpaceFeatureServerResponseModel> > Update(
            int id,
            ApiSpaceFeatureServerRequestModel model)
        {
            var validationResult = await this.SpaceFeatureModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                SpaceFeature record = this.DalSpaceFeatureMapper.MapModelToEntity(id, model);
                await this.SpaceFeatureRepository.Update(record);

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

                ApiSpaceFeatureServerResponseModel apiModel = this.DalSpaceFeatureMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SpaceFeatureUpdatedNotification(apiModel));

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