public virtual ApiPaymentTypeClientRequestModel MapServerResponseToClientRequest(
            ApiPaymentTypeServerResponseModel response)
        {
            var request = new ApiPaymentTypeClientRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
Ejemplo n.º 2
0
        public virtual ApiPaymentTypeServerResponseModel MapEntityToModel(
            PaymentType item)
        {
            var model = new ApiPaymentTypeServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name);

            return(model);
        }
        public virtual ApiPaymentTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiPaymentTypeServerRequestModel request)
        {
            var response = new ApiPaymentTypeServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Ejemplo n.º 4
0
        public void MapEntityToModel()
        {
            var         mapper = new DALPaymentTypeMapper();
            PaymentType item   = new PaymentType();

            item.SetProperties(1, "A");
            ApiPaymentTypeServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public virtual async Task <UpdateResponse <ApiPaymentTypeServerResponseModel> > Update(
            int id,
            ApiPaymentTypeServerRequestModel model)
        {
            var validationResult = await this.PaymentTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PaymentType record = this.DalPaymentTypeMapper.MapModelToEntity(id, model);
                await this.PaymentTypeRepository.Update(record);

                record = await this.PaymentTypeRepository.Get(id);

                ApiPaymentTypeServerResponseModel apiModel = this.DalPaymentTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PaymentTypeUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiPaymentTypeServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiPaymentTypeServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Ejemplo n.º 7
0
 public PaymentTypeUpdatedNotification(ApiPaymentTypeServerResponseModel record)
 {
     this.Record = record;
 }
Ejemplo n.º 8
0
 public void SetPaymentTypeIdNavigation(ApiPaymentTypeServerResponseModel value)
 {
     this.PaymentTypeIdNavigation = value;
 }