public JsonPatchDocument <ApiPostHistoryTypeServerRequestModel> CreatePatch(ApiPostHistoryTypeServerRequestModel model) { var patch = new JsonPatchDocument <ApiPostHistoryTypeServerRequestModel>(); patch.Replace(x => x.RwType, model.RwType); return(patch); }
public virtual ApiPostHistoryTypeServerRequestModel MapServerResponseToRequest( ApiPostHistoryTypeServerResponseModel response) { var request = new ApiPostHistoryTypeServerRequestModel(); request.SetProperties( response.RwType); return(request); }
public virtual ApiPostHistoryTypeServerResponseModel MapServerRequestToResponse( int id, ApiPostHistoryTypeServerRequestModel request) { var response = new ApiPostHistoryTypeServerResponseModel(); response.SetProperties(id, request.RwType); return(response); }
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"); }
public virtual PostHistoryType MapModelToEntity( int id, ApiPostHistoryTypeServerRequestModel model ) { PostHistoryType item = new PostHistoryType(); item.SetProperties( id, model.RwType); return(item); }
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); }
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)); } }