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

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

            request.SetProperties(
                response.Name);
            return(request);
        }
        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");
        }
        public virtual ApiSpaceFeatureServerResponseModel MapServerRequestToResponse(
            int id,
            ApiSpaceFeatureServerRequestModel request)
        {
            var response = new ApiSpaceFeatureServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
        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));
            }
        }