Beispiel #1
0
        public bool AddPackageHistory(AddPackageHistoryDto packageHistoryInfo)
        {
            var franchisee = _franchiseeTenantRepository.FirstOrDefault(
                o => o.Name == packageHistoryInfo.FranchiseeName && o.LicenseKey == packageHistoryInfo.LicenseKey);
            var packageHistory = new PackageHistory();

            using (var scope = new TransactionScope())
            {
                packageHistory.PackageId          = packageHistoryInfo.PackageId;
                packageHistory.OldPackageId       = packageHistoryInfo.OldPackageId;
                packageHistory.StartDate          = packageHistoryInfo.StartDate;
                packageHistory.EndDate            = packageHistoryInfo.EndDate;
                packageHistory.RequestId          = packageHistoryInfo.RequestId;
                packageHistory.FranchiseeTenantId = packageHistoryInfo.FranchiseeTenantId;
                packageHistory.AccountNumber      = packageHistoryInfo.AccountNumber;
                packageHistory.IsApply            = packageHistoryInfo.IsApply;
                Add(packageHistory);

                if (!packageHistoryInfo.IsApply)
                {
                    franchisee.EndActiveDate = packageHistoryInfo.StartDate;
                }
                if (packageHistoryInfo.IsApply)
                {
                    franchisee.CurrentPackageId = packageHistoryInfo.PackageId;
                    franchisee.EndActiveDate    = packageHistoryInfo.EndDate;
                }

                franchisee.RemainingAmount        = packageHistoryInfo.Amount;
                franchisee.NextBillingDate        = packageHistoryInfo.NextBillingDate;
                franchisee.PackageNextBillingDate = packageHistoryInfo.PackageNextBillingDate;
                franchisee.StartDateSuccess       = null;
                franchisee.EndDateSuccess         = null;
                _franchiseeTenantRepository.Update(franchisee);
                _franchiseeTenantRepository.Commit();

                scope.Complete();
                return(true);
            }
        }
Beispiel #2
0
 public IHttpActionResult AddPackageHistory(AddPackageHistoryDto packageHistoryInfo)
 {
     return(Ok(_packageHistoryService.AddPackageHistory(packageHistoryInfo)));
 }