Пример #1
0
        public virtual ApiSpaceSpaceFeatureServerResponseModel MapEntityToModel(
            SpaceSpaceFeature item)
        {
            var model = new ApiSpaceSpaceFeatureServerResponseModel();

            model.SetProperties(item.Id,
                                item.SpaceFeatureId,
                                item.SpaceId);
            if (item.SpaceFeatureIdNavigation != null)
            {
                var spaceFeatureIdModel = new ApiSpaceFeatureServerResponseModel();
                spaceFeatureIdModel.SetProperties(
                    item.SpaceFeatureIdNavigation.Id,
                    item.SpaceFeatureIdNavigation.Name);

                model.SetSpaceFeatureIdNavigation(spaceFeatureIdModel);
            }

            if (item.SpaceIdNavigation != null)
            {
                var spaceIdModel = new ApiSpaceServerResponseModel();
                spaceIdModel.SetProperties(
                    item.SpaceIdNavigation.Id,
                    item.SpaceIdNavigation.Description,
                    item.SpaceIdNavigation.Name);

                model.SetSpaceIdNavigation(spaceIdModel);
            }

            return(model);
        }
        public virtual ApiSpaceSpaceFeatureClientRequestModel MapServerResponseToClientRequest(
            ApiSpaceSpaceFeatureServerResponseModel response)
        {
            var request = new ApiSpaceSpaceFeatureClientRequestModel();

            request.SetProperties(
                response.SpaceFeatureId,
                response.SpaceId);
            return(request);
        }
        public virtual ApiSpaceSpaceFeatureServerResponseModel MapServerRequestToResponse(
            int id,
            ApiSpaceSpaceFeatureServerRequestModel request)
        {
            var response = new ApiSpaceSpaceFeatureServerResponseModel();

            response.SetProperties(id,
                                   request.SpaceFeatureId,
                                   request.SpaceId);
            return(response);
        }
Пример #4
0
        public void MapEntityToModel()
        {
            var mapper             = new DALSpaceSpaceFeatureMapper();
            SpaceSpaceFeature item = new SpaceSpaceFeature();

            item.SetProperties(1, 1, 1);
            ApiSpaceSpaceFeatureServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.SpaceFeatureId.Should().Be(1);
            response.SpaceId.Should().Be(1);
        }
Пример #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 SpaceSpaceFeatureUpdatedNotification(ApiSpaceSpaceFeatureServerResponseModel record)
 {
     this.Record = record;
 }