public JsonPatchDocument <ApiCountryServerRequestModel> CreatePatch(ApiCountryServerRequestModel model) { var patch = new JsonPatchDocument <ApiCountryServerRequestModel>(); patch.Replace(x => x.Name, model.Name); return(patch); }
public virtual ApiCountryServerRequestModel MapServerResponseToRequest( ApiCountryServerResponseModel response) { var request = new ApiCountryServerRequestModel(); request.SetProperties( response.Name); return(request); }
public virtual ApiCountryServerResponseModel MapServerRequestToResponse( int id, ApiCountryServerRequestModel request) { var response = new ApiCountryServerResponseModel(); response.SetProperties(id, request.Name); return(response); }
public void MapModelToEntity() { var mapper = new DALCountryMapper(); ApiCountryServerRequestModel model = new ApiCountryServerRequestModel(); model.SetProperties("A"); Country response = mapper.MapModelToEntity(1, model); response.Name.Should().Be("A"); }
public virtual Country MapModelToEntity( int id, ApiCountryServerRequestModel model ) { Country item = new Country(); item.SetProperties( id, model.Name); return(item); }
public virtual async Task <CreateResponse <ApiCountryServerResponseModel> > Create( ApiCountryServerRequestModel model) { CreateResponse <ApiCountryServerResponseModel> response = ValidationResponseFactory <ApiCountryServerResponseModel> .CreateResponse(await this.CountryModelValidator.ValidateCreateAsync(model)); if (response.Success) { Country record = this.DalCountryMapper.MapModelToEntity(default(int), model); record = await this.CountryRepository.Create(record); response.SetRecord(this.DalCountryMapper.MapEntityToModel(record)); await this.mediator.Publish(new CountryCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiCountryServerResponseModel> > Update( int id, ApiCountryServerRequestModel model) { var validationResult = await this.CountryModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Country record = this.DalCountryMapper.MapModelToEntity(id, model); await this.CountryRepository.Update(record); record = await this.CountryRepository.Get(id); ApiCountryServerResponseModel apiModel = this.DalCountryMapper.MapEntityToModel(record); await this.mediator.Publish(new CountryUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiCountryServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiCountryServerResponseModel> .UpdateResponse(validationResult)); } }