示例#1
0
 //not currently being used, meant for matching role name to ID
 public void SetCurrentRole(List <Microsoft.AspNet.Identity.EntityFramework.IdentityRole> roles)
 {
     foreach (var role in roles)
     {
         CurrentRole.Add(role);
     }
 }
        public ProfileViewModel(Account account, IEnumerable <Role> roles)
        {
            this.Id          = account.Id;
            this.Email       = account.Email;
            this.FirstName   = account.FirstName;
            this.LastName    = account.LastName;
            this.PhoneNumber = account.PhoneNumber;
            this.Addresses   = account.Address;
            this.Role        = account.Role;

            foreach (var role in roles)
            {
                if (role.RoleName == this.Role.RoleName)
                {
                    SelectListItem listItem = new SelectListItem()
                    {
                        Value = role.Id.ToString(),
                        Text  = role.RoleName
                    };
                    CurrentRole.Add(listItem);
                }
                else
                {
                    SelectListItem listItem = new SelectListItem()
                    {
                        Value = role.Id.ToString(),
                        Text  = role.RoleName
                    };
                    OtherRole.Add(listItem);
                }
            }

            Roles.AddRange(CurrentRole);
            Roles.AddRange(OtherRole);
        }
        private void BindRoles(Node origin, Node target, ManhattanGeometry geometry)
        {
            // Variable initialization
            _pathTo      = new Dictionary <Node, Node>();
            _origin      = origin;
            _destination = target;

            // Bind RolePlayers to Roles

            // Set the initial node as current.
            Current             = origin;
            CurrentIntersection = origin;
            DistanceGraph       = origin;

            Map = geometry;

            // A set of the unvisited nodes called the unvisited set consisting of all the nodes
            // except the initial node.
            Unvisited = new UnvisitedNodes(geometry.Nodes);
            Unvisited.Remove(origin);

            // Assign to every node a tentative distance value:
            // Set it to zero for our initial node and to infinity for all other nodes.
            TentativeDistance         = geometry.Nodes.ToDictionary(n => n, n => ManhattanGeometry.Infinity);
            TentativeDistance[origin] = 0;
        }
示例#4
0
        /// <summary>
        /// If current role has been specified check that
        /// user has this role in the specified context.
        /// Authorities for specified role is replaced
        /// with information from UserService for
        /// security reasons.
        /// </summary>
        /// <exception cref="ArgumentException">Thrown if user does not have the specified role in this context.</exception>
        private void CheckCurrentRole()
        {
            WebRole verifiedRole;

            if (CurrentRole.IsNotNull())
            {
                // Don't trust client information. Verify role information
                // and get authorities from UserService.
                verifiedRole = null;
                foreach (WebRole role in WebServiceData.UserManager.GetRoles(this))
                {
                    if (role.Id == CurrentRole.Id)
                    {
                        verifiedRole = role;
                        break;
                    }
                }
                if (verifiedRole.IsNull())
                {
                    // User does not have specified role.
                    throw new ArgumentException("User " + GetUser().UserName + " is not in role name:" + CurrentRole.Name + " id:" + CurrentRole.Id);
                }
                else
                {
                    _currentRole = verifiedRole;
                }
            }
        }
示例#5
0
        private CurrentUser Map(User user)
        {
            var currentRole = new CurrentRole()
            {
                Id   = user.RoleId,
                Code = user.Role.Code,
                Name = user.Role.Name
            };
            var currentTenant = new CurrentTenant()
            {
                Id   = user.TenantId,
                Code = user.Tenant.Code,
                Name = user.Tenant.Name
            };

            return(new CurrentUser()
            {
                Id = user.Id,
                Email = user.Email,
                Name = user.Name,
                Role = currentRole,
                Tenant = currentTenant
            });
        }
示例#6
0
        public override void Save()
        {
            log.WARN ("Save () called");

            // re-construct the data from the widget
            taskViewWidget.ConvertToTaskCore ();
            this.ContentName = taskViewWidget.TargetCore.Title;

            if (Role == CurrentRole.EditTask) {
                // the task is already hooked up to the provider
                // just force an update of the TFStore for now
                targetTask.Label = taskViewWidget.TargetCore.Title;
                targetTask.TriggerUpdate ();
                TaskForceMain.Instance.StartTFStoreUpdate ();
            } else if (Role == CurrentRole.NewTask) {
                // create a new task
                TaskData data = new TaskData ();

                data.CoreDataObject = taskViewWidget.TargetCore;
                data.Label = taskViewWidget.TargetCore.Title;

                providerNode.AddChild (data);
                TaskForceMain.Instance.StartTFStoreUpdate ();

                Role = CurrentRole.EditTask;

                // the new task now becomes the target
                targetTask = data;
            }

            // Unset the IsDirry
            IsDirty = false;
        }
示例#7
0
        public void NewTaskRole(ProviderData _providerNode)
        {
            providerNode = _providerNode;
            Role = CurrentRole.NewTask;

            this.IsDirty = true;
        }
示例#8
0
        public void EditTaskRole(ProviderData _providerNode, TaskData _target)
        {
            providerNode = _providerNode;
            targetTask = _target;

            taskViewWidget.PopulateFromTaskData (_target);
            Role = CurrentRole.EditTask;

            this.ContentName = _target.Label;
            this.IsDirty = false;
        }
示例#9
0
 public bool IsAdmin()
 {
     return(CurrentRole.In(RoleType.Administrator, RoleType.SuperAdmin));
 }