Example #1
0
        public static string ProcessCommand(string paramCmd, HttpContext context)
        {
            var strOut = "CLIENT - ERROR!! - No Security rights for current user!";

            if (NBrightBuyUtils.CheckManagerRights())
            {
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                var userId   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/userid");

                switch (paramCmd)
                {
                case "client.admin_getlist":
                    strOut = ClientFunctions.ClientAdminList(context);
                    break;

                case "client.admin_getdetail":
                    strOut = ClientFunctions.ClientAdminDetail(context);
                    break;

                case "client.admin_save":
                    strOut = ClientFunctions.ClientAdminSave(context);
                    break;

                case "client.discountcodes":
                    //strOut = ClientFunctions.GetClientDiscountCodes(context);
                    break;

                case "client.adddiscountcode":
                    AddClientDiscountCodes(context);
                    strOut = ClientFunctions.ClientAdminDetail(context);
                    break;

                case "client.vouchercodes":
                    //strOut = ClientFunctions.GetClientVoucherCodes(context);
                    break;

                case "client.addvouchercode":
                    AddClientVoucherCodes(context);
                    strOut = ClientFunctions.ClientAdminDetail(context);
                    break;

                case "client.unlockuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.UnlockUser();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.deleteuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.DeleteUser();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.restoreuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.RestoreUser();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.removeuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.RemoveUser();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.validateuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.AuthoriseClient();
                            clientData.AddClientEditorRole();
                            if (StoreSettings.Current.Get("resetpasswordonclientvalidate") == "True")
                            {
                                clientData.ResetPassword();
                            }
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.unauthoriseuser":
                    if (userId > 0 && UserController.Instance.GetCurrentUserInfo()?.UserID != userId)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.UnAuthoriseClient();
                            clientData.RemoveClientEditorRole();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.resetpass":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.ResetPassword();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.createorder":
                    var cart = new CartData(PortalSettings.Current.PortalId);
                    cart.UserId   = userId;
                    cart.EditMode = "C";
                    cart.Save();
                    strOut = DnnUtils.GetResourceString("/DesktopModules/NBright/NBrightBuy/App_LocalResources/", "General.Processing");
                    break;
                }
            }
            return(strOut);
        }
Example #2
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg           = e.CommandArgument.ToString();
            var param          = new string[3];
            var navigationData = new NavigationData(PortalId, "ClientsAdmin");

            switch (e.CommandName.ToLower())
            {
            case "entrydetail":
                param[0] = "uid=" + cArg;
                if (_page != "")
                {
                    param[1] = "page=" + _page;
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "return":
                param[0] = "";
                if (_page != "")
                {
                    param[1] = "page=" + _page;
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "search":
                navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch, "", "");
                navigationData.Save();
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "resetsearch":
                // clear cookie info
                navigationData.Delete();
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "unlockuser":
                if (Utils.IsNumeric(cArg))
                {
                    var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                    clientData.UnlockUser();
                }
                param[0] = "uid=" + cArg;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "deleteuser":
                if (Utils.IsNumeric(cArg))
                {
                    var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                    clientData.DeleteUser();
                }
                param[0] = "uid=" + cArg;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "restoreuser":
                if (Utils.IsNumeric(cArg))
                {
                    var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                    clientData.RestoreUser();
                }
                param[0] = "uid=" + cArg;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "removeuser":
                if (Utils.IsNumeric(cArg))
                {
                    var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                    var ok         = clientData.RemoveUser();
                    if (!ok)
                    {
                        NBrightBuyUtils.SetNotfiyMessage(ModuleId, "removeuser", NotifyCode.fail);
                        param[0] = "uid=" + cArg;
                    }
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "validateuser":
                if (Utils.IsNumeric(cArg))
                {
                    var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                    clientData.AuthoriseClient();
                    clientData.AddClientEditorRole();
                    if (StoreSettings.Current.Get("resetpasswordonclientvalidate") == "True")
                    {
                        clientData.ResetPassword();
                    }
                }
                param[0] = "uid=" + cArg;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "unauthoriseuser":
                if (Utils.IsNumeric(cArg))
                {
                    var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                    clientData.UnAuthoriseClient();
                    clientData.RemoveClientEditorRole();
                }
                param[0] = "uid=" + cArg;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "resetpass":
                if (Utils.IsNumeric(cArg))
                {
                    var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                    clientData.ResetPassword();
                }
                param[0] = "uid=" + cArg;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;

            case "viewaddressbook":
                param[0] = "";
                if (Utils.IsNumeric(cArg))
                {
                    param[0] = "ctrl=addressbook";
                    param[1] = "uid=" + cArg;
                }
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "vieworders":
                param[0] = "";
                if (Utils.IsNumeric(cArg))
                {
                    param[0] = "ctrl=orders";
                    param[1] = "uid=" + cArg;
                }
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "createorder":
                param[0] = "";
                var tabId = TabId;
                if (Utils.IsNumeric(cArg))
                {
                    var cart = new CartData(PortalId);
                    cart.UserId   = Convert.ToInt32(cArg);
                    cart.EditMode = "C";
                    cart.Save();
                    tabId = StoreSettings.Current.GetInt("productlisttab");
                    if (tabId == 0)
                    {
                        tabId = TabId;
                    }
                }
                Response.Redirect(NBrightBuyUtils.AdminUrl(tabId, param), true);
                break;

            case "save":
                if (Utils.IsNumeric(cArg))
                {
                    var clientData = new ClientData(PortalId, Convert.ToInt32(cArg));
                    if (clientData.Exists)
                    {
                        clientData.Update(rpData);
                        clientData.Save();
                    }
                }
                param[0] = "uid=" + cArg;
                Response.Redirect(NBrightBuyUtils.AdminUrl(TabId, param), true);
                break;
            }
        }