public JsonPatchDocument <ApiPostTypeServerRequestModel> CreatePatch(ApiPostTypeServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiPostTypeServerRequestModel>();

            patch.Replace(x => x.RwType, model.RwType);
            return(patch);
        }
        public virtual ApiPostTypeServerRequestModel MapServerResponseToRequest(
            ApiPostTypeServerResponseModel response)
        {
            var request = new ApiPostTypeServerRequestModel();

            request.SetProperties(
                response.RwType);
            return(request);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALPostTypeMapper();
            ApiPostTypeServerRequestModel model = new ApiPostTypeServerRequestModel();

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

            response.RwType.Should().Be("A");
        }
        public virtual ApiPostTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiPostTypeServerRequestModel request)
        {
            var response = new ApiPostTypeServerResponseModel();

            response.SetProperties(id,
                                   request.RwType);
            return(response);
        }
Esempio n. 5
0
        public virtual PostType MapModelToEntity(
            int id,
            ApiPostTypeServerRequestModel model
            )
        {
            PostType item = new PostType();

            item.SetProperties(
                id,
                model.RwType);
            return(item);
        }
Esempio n. 6
0
        public virtual async Task <CreateResponse <ApiPostTypeServerResponseModel> > Create(
            ApiPostTypeServerRequestModel model)
        {
            CreateResponse <ApiPostTypeServerResponseModel> response = ValidationResponseFactory <ApiPostTypeServerResponseModel> .CreateResponse(await this.PostTypeModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                PostType record = this.DalPostTypeMapper.MapModelToEntity(default(int), model);
                record = await this.PostTypeRepository.Create(record);

                response.SetRecord(this.DalPostTypeMapper.MapEntityToModel(record));
                await this.mediator.Publish(new PostTypeCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 7
0
        public virtual async Task <UpdateResponse <ApiPostTypeServerResponseModel> > Update(
            int id,
            ApiPostTypeServerRequestModel model)
        {
            var validationResult = await this.PostTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PostType record = this.DalPostTypeMapper.MapModelToEntity(id, model);
                await this.PostTypeRepository.Update(record);

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

                ApiPostTypeServerResponseModel apiModel = this.DalPostTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PostTypeUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiPostTypeServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiPostTypeServerResponseModel> .UpdateResponse(validationResult));
            }
        }