public FranchiseeTenant CheckFranchiseeWithNameAndLicenseKey(string franchiseeName, string licenseKey) { var now = DateTime.UtcNow; return (_franchiseeTenantRepository.FirstOrDefault( o => o.Name == franchiseeName && o.LicenseKey == licenseKey && o.EndActiveDate >= now && o.IsActive)); }
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); } }