Exemple #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);
        }
Exemple #2
0
        public virtual ApiSpaceClientRequestModel MapServerResponseToClientRequest(
            ApiSpaceServerResponseModel response)
        {
            var request = new ApiSpaceClientRequestModel();

            request.SetProperties(
                response.Description,
                response.Name);
            return(request);
        }
Exemple #3
0
        public virtual ApiSpaceServerResponseModel MapServerRequestToResponse(
            int id,
            ApiSpaceServerRequestModel request)
        {
            var response = new ApiSpaceServerResponseModel();

            response.SetProperties(id,
                                   request.Description,
                                   request.Name);
            return(response);
        }
Exemple #4
0
        public virtual ApiSpaceServerResponseModel MapEntityToModel(
            Space item)
        {
            var model = new ApiSpaceServerResponseModel();

            model.SetProperties(item.Id,
                                item.Description,
                                item.Name);

            return(model);
        }
        public void MapEntityToModel()
        {
            var   mapper = new DALSpaceMapper();
            Space item   = new Space();

            item.SetProperties(1, "A", "A");
            ApiSpaceServerResponseModel response = mapper.MapEntityToModel(item);

            response.Description.Should().Be("A");
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemple #6
0
        public virtual async Task <UpdateResponse <ApiSpaceServerResponseModel> > Update(
            int id,
            ApiSpaceServerRequestModel model)
        {
            var validationResult = await this.SpaceModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Space record = this.DalSpaceMapper.MapModelToEntity(id, model);
                await this.SpaceRepository.Update(record);

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

                ApiSpaceServerResponseModel apiModel = this.DalSpaceMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SpaceUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiSpaceServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiSpaceServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemple #7
0
 public SpaceUpdatedNotification(ApiSpaceServerResponseModel record)
 {
     this.Record = record;
 }
Exemple #8
0
 public void SetSpaceIdNavigation(ApiSpaceServerResponseModel value)
 {
     this.SpaceIdNavigation = value;
 }