public JsonPatchDocument <ApiPersonTypeServerRequestModel> CreatePatch(ApiPersonTypeServerRequestModel model) { var patch = new JsonPatchDocument <ApiPersonTypeServerRequestModel>(); patch.Replace(x => x.Name, model.Name); return(patch); }
public virtual ApiPersonTypeServerRequestModel MapServerResponseToRequest( ApiPersonTypeServerResponseModel response) { var request = new ApiPersonTypeServerRequestModel(); request.SetProperties( response.Name); return(request); }
public void MapModelToEntity() { var mapper = new DALPersonTypeMapper(); ApiPersonTypeServerRequestModel model = new ApiPersonTypeServerRequestModel(); model.SetProperties("A"); PersonType response = mapper.MapModelToEntity(1, model); response.Name.Should().Be("A"); }
public virtual ApiPersonTypeServerResponseModel MapServerRequestToResponse( int id, ApiPersonTypeServerRequestModel request) { var response = new ApiPersonTypeServerResponseModel(); response.SetProperties(id, request.Name); return(response); }
public virtual PersonType MapModelToEntity( int id, ApiPersonTypeServerRequestModel model ) { PersonType item = new PersonType(); item.SetProperties( id, model.Name); return(item); }
public virtual async Task <CreateResponse <ApiPersonTypeServerResponseModel> > Create( ApiPersonTypeServerRequestModel model) { CreateResponse <ApiPersonTypeServerResponseModel> response = ValidationResponseFactory <ApiPersonTypeServerResponseModel> .CreateResponse(await this.PersonTypeModelValidator.ValidateCreateAsync(model)); if (response.Success) { PersonType record = this.DalPersonTypeMapper.MapModelToEntity(default(int), model); record = await this.PersonTypeRepository.Create(record); response.SetRecord(this.DalPersonTypeMapper.MapEntityToModel(record)); await this.mediator.Publish(new PersonTypeCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiPersonTypeServerResponseModel> > Update( int id, ApiPersonTypeServerRequestModel model) { var validationResult = await this.PersonTypeModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { PersonType record = this.DalPersonTypeMapper.MapModelToEntity(id, model); await this.PersonTypeRepository.Update(record); record = await this.PersonTypeRepository.Get(id); ApiPersonTypeServerResponseModel apiModel = this.DalPersonTypeMapper.MapEntityToModel(record); await this.mediator.Publish(new PersonTypeUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiPersonTypeServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiPersonTypeServerResponseModel> .UpdateResponse(validationResult)); } }