public virtual ApiIncludedColumnTestServerRequestModel MapServerResponseToRequest(
            ApiIncludedColumnTestServerResponseModel response)
        {
            var request = new ApiIncludedColumnTestServerRequestModel();

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

            response.SetProperties(id,
                                   request.Name,
                                   request.Name2);
            return(response);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALIncludedColumnTestMapper();
            ApiIncludedColumnTestServerRequestModel model = new ApiIncludedColumnTestServerRequestModel();

            model.SetProperties("A", "A");
            IncludedColumnTest response = mapper.MapModelToEntity(1, model);

            response.Name.Should().Be("A");
            response.Name2.Should().Be("A");
        }
Exemplo n.º 4
0
        public virtual IncludedColumnTest MapModelToEntity(
            int id,
            ApiIncludedColumnTestServerRequestModel model
            )
        {
            IncludedColumnTest item = new IncludedColumnTest();

            item.SetProperties(
                id,
                model.Name,
                model.Name2);
            return(item);
        }
        public virtual async Task <CreateResponse <ApiIncludedColumnTestServerResponseModel> > Create(
            ApiIncludedColumnTestServerRequestModel model)
        {
            CreateResponse <ApiIncludedColumnTestServerResponseModel> response = ValidationResponseFactory <ApiIncludedColumnTestServerResponseModel> .CreateResponse(await this.IncludedColumnTestModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                IncludedColumnTest record = this.DalIncludedColumnTestMapper.MapModelToEntity(default(int), model);
                record = await this.IncludedColumnTestRepository.Create(record);

                response.SetRecord(this.DalIncludedColumnTestMapper.MapEntityToModel(record));
                await this.mediator.Publish(new IncludedColumnTestCreatedNotification(response.Record));
            }

            return(response);
        }
        public virtual async Task <UpdateResponse <ApiIncludedColumnTestServerResponseModel> > Update(
            int id,
            ApiIncludedColumnTestServerRequestModel model)
        {
            var validationResult = await this.IncludedColumnTestModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                IncludedColumnTest record = this.DalIncludedColumnTestMapper.MapModelToEntity(id, model);
                await this.IncludedColumnTestRepository.Update(record);

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

                ApiIncludedColumnTestServerResponseModel apiModel = this.DalIncludedColumnTestMapper.MapEntityToModel(record);
                await this.mediator.Publish(new IncludedColumnTestUpdatedNotification(apiModel));

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

            patch.Replace(x => x.Name, model.Name);
            patch.Replace(x => x.Name2, model.Name2);
            return(patch);
        }