Beispiel #1
0
        public ActionResult GetRoles(FormCollection collection)
        {
            ResultText resultText = new ResultText();
            int userId = int.Parse(collection["userId"]);
            if (userService.GetUserWithDomain(User.Identity.Name).isManager)
            {

                User user = userService.GetUser(userId);
                bool isManager = collection["isManager"] == "true,false";
                user.isManager = isManager;

                bool isViewer = collection["isViewer"] == "true,false";
                user.isViewer = isViewer;

                userService.ApplyCurrentValues(user);
                foreach (string key in collection.Keys)
                {
                    int id = -1;
                    try
                    {
                        id = int.Parse(key);
                        bool val = collection[key] == "true,false";
                        if (val)
                        {
                            rightService.AddRole(user.id,id);
                        }
                        else
                        {
                            rightService.RemoveRole(user.id,id);
                        }

                    }
                    catch (Exception)
                    {

                    }

                }

                resultText = resultsService.GetResultText(Constants.ResultTypes.SuccessAction);

            }
            else
            {
                resultText = resultsService.GetResultText(Constants.ResultTypes.HasNoRight);
            }

            //return GetRoles(userId.ToString(),resultText);//return "loaded" + id;
            return GetRoles(userId.ToString(), resultText);
        }
Beispiel #2
0
        public ActionResult GetRoles(string id, ResultText resultText)
        {
            List<Role> roles = rightService.GetAllRoles();
            List<int> rights = rightService.GetRoles(int.Parse(id)).Select(rig => rig.id).ToList();
            RoleModel roleModel = new RoleModel();
            roleModel.ResultText = resultText;
            roleModel.User = userService.GetUser(int.Parse(id));
            roleModel.roleListModel = new List<RoleListModel>();
            foreach (var role in roles)
            {
                bool hasRole = rights.Any(rol => rights.Contains(role.id));
                roleModel.roleListModel.Add(new RoleListModel() { id = role.id, name = role.name, hasRole = hasRole });
            }

            return PartialView(roleModel);
        }
Beispiel #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ResultTexts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToResultTexts(ResultText resultText)
 {
     base.AddObject("ResultTexts", resultText);
 }
Beispiel #4
0
 /// <summary>
 /// Create a new ResultText object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="success">Initial value of the success property.</param>
 public static ResultText CreateResultText(global::System.String id, global::System.Boolean success)
 {
     ResultText resultText = new ResultText();
     resultText.id = id;
     resultText.success = success;
     return resultText;
 }