public JsonPatchDocument <ApiPersonServerRequestModel> CreatePatch(ApiPersonServerRequestModel model) { var patch = new JsonPatchDocument <ApiPersonServerRequestModel>(); patch.Replace(x => x.PersonName, model.PersonName); return(patch); }
public virtual ApiPersonServerRequestModel MapServerResponseToRequest( ApiPersonServerResponseModel response) { var request = new ApiPersonServerRequestModel(); request.SetProperties( response.PersonName); return(request); }
public void MapModelToEntity() { var mapper = new DALPersonMapper(); ApiPersonServerRequestModel model = new ApiPersonServerRequestModel(); model.SetProperties("A"); Person response = mapper.MapModelToEntity(1, model); response.PersonName.Should().Be("A"); }
public virtual ApiPersonServerResponseModel MapServerRequestToResponse( int personId, ApiPersonServerRequestModel request) { var response = new ApiPersonServerResponseModel(); response.SetProperties(personId, request.PersonName); return(response); }
public virtual Person MapModelToEntity( int personId, ApiPersonServerRequestModel model ) { Person item = new Person(); item.SetProperties( personId, model.PersonName); return(item); }
public virtual async Task <CreateResponse <ApiPersonServerResponseModel> > Create( ApiPersonServerRequestModel model) { CreateResponse <ApiPersonServerResponseModel> response = ValidationResponseFactory <ApiPersonServerResponseModel> .CreateResponse(await this.PersonModelValidator.ValidateCreateAsync(model)); if (response.Success) { Person record = this.DalPersonMapper.MapModelToEntity(default(int), model); record = await this.PersonRepository.Create(record); response.SetRecord(this.DalPersonMapper.MapEntityToModel(record)); await this.mediator.Publish(new PersonCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiPersonServerResponseModel> > Update( int personId, ApiPersonServerRequestModel model) { var validationResult = await this.PersonModelValidator.ValidateUpdateAsync(personId, model); if (validationResult.IsValid) { Person record = this.DalPersonMapper.MapModelToEntity(personId, model); await this.PersonRepository.Update(record); record = await this.PersonRepository.Get(personId); ApiPersonServerResponseModel apiModel = this.DalPersonMapper.MapEntityToModel(record); await this.mediator.Publish(new PersonUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiPersonServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiPersonServerResponseModel> .UpdateResponse(validationResult)); } }