public virtual ApiSaleServerResponseModel MapEntityToModel( Sale item) { var model = new ApiSaleServerResponseModel(); model.SetProperties(item.Id, item.Amount, item.CutomerId, item.Note, item.PetId, item.SaleDate, item.SalesPersonId); if (item.PetIdNavigation != null) { var petIdModel = new ApiPetServerResponseModel(); petIdModel.SetProperties( item.PetIdNavigation.Id, item.PetIdNavigation.BreedId, item.PetIdNavigation.ClientId, item.PetIdNavigation.Name, item.PetIdNavigation.Weight); model.SetPetIdNavigation(petIdModel); } return(model); }
public virtual ApiPetClientRequestModel MapServerResponseToClientRequest( ApiPetServerResponseModel response) { var request = new ApiPetClientRequestModel(); request.SetProperties( response.BreedId, response.ClientId, response.Name, response.Weight); return(request); }
public virtual ApiPetServerResponseModel MapServerRequestToResponse( int id, ApiPetServerRequestModel request) { var response = new ApiPetServerResponseModel(); response.SetProperties(id, request.BreedId, request.ClientId, request.Name, request.Weight); return(response); }
public void MapEntityToModel() { var mapper = new DALPetMapper(); Pet item = new Pet(); item.SetProperties(1, 1, 1, "A", 1); ApiPetServerResponseModel response = mapper.MapEntityToModel(item); response.BreedId.Should().Be(1); response.ClientId.Should().Be(1); response.Id.Should().Be(1); response.Name.Should().Be("A"); response.Weight.Should().Be(1); }
public virtual ApiPetServerResponseModel MapEntityToModel( Pet item) { var model = new ApiPetServerResponseModel(); model.SetProperties(item.Id, item.BreedId, item.ClientId, item.Name, item.Weight); if (item.BreedIdNavigation != null) { var breedIdModel = new ApiBreedServerResponseModel(); breedIdModel.SetProperties( item.BreedIdNavigation.Id, item.BreedIdNavigation.Name, item.BreedIdNavigation.SpeciesId); model.SetBreedIdNavigation(breedIdModel); } return(model); }
public virtual async Task <UpdateResponse <ApiPetServerResponseModel> > Update( int id, ApiPetServerRequestModel model) { var validationResult = await this.PetModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Pet record = this.DalPetMapper.MapModelToEntity(id, model); await this.PetRepository.Update(record); record = await this.PetRepository.Get(id); ApiPetServerResponseModel apiModel = this.DalPetMapper.MapEntityToModel(record); await this.mediator.Publish(new PetUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiPetServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiPetServerResponseModel> .UpdateResponse(validationResult)); } }
public void SetPetIdNavigation(ApiPetServerResponseModel value) { this.PetIdNavigation = value; }
public PetUpdatedNotification(ApiPetServerResponseModel record) { this.Record = record; }