public JsonPatchDocument <ApiVPersonServerRequestModel> CreatePatch(ApiVPersonServerRequestModel model) { var patch = new JsonPatchDocument <ApiVPersonServerRequestModel>(); patch.Replace(x => x.PersonName, model.PersonName); return(patch); }
public void MapModelToEntity() { var mapper = new DALVPersonMapper(); ApiVPersonServerRequestModel model = new ApiVPersonServerRequestModel(); model.SetProperties("A"); VPerson response = mapper.MapModelToEntity(1, model); response.PersonName.Should().Be("A"); }
public virtual ApiVPersonServerRequestModel MapServerResponseToRequest( ApiVPersonServerResponseModel response) { var request = new ApiVPersonServerRequestModel(); request.SetProperties( response.PersonName); return(request); }
public virtual ApiVPersonServerResponseModel MapServerRequestToResponse( int personId, ApiVPersonServerRequestModel request) { var response = new ApiVPersonServerResponseModel(); response.SetProperties(personId, request.PersonName); return(response); }
public virtual VPerson MapModelToEntity( int personId, ApiVPersonServerRequestModel model ) { VPerson item = new VPerson(); item.SetProperties( personId, model.PersonName); return(item); }
public virtual async Task <CreateResponse <ApiVPersonServerResponseModel> > Create( ApiVPersonServerRequestModel model) { CreateResponse <ApiVPersonServerResponseModel> response = ValidationResponseFactory <ApiVPersonServerResponseModel> .CreateResponse(await this.VPersonModelValidator.ValidateCreateAsync(model)); if (response.Success) { VPerson record = this.DalVPersonMapper.MapModelToEntity(default(int), model); record = await this.VPersonRepository.Create(record); response.SetRecord(this.DalVPersonMapper.MapEntityToModel(record)); await this.mediator.Publish(new VPersonCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiVPersonServerResponseModel> > Update( int personId, ApiVPersonServerRequestModel model) { var validationResult = await this.VPersonModelValidator.ValidateUpdateAsync(personId, model); if (validationResult.IsValid) { VPerson record = this.DalVPersonMapper.MapModelToEntity(personId, model); await this.VPersonRepository.Update(record); record = await this.VPersonRepository.Get(personId); ApiVPersonServerResponseModel apiModel = this.DalVPersonMapper.MapEntityToModel(record); await this.mediator.Publish(new VPersonUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiVPersonServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiVPersonServerResponseModel> .UpdateResponse(validationResult)); } }