/// <summary>
            ///
            /// </summary>
            /// <returns></returns>
            public ModelDashboardPermission ToModel(int id)
            {
                var fp = new ModelDashboardPermission()
                {
                    Dashboard = new ModelDashboard()
                    {
                        Id = id,
                    },

                    Permission = Permission
                };

                if (UserId.HasValue)
                {
                    fp.User = new ED.Security.User()
                    {
                        Id = UserId.Value
                    };
                }
                else if (TeamId.HasValue)
                {
                    fp.Team = new ED.Security.Team()
                    {
                        Id = TeamId.Value
                    };
                }
                else if (Role.HasValue)
                {
                    fp.Role = Role;
                }

                return(fp);
            }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static ModelDashboardPermissions GetDefault(ModelDashboard db)
        {
            var list = new ModelDashboardPermissions();

            var editor = new ModelDashboardPermission()
            {
                Role       = Security.Role.Editor,
                Permission = Security.Permission.Edit,
                Dashboard  = db,
            };

            var viewer = new ModelDashboardPermission()
            {
                Role       = Security.Role.Viewer,
                Permission = Security.Permission.View,
                Dashboard  = db,
            };

            editor.Bag.Created     = editor.Bag.Updated =
                viewer.Bag.Created = viewer.Bag.Updated = DateTime.Now;

            list.Add(editor);
            list.Add(viewer);

            return(list);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public static EntityDashboardPermission ToEntity(this ModelDashboardPermission dp)
        {
            var e = new EntityDashboardPermission()
            {
                //OrgId = fp.Org,
                DashboardId = dp.Dashboard.Id,
                Permission  = dp.Permission
            };

            if (null != dp.User)
            {
                e.UserId = dp.User.Id;
            }
            else if (null != dp.Team)
            {
                e.TeamId = dp.Team.Id;
            }
            else
            {
                e.Role = dp.Role;
            }

            return(e);
        }