Example #1
0
        public JsonPatchDocument <ApiPostHistoryTypeServerRequestModel> CreatePatch(ApiPostHistoryTypeServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiPostHistoryTypeServerRequestModel>();

            patch.Replace(x => x.RwType, model.RwType);
            return(patch);
        }
Example #2
0
        public virtual ApiPostHistoryTypeServerRequestModel MapServerResponseToRequest(
            ApiPostHistoryTypeServerResponseModel response)
        {
            var request = new ApiPostHistoryTypeServerRequestModel();

            request.SetProperties(
                response.RwType);
            return(request);
        }
Example #3
0
        public virtual ApiPostHistoryTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiPostHistoryTypeServerRequestModel request)
        {
            var response = new ApiPostHistoryTypeServerResponseModel();

            response.SetProperties(id,
                                   request.RwType);
            return(response);
        }
Example #4
0
        public void MapModelToEntity()
        {
            var mapper = new DALPostHistoryTypeMapper();
            ApiPostHistoryTypeServerRequestModel model = new ApiPostHistoryTypeServerRequestModel();

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

            response.RwType.Should().Be("A");
        }
Example #5
0
        public virtual PostHistoryType MapModelToEntity(
            int id,
            ApiPostHistoryTypeServerRequestModel model
            )
        {
            PostHistoryType item = new PostHistoryType();

            item.SetProperties(
                id,
                model.RwType);
            return(item);
        }
Example #6
0
        public virtual async Task <CreateResponse <ApiPostHistoryTypeServerResponseModel> > Create(
            ApiPostHistoryTypeServerRequestModel model)
        {
            CreateResponse <ApiPostHistoryTypeServerResponseModel> response = ValidationResponseFactory <ApiPostHistoryTypeServerResponseModel> .CreateResponse(await this.PostHistoryTypeModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                PostHistoryType record = this.DalPostHistoryTypeMapper.MapModelToEntity(default(int), model);
                record = await this.PostHistoryTypeRepository.Create(record);

                response.SetRecord(this.DalPostHistoryTypeMapper.MapEntityToModel(record));
                await this.mediator.Publish(new PostHistoryTypeCreatedNotification(response.Record));
            }

            return(response);
        }
Example #7
0
        public virtual async Task <UpdateResponse <ApiPostHistoryTypeServerResponseModel> > Update(
            int id,
            ApiPostHistoryTypeServerRequestModel model)
        {
            var validationResult = await this.PostHistoryTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PostHistoryType record = this.DalPostHistoryTypeMapper.MapModelToEntity(id, model);
                await this.PostHistoryTypeRepository.Update(record);

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

                ApiPostHistoryTypeServerResponseModel apiModel = this.DalPostHistoryTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PostHistoryTypeUpdatedNotification(apiModel));

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