public virtual ApiPetServerResponseModel MapEntityToModel( Pet item) { var model = new ApiPetServerResponseModel(); model.SetProperties(item.Id, item.AcquiredDate, item.BreedId, item.Description, item.PenId, item.Price); if (item.BreedIdNavigation != null) { var breedIdModel = new ApiBreedServerResponseModel(); breedIdModel.SetProperties( item.BreedIdNavigation.Id, item.BreedIdNavigation.Name, item.BreedIdNavigation.SpeciesId); model.SetBreedIdNavigation(breedIdModel); } if (item.PenIdNavigation != null) { var penIdModel = new ApiPenServerResponseModel(); penIdModel.SetProperties( item.PenIdNavigation.Id, item.PenIdNavigation.Name); model.SetPenIdNavigation(penIdModel); } return(model); }
public virtual ApiPenClientRequestModel MapServerResponseToClientRequest( ApiPenServerResponseModel response) { var request = new ApiPenClientRequestModel(); request.SetProperties( response.Name); return(request); }
public virtual ApiPenServerResponseModel MapEntityToModel( Pen item) { var model = new ApiPenServerResponseModel(); model.SetProperties(item.Id, item.Name); return(model); }
public virtual ApiPenServerResponseModel MapServerRequestToResponse( int id, ApiPenServerRequestModel request) { var response = new ApiPenServerResponseModel(); response.SetProperties(id, request.Name); return(response); }
public void MapEntityToModel() { var mapper = new DALPenMapper(); Pen item = new Pen(); item.SetProperties(1, "A"); ApiPenServerResponseModel response = mapper.MapEntityToModel(item); response.Id.Should().Be(1); response.Name.Should().Be("A"); }
public virtual async Task <UpdateResponse <ApiPenServerResponseModel> > Update( int id, ApiPenServerRequestModel model) { var validationResult = await this.PenModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Pen record = this.DalPenMapper.MapModelToEntity(id, model); await this.PenRepository.Update(record); record = await this.PenRepository.Get(id); ApiPenServerResponseModel apiModel = this.DalPenMapper.MapEntityToModel(record); await this.mediator.Publish(new PenUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiPenServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiPenServerResponseModel> .UpdateResponse(validationResult)); } }
public PenUpdatedNotification(ApiPenServerResponseModel record) { this.Record = record; }
public void SetPenIdNavigation(ApiPenServerResponseModel value) { this.PenIdNavigation = value; }