Ejemplo n.º 1
0
        public void DoImport(Stream backupStream, Action <ExportImportProgressInfo> progressCallback)
        {
            var backupObject = backupStream.DeserializeJson <BackupObject>();

            var progressInfo = new ExportImportProgressInfo();
            var totalCount   = backupObject.Subscriptions.Count();
            var take         = 20;

            for (int skip = 0; skip < totalCount; skip += take)
            {
                _subscriptionService.SaveSubscriptions(backupObject.Subscriptions.Skip(skip).Take(take).ToArray());
                progressInfo.Description = String.Format("{0} of {1} subscriptions imported", Math.Min(skip + take, totalCount), totalCount);
                progressCallback(progressInfo);
            }

            totalCount = backupObject.PaymentPlans.Count();
            for (int skip = 0; skip < totalCount; skip += take)
            {
                _paymentPlanService.SavePlans(backupObject.PaymentPlans.Skip(skip).Take(take).ToArray());
                progressInfo.Description = String.Format("{0} of {1} payment plans imported", Math.Min(skip + take, totalCount), totalCount);
                progressCallback(progressInfo);
            }
        }
Ejemplo n.º 2
0
 public IHttpActionResult CreatePaymentPlan(PaymentPlan plan)
 {
     _planService.SavePlans(new[] { plan });
     return(Ok(plan));
 }