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

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

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

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

            return(model);
        }
Ejemplo n.º 5
0
        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");
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 7
0
 public SpaceUpdatedNotification(ApiSpaceServerResponseModel record)
 {
     this.Record = record;
 }
Ejemplo n.º 8
0
 public void SetSpaceIdNavigation(ApiSpaceServerResponseModel value)
 {
     this.SpaceIdNavigation = value;
 }