Пример #1
0
        public RoleModelList SelectRolesAll()
        {
            var cs = "Server=localhost\\SQLEXPRESS;Database=HospitalDB;Trusted_Connection=True;";

            using var con = new SqlConnection(cs); //Using Class SqlConnection for COnnent to database
            con.Open();

            string sql = "SELECT Id, Role FROM RoleTbl";

            using var cmd = new SqlCommand(sql, con); //Using Class SqlCommand for query data

            using SqlDataReader rdr = cmd.ExecuteReader();

            RoleModelList output = new RoleModelList();

            output.RoleList = new List <RoleModel>();

            while (rdr.Read())

            {
                output.RoleList.Add(
                    new RoleModel()
                {
                    id   = rdr.GetInt32(0),
                    role = rdr.GetString(1),
                }
                    );
            }
            return(output);
        }
Пример #2
0
        private void addRoleBy(int id)
        {
            object _lock = new object();

            if (RoleModelList != null)
            {
                Role roleFound = RoleModelList.Where(x => x.Role.ID == id).Select(x => x.Role).FirstOrDefault();
                lock (_lock)
                    if (roleFound != null)
                    {
                        if (RoleList == null)
                        {
                            RoleList = new List <Role>();
                        }

                        if (RoleList.Where(x => x.ID == roleFound.ID).Count() == 0)
                        {
                            RoleList.Add(roleFound);
                            RoleToAddList.Add(new RoleModel {
                                Role = roleFound
                            });
                        }
                        else
                        {
                            RoleList = RoleList.Where(x => x.ID != roleFound.ID).ToList();
                            RoleToRemoveList.Add(new RoleModel {
                                Role = roleFound
                            });
                        }
                    }
            }
        }
Пример #3
0
        public async Task <List <AgentModel> > getAgentModelAsync()
        {
            List <Agent> agentList = await Bl.BlAgent.GetAgentDataAsync(999);

            List <AgentModel> output = new List <AgentModel>();

            output = (from ag in agentList
                      select new AgentModel {
                Agent = ag,
                RoleModelList = RoleModelList.OrderBy(x => x.TxtID).Distinct().ToList(),
                RolePositionDisplay = _rolePosition
            }).ToList();

            return(output);
        }
Пример #4
0
        private async void updateSecurityCredential(object obj)
        {
            Singleton.getDialogueBox().showSearch(ConfigurationManager.AppSettings["update_message"]);

            // update role right on actions
            List <RoleModel> roleModifiedList            = RoleModelList.Where(x => x.IsModified).ToList();
            bool             isRightsUpdatedSuccessfully = await updateRoleRights(roleModifiedList);

            // updating authenticated user
            if (isRightsUpdatedSuccessfully)
            {
                isRightsUpdatedSuccessfully = updateAuthenticatedUserCredentialsOnActions(roleModifiedList);
            }

            // update agent role
            var agent_roleProcessedList = new List <Agent_role>();
            var agentModifiedList       = AgentModelList.Where(x => x.IsModified).ToList();

            foreach (var agentModel in agentModifiedList)
            {
                if (await updateAgentRoles(agentModel.Agent, agentModel.RoleToAddList, agentModel.RoleToRemoveList))
                {
                    agent_roleProcessedList = agent_roleProcessedList.Concat(agentModel.RoleToAddList.Select(x => new Agent_role {
                        AgentId = agentModel.Agent.ID, RoleId = x.Role.ID
                    }).ToList()).ToList();
                }

                agentModel.IsModified = false;
                agentModel.RoleToAddList.Clear();
                agentModel.RoleToRemoveList.Clear();
            }

            if (agent_roleProcessedList.Count > 0 || isRightsUpdatedSuccessfully)
            {
                updateAuthenticatedUserRoles(agentModifiedList.Where(x => x.Agent.ID == Bl.BlSecurity.GetAuthenticatedUser().ID).SelectMany(x => x.RoleList.Select(y => new RoleModel {
                    Role = y
                })).ToList());
                await Singleton.getDialogueBox().showAsync("Security updated successfuly!");

                _referential.MainWindowViewModel.CommandNavig.raiseCanExecuteActionChanged();
                //_page(this);
            }

            Singleton.getDialogueBox().IsDialogOpen = false;
        }
Пример #5
0
        public RoleModelList GetRoleList()
        {
            RoleModelList result = _rolesService.SelectRoles();

            return(result);
        }
Пример #6
0
        //Create Method
        public RoleModelList SelectRoles()
        {
            RoleModelList result = _rolesRepository.SelectRolesAll();

            return(result);
        }