public virtual ApiTableClientRequestModel MapServerResponseToClientRequest(
            ApiTableServerResponseModel response)
        {
            var request = new ApiTableClientRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
        public virtual ApiTableServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTableServerRequestModel request)
        {
            var response = new ApiTableServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Exemple #3
0
        public virtual ApiTableServerResponseModel MapEntityToModel(
            Table item)
        {
            var model = new ApiTableServerResponseModel();

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

            return(model);
        }
        public void MapEntityToModel()
        {
            var   mapper = new DALTableMapper();
            Table item   = new Table();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemple #5
0
        public virtual async Task <UpdateResponse <ApiTableServerResponseModel> > Update(
            int id,
            ApiTableServerRequestModel model)
        {
            var validationResult = await this.TableModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Table record = this.DalTableMapper.MapModelToEntity(id, model);
                await this.TableRepository.Update(record);

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

                ApiTableServerResponseModel apiModel = this.DalTableMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TableUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiTableServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiTableServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemple #6
0
 public TableUpdatedNotification(ApiTableServerResponseModel record)
 {
     this.Record = record;
 }