//change user permissions  quick
        public ActionResult UserPermissions(int?id)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            string        Checked       = "";
            StringBuilder stringBuilder = new StringBuilder();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            caTenant tenant = caCurrent.CurrentTenant();
            caUser   user   = caCurrent.CurrentUser();

            var userModules = _tenantServices.GetAllTenantModules(user.TenantId).Select(m => m.ModuleId).ToList();

            ICollection <TenantLocations> WareHouse = tenant.TenantLocations.Where(x => x.IsMobile != true).ToList();

            stringBuilder.Append(string.Format("<input type=\"hidden\" name=\"UserId\" value=\"{0}\" />", id));

            foreach (TenantLocations vh in WareHouse)
            {
                stringBuilder.Append(string.Format("<div id=\"page-wrap{0}\" class=\"page-wrap form-horizontal\">", vh.WarehouseId));
                stringBuilder.Append("<ul>");
                stringBuilder.Append("<li>");
                stringBuilder.Append(string.Format("<input type=\"checkbox\" name=\"wareh\" id=\"wareh-{0}\" value=\"{0}\">", vh.WarehouseId, vh.WarehouseName));
                stringBuilder.Append(string.Format("<label for=\"wareh-{0}\">{1}</label>", vh.WarehouseId, vh.WarehouseName));

                stringBuilder.Append("<ul class=\"wareh-ul\">");

                var Groups = _activityServices.GetDistinctActivityGroupsForPerm(userModules);

                foreach (var Grp in Groups)
                {
                    stringBuilder.Append("<li class=\"group-li\">");
                    stringBuilder.Append(string.Format("<input type=\"checkbox\" name=\"group-{0}-{1}\" id=\"group-{0}-{1}\" value=\"{1}\">", vh.WarehouseId, Grp.ActivityGroupId));
                    stringBuilder.Append(string.Format("<label for=\"group-{0}-{1}\">{2}</label>", vh.WarehouseId, Grp.ActivityGroupId, Grp.ActivityGroupName));
                    stringBuilder.Append("<ul class=\"group-ul\">");

                    var nav = _activityServices.GetAuthActivitiesForPermByGroup(Grp, userModules, CurrentTenantId);

                    foreach (var perm in nav)
                    {
                        if (_activityServices.PermCheckByActivityId(perm.ActivityId, (int)id, vh.WarehouseId))
                        {
                            Checked = "checked";
                        }

                        stringBuilder.Append("<li class=\"col-lg-2 col-md-3 col-sm-4 pull-left\">");
                        stringBuilder.Append(string.Format("<input type=\"checkbox\" name=\"perm\" id=\"{0}-{1}\" {2} value=\"{0}-{1}\">", vh.WarehouseId, perm.ActivityId, Checked));
                        stringBuilder.Append(string.Format("<label for=\"{0}-{1}\">{2}</label>", vh.WarehouseId, perm.ActivityId, perm.ActivityName));
                        stringBuilder.Append("</li>");

                        Checked = "";
                    }

                    stringBuilder.Append("</ul>");
                    stringBuilder.Append("</li>");
                }

                // check the activities which are not in any group
                var nav2 = _activityServices.GetAuthActivitiesForPermNoGroup(userModules);

                if (nav2.Count() > 0)
                {
                    stringBuilder.Append("<li>");
                    stringBuilder.Append(string.Format("<input type=\"checkbox\" name=\"Misc-{0}\" id=\"Misc-{0}\" value=\"{0}\">", vh.WarehouseId));
                    stringBuilder.Append(string.Format("<label for=\"Misc-{0}\">Miscellaneous</label>", vh.WarehouseId));
                    stringBuilder.Append("<ul>");

                    foreach (var perm2 in nav2)
                    {
                        if (_activityServices.PermCheckByActivityId(perm2.ActivityId, (int)id, vh.WarehouseId))
                        {
                            Checked = "checked";
                        }

                        stringBuilder.Append("<li>");
                        stringBuilder.Append(string.Format("<input type=\"checkbox\" name=\"perm\" id=\"{0}-{1}\" {2} value=\"{0}-{1}\">", vh.WarehouseId, perm2.ActivityId, Checked));
                        stringBuilder.Append(string.Format("<label for=\"{0}-{1}\">{2}</label>", vh.WarehouseId, perm2.ActivityId, perm2.ActivityName));
                        stringBuilder.Append("</li>");

                        Checked = "";
                    }

                    stringBuilder.Append("</ul>");
                    stringBuilder.Append("</li>");
                }

                stringBuilder.Append("</ul>");
                stringBuilder.Append("</li>");
                stringBuilder.Append("</ul>");
                stringBuilder.Append("</div>");
            }

            stringBuilder.Append("<div class=\"page-wrap-btn\">");
            stringBuilder.Append("</div>");

            ViewBag.permissions = stringBuilder.ToString();
            return(View());
        }