Example #1
0
        public void OnBeforeSave(ISaveRequestHandler handler)
        {
            if (Authorization.HasPermission(PermissionKeys.Tenants))
            {
                return;
            }

            if (handler.Row is PaymentsRow ||
                handler.Row is SubscriptionsRow ||
                handler.Row is  PaymentsDetailsRow)
            {
                return;
            }
            var user = (UserDefinition)Authorization.UserDefinition;

            var tenantFld  = TenantRow.Fields;
            var connection = SqlConnections.NewFor <TenantRow>();
            var tenant     = connection.First <TenantRow>(tenantFld.TenantId == user.TenantId);

            if (tenant?.SubscriptionRequired != null && tenant.SubscriptionRequired.Value &&
                UserSubscriptionHelper.GetTenantPaidDays(user.TenantId) < DateTime.Now)
            {
                throw new ValidationException(Texts.Site.Subscriptions.Expired.SubscriptionInfoBoxHeader);
            }
        }
Example #2
0
        public IActionResult GetTenantSubscriptionEndDate()
        {
            if (!Authorization.IsLoggedIn)
            {
                return(NotFound());
            }

            var user = Authorization.UserDefinition as UserDefinition;
            var days = UserSubscriptionHelper.GetTenantPaidDays(user.TenantId);

            if (days <= DateTime.Now.AddDays(7) || Authorization.HasPermission("AdministrationTenants:Payments"))
            {
                return(Json(days));
            }
            else
            {
                return(Json(DateTime.MinValue));
            }
        }