Пример #1
0
        public override void AssignMembershipRole(string userId, MembershipProductType membershipType, TimeSpan timeSpan)
        {
            var portalId = PortalSettings.Current.PortalId;
            var userInfo = UserController.GetUserById(portalId, Convert.ToInt32(userId));

            var _roleController    = new RoleController();
            var roleInfo           = _roleController.GetRoleByName(portalId, membershipType.RoleName);
            var lastExpirationTime = TimeSpan.Zero;

            if (userInfo.IsInRole(membershipType.RoleName))
            {
                var userRole     = _roleController.GetUserRole(portalId, userInfo.UserID, roleInfo.RoleID);
                var unusedPeriod = userRole.ExpiryDate - DateTime.Now;

                if (lastExpirationTime < unusedPeriod)
                {
                    lastExpirationTime = unusedPeriod;
                }

                RoleController.DeleteUserRole(userInfo, roleInfo, PortalSettings.Current, false);
            }

            // DNN does verification against "DateTime.Now" and doesn't use UTC.
            RoleController.AddUserRole(userInfo, roleInfo, PortalSettings.Current,
                                       RoleStatus.Approved,
                                       DateTime.Now,                                 // effective date
                                       DateTime.Now + lastExpirationTime + timeSpan, // expiration date
                                       membershipType.Notify,                        // notify user
                                       false);                                       // is owner
        }
Пример #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Model = new MembershipProductType
                {
                    ProductTypeId        = TypeId,
                    StoreId              = HccApp.CurrentStore.Id,
                    ProductTypeName      = txtProductTypeName.Text.Trim(),
                    RoleName             = ddlMembershipRole.SelectedValue,
                    ExpirationPeriod     = (int)txtExpirationNum.Value,
                    ExpirationPeriodType = (ExpirationPeriodType)Convert.ToInt32(ddlPeriodType.SelectedValue)
                };

                if (SaveData != null)
                {
                    SaveData(this, EventArgs.Empty);
                }
            }
        }
Пример #3
0
 public override void AssignMembershipRole(string userId, MembershipProductType membershipType, TimeSpan timeSpan)
 {
     throw new NotImplementedException();
 }
 public abstract void AssignMembershipRole(string userId, MembershipProductType membershipType, TimeSpan timeSpan);