public virtual ApiCountryRequirementServerRequestModel MapServerResponseToRequest( ApiCountryRequirementServerResponseModel response) { var request = new ApiCountryRequirementServerRequestModel(); request.SetProperties( response.CountryId, response.Details); return(request); }
public virtual ApiCountryRequirementServerResponseModel MapServerRequestToResponse( int id, ApiCountryRequirementServerRequestModel request) { var response = new ApiCountryRequirementServerResponseModel(); response.SetProperties(id, request.CountryId, request.Details); return(response); }
public void MapModelToEntity() { var mapper = new DALCountryRequirementMapper(); ApiCountryRequirementServerRequestModel model = new ApiCountryRequirementServerRequestModel(); model.SetProperties(1, "A"); CountryRequirement response = mapper.MapModelToEntity(1, model); response.CountryId.Should().Be(1); response.Details.Should().Be("A"); }
public virtual CountryRequirement MapModelToEntity( int id, ApiCountryRequirementServerRequestModel model ) { CountryRequirement item = new CountryRequirement(); item.SetProperties( id, model.CountryId, model.Details); return(item); }
public virtual async Task <CreateResponse <ApiCountryRequirementServerResponseModel> > Create( ApiCountryRequirementServerRequestModel model) { CreateResponse <ApiCountryRequirementServerResponseModel> response = ValidationResponseFactory <ApiCountryRequirementServerResponseModel> .CreateResponse(await this.CountryRequirementModelValidator.ValidateCreateAsync(model)); if (response.Success) { CountryRequirement record = this.DalCountryRequirementMapper.MapModelToEntity(default(int), model); record = await this.CountryRequirementRepository.Create(record); response.SetRecord(this.DalCountryRequirementMapper.MapEntityToModel(record)); await this.mediator.Publish(new CountryRequirementCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiCountryRequirementServerResponseModel> > Update( int id, ApiCountryRequirementServerRequestModel model) { var validationResult = await this.CountryRequirementModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { CountryRequirement record = this.DalCountryRequirementMapper.MapModelToEntity(id, model); await this.CountryRequirementRepository.Update(record); record = await this.CountryRequirementRepository.Get(id); ApiCountryRequirementServerResponseModel apiModel = this.DalCountryRequirementMapper.MapEntityToModel(record); await this.mediator.Publish(new CountryRequirementUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiCountryRequirementServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiCountryRequirementServerResponseModel> .UpdateResponse(validationResult)); } }
public JsonPatchDocument <ApiCountryRequirementServerRequestModel> CreatePatch(ApiCountryRequirementServerRequestModel model) { var patch = new JsonPatchDocument <ApiCountryRequirementServerRequestModel>(); patch.Replace(x => x.CountryId, model.CountryId); patch.Replace(x => x.Details, model.Details); return(patch); }