public virtual ApiSpaceSpaceFeatureServerRequestModel MapServerResponseToRequest(
            ApiSpaceSpaceFeatureServerResponseModel response)
        {
            var request = new ApiSpaceSpaceFeatureServerRequestModel();

            request.SetProperties(
                response.SpaceFeatureId,
                response.SpaceId);
            return(request);
        }
Esempio n. 2
0
        public void MapModelToEntity()
        {
            var mapper = new DALSpaceSpaceFeatureMapper();
            ApiSpaceSpaceFeatureServerRequestModel model = new ApiSpaceSpaceFeatureServerRequestModel();

            model.SetProperties(1, 1);
            SpaceSpaceFeature response = mapper.MapModelToEntity(1, model);

            response.SpaceFeatureId.Should().Be(1);
            response.SpaceId.Should().Be(1);
        }
Esempio n. 3
0
        public virtual SpaceSpaceFeature MapModelToEntity(
            int id,
            ApiSpaceSpaceFeatureServerRequestModel model
            )
        {
            SpaceSpaceFeature item = new SpaceSpaceFeature();

            item.SetProperties(
                id,
                model.SpaceFeatureId,
                model.SpaceId);
            return(item);
        }
Esempio n. 4
0
        public virtual async Task <CreateResponse <ApiSpaceSpaceFeatureServerResponseModel> > Create(
            ApiSpaceSpaceFeatureServerRequestModel model)
        {
            CreateResponse <ApiSpaceSpaceFeatureServerResponseModel> response = ValidationResponseFactory <ApiSpaceSpaceFeatureServerResponseModel> .CreateResponse(await this.SpaceSpaceFeatureModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                SpaceSpaceFeature record = this.DalSpaceSpaceFeatureMapper.MapModelToEntity(default(int), model);
                record = await this.SpaceSpaceFeatureRepository.Create(record);

                response.SetRecord(this.DalSpaceSpaceFeatureMapper.MapEntityToModel(record));
                await this.mediator.Publish(new SpaceSpaceFeatureCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 5
0
        public virtual async Task <UpdateResponse <ApiSpaceSpaceFeatureServerResponseModel> > Update(
            int id,
            ApiSpaceSpaceFeatureServerRequestModel model)
        {
            var validationResult = await this.SpaceSpaceFeatureModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                SpaceSpaceFeature record = this.DalSpaceSpaceFeatureMapper.MapModelToEntity(id, model);
                await this.SpaceSpaceFeatureRepository.Update(record);

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

                ApiSpaceSpaceFeatureServerResponseModel apiModel = this.DalSpaceSpaceFeatureMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SpaceSpaceFeatureUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiSpaceSpaceFeatureServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiSpaceSpaceFeatureServerResponseModel> .UpdateResponse(validationResult));
            }
        }
        public JsonPatchDocument <ApiSpaceSpaceFeatureServerRequestModel> CreatePatch(ApiSpaceSpaceFeatureServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiSpaceSpaceFeatureServerRequestModel>();

            patch.Replace(x => x.SpaceFeatureId, model.SpaceFeatureId);
            patch.Replace(x => x.SpaceId, model.SpaceId);
            return(patch);
        }