public JsonPatchDocument <ApiProvinceServerRequestModel> CreatePatch(ApiProvinceServerRequestModel model) { var patch = new JsonPatchDocument <ApiProvinceServerRequestModel>(); patch.Replace(x => x.CountryId, model.CountryId); patch.Replace(x => x.Name, model.Name); return(patch); }
public virtual ApiProvinceServerRequestModel MapServerResponseToRequest( ApiProvinceServerResponseModel response) { var request = new ApiProvinceServerRequestModel(); request.SetProperties( response.CountryId, response.Name); return(request); }
public void MapModelToEntity() { var mapper = new DALProvinceMapper(); ApiProvinceServerRequestModel model = new ApiProvinceServerRequestModel(); model.SetProperties(1, "A"); Province response = mapper.MapModelToEntity(1, model); response.CountryId.Should().Be(1); response.Name.Should().Be("A"); }
public virtual ApiProvinceServerResponseModel MapServerRequestToResponse( int id, ApiProvinceServerRequestModel request) { var response = new ApiProvinceServerResponseModel(); response.SetProperties(id, request.CountryId, request.Name); return(response); }
public virtual Province MapModelToEntity( int id, ApiProvinceServerRequestModel model ) { Province item = new Province(); item.SetProperties( id, model.CountryId, model.Name); return(item); }
public virtual async Task <CreateResponse <ApiProvinceServerResponseModel> > Create( ApiProvinceServerRequestModel model) { CreateResponse <ApiProvinceServerResponseModel> response = ValidationResponseFactory <ApiProvinceServerResponseModel> .CreateResponse(await this.ProvinceModelValidator.ValidateCreateAsync(model)); if (response.Success) { Province record = this.DalProvinceMapper.MapModelToEntity(default(int), model); record = await this.ProvinceRepository.Create(record); response.SetRecord(this.DalProvinceMapper.MapEntityToModel(record)); await this.mediator.Publish(new ProvinceCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiProvinceServerResponseModel> > Update( int id, ApiProvinceServerRequestModel model) { var validationResult = await this.ProvinceModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Province record = this.DalProvinceMapper.MapModelToEntity(id, model); await this.ProvinceRepository.Update(record); record = await this.ProvinceRepository.Get(id); ApiProvinceServerResponseModel apiModel = this.DalProvinceMapper.MapEntityToModel(record); await this.mediator.Publish(new ProvinceUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiProvinceServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiProvinceServerResponseModel> .UpdateResponse(validationResult)); } }