Пример #1
0
        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);
        }
Пример #2
0
        public virtual ApiPetServerResponseModel MapServerRequestToResponse(
            int id,
            ApiPetServerRequestModel request)
        {
            var response = new ApiPetServerResponseModel();

            response.SetProperties(id,
                                   request.AcquiredDate,
                                   request.BreedId,
                                   request.Description,
                                   request.PenId,
                                   request.Price);
            return(response);
        }
Пример #3
0
        public virtual ApiSaleServerResponseModel MapEntityToModel(
            Sale item)
        {
            var model = new ApiSaleServerResponseModel();

            model.SetProperties(item.Id,
                                item.Amount,
                                item.FirstName,
                                item.LastName,
                                item.PaymentTypeId,
                                item.PetId,
                                item.Phone);
            if (item.PaymentTypeIdNavigation != null)
            {
                var paymentTypeIdModel = new ApiPaymentTypeServerResponseModel();
                paymentTypeIdModel.SetProperties(
                    item.PaymentTypeIdNavigation.Id,
                    item.PaymentTypeIdNavigation.Name);

                model.SetPaymentTypeIdNavigation(paymentTypeIdModel);
            }

            if (item.PetIdNavigation != null)
            {
                var petIdModel = new ApiPetServerResponseModel();
                petIdModel.SetProperties(
                    item.PetIdNavigation.Id,
                    item.PetIdNavigation.AcquiredDate,
                    item.PetIdNavigation.BreedId,
                    item.PetIdNavigation.Description,
                    item.PetIdNavigation.PenId,
                    item.PetIdNavigation.Price);

                model.SetPetIdNavigation(petIdModel);
            }

            return(model);
        }