public virtual ApiSubscriptionClientRequestModel MapServerResponseToClientRequest(
            ApiSubscriptionServerResponseModel response)
        {
            var request = new ApiSubscriptionClientRequestModel();

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

            response.SetProperties(id,
                                   request.Name,
                                   request.StripePlanName);
            return(response);
        }
Beispiel #3
0
        public virtual ApiSubscriptionServerResponseModel MapEntityToModel(
            Subscription item)
        {
            var model = new ApiSubscriptionServerResponseModel();

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

            return(model);
        }
Beispiel #4
0
        public void MapEntityToModel()
        {
            var          mapper = new DALSubscriptionMapper();
            Subscription item   = new Subscription();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.StripePlanName.Should().Be("A");
        }
Beispiel #5
0
        public virtual async Task <UpdateResponse <ApiSubscriptionServerResponseModel> > Update(
            int id,
            ApiSubscriptionServerRequestModel model)
        {
            var validationResult = await this.SubscriptionModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Subscription record = this.DalSubscriptionMapper.MapModelToEntity(id, model);
                await this.SubscriptionRepository.Update(record);

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

                ApiSubscriptionServerResponseModel apiModel = this.DalSubscriptionMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SubscriptionUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiSubscriptionServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiSubscriptionServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public SubscriptionUpdatedNotification(ApiSubscriptionServerResponseModel record)
 {
     this.Record = record;
 }