Esempio n. 1
0
        public ApiMessage GetAdminRoles()
        {
            ApiMessage message = new ApiMessage() { Status = "ok" };
            List<BAdminRole> roles = new List<BAdminRole>();
            HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];
            HttpRequestBase request = context.Request;
            string user_id = User.Identity.Name;
            UserManager userMgr = new UserManager(int.Parse(user_id), null);
            BUser user = userMgr.CurrentUser;
            PermissionManagement permissionMgt = new PermissionManagement(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission);
            bool enabled = true;
            if (request["enabled"] != null && request["enabled"] == "0")
            {
                enabled = false;
            }
            int shop = 0;
            int.TryParse(request["shop"],out shop);
            try
            {
                roles = permissionMgt.GetAdminRoles(shop, enabled);
                message.Item = roles;
            }
            catch (KMJXCException kex)
            {
                message.Status = "failed";
                message.Message = kex.Message;
            }
            catch
            {
            }
            finally
            {

            }
            return message;
        }