public JsonPatchDocument <ApiPaymentTypeServerRequestModel> CreatePatch(ApiPaymentTypeServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiPaymentTypeServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
        public virtual ApiPaymentTypeServerRequestModel MapServerResponseToRequest(
            ApiPaymentTypeServerResponseModel response)
        {
            var request = new ApiPaymentTypeServerRequestModel();

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

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Example #4
0
        public void MapModelToEntity()
        {
            var mapper = new DALPaymentTypeMapper();
            ApiPaymentTypeServerRequestModel model = new ApiPaymentTypeServerRequestModel();

            model.SetProperties("A");
            PaymentType response = mapper.MapModelToEntity(1, model);

            response.Name.Should().Be("A");
        }
        public virtual PaymentType MapModelToEntity(
            int id,
            ApiPaymentTypeServerRequestModel model
            )
        {
            PaymentType item = new PaymentType();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
Example #6
0
        public virtual async Task <CreateResponse <ApiPaymentTypeServerResponseModel> > Create(
            ApiPaymentTypeServerRequestModel model)
        {
            CreateResponse <ApiPaymentTypeServerResponseModel> response = ValidationResponseFactory <ApiPaymentTypeServerResponseModel> .CreateResponse(await this.PaymentTypeModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                PaymentType record = this.DalPaymentTypeMapper.MapModelToEntity(default(int), model);
                record = await this.PaymentTypeRepository.Create(record);

                response.SetRecord(this.DalPaymentTypeMapper.MapEntityToModel(record));
                await this.mediator.Publish(new PaymentTypeCreatedNotification(response.Record));
            }

            return(response);
        }
Example #7
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));
            }
        }