Ejemplo n.º 1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            GroupListView groupListView = new GroupListView();

            groupListView.Show();
            this.Close();
        }
Ejemplo n.º 2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            if (mv.IsBusy == false)
            {
                GroupListView.BeginRefresh();
                await mv.PopulateGroups();

                GroupListView.ItemsSource = mv.Groups;
                GroupListView.EndRefresh();
            }
        }
Ejemplo n.º 3
0
        public static List <GroupListView> GetGroupListViewsCreatedByUser(ApplicationDbContext db, Guid appUserId)
        {
            List <GroupListView> list = new List <GroupListView>();

            List <Group> allGroupsCreatedByUser = GroupHelpers.GetGroupsCreatedByUser(db, appUserId);

            foreach (Group group in allGroupsCreatedByUser)
            {
                //Get members of the group
                List <GroupMember>         groupMembers     = GroupMemberHelpers.GetMembersForGroup(db, group.GroupId);
                List <GroupMemberListView> groupMembersView = new List <GroupMemberListView>();

                foreach (GroupMember member in groupMembers)
                {
                    string memberName = null;

                    switch (member.Type)
                    {
                    case LevelEnum.User:
                        memberName = AppUserHelpers.GetAppUserName(db, member.ReferenceId);
                        break;

                    case LevelEnum.Branch:
                        memberName = BranchHelpers.GetBranchNameTownPostCode(db, member.ReferenceId);
                        break;

                    case LevelEnum.Company:
                        memberName = CompanyHelpers.GetCompanyNameTownPostCode(db, member.ReferenceId);
                        break;
                    }

                    GroupMemberListView groupMemberListView = new GroupMemberListView()
                    {
                        GroupMember     = member,
                        GroupMemberName = memberName
                    };

                    groupMembersView.Add(groupMemberListView);
                }

                //create view record to add to list of view records
                GroupListView view = new GroupListView();
                view.Group = group;
                view.GroupOriginatorName = AppUserHelpers.GetAppUserName(db, view.Group.GroupOriginatorAppUserId);
                view.Members             = groupMembersView;

                list.Add(view);
            }

            return(list);
        }
Ejemplo n.º 4
0
        private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
        {
            GroupListView.BeginRefresh();

            if (string.IsNullOrWhiteSpace(e.NewTextValue))
            {
                GroupListView.ItemsSource = mv.Groups;
            }
            else
            {
                GroupListView.ItemsSource = mv.Groups.Where(i => i.Name.Contains(e.NewTextValue));
            }

            GroupListView.EndRefresh();
        }
Ejemplo n.º 5
0
        public static List <GroupListView> GetGroupListViewsRelevantToUser(ApplicationDbContext db, Guid appUserId)
        {
            List <GroupListView> list = new List <GroupListView>();

            List <Group> allGroupsRelevantUser = new List <Group>();

            //Get user groups containing this user
            allGroupsRelevantUser = GroupHelpers.GetGroupsForUser(db, appUserId);
            //Get branch groups containing this users branches
            List <Branch> usersBranches = BranchHelpers.GetBranchesForUser(db, appUserId);

            foreach (Branch branch in usersBranches)
            {
                List <Group> groups = GroupHelpers.GetGroupsForTypeAndReferenceId(db, LevelEnum.Branch, branch.BranchId);
                foreach (Group group in groups)
                {
                    allGroupsRelevantUser.Add(group);
                }
            }
            //Get company groups containing this users company
            List <Group> companyGroups = GroupHelpers.GetGroupsForTypeAndReferenceId(db, LevelEnum.Company, CompanyHelpers.GetCompanyForUser(db, appUserId).CompanyId);

            foreach (Group group in companyGroups)
            {
                allGroupsRelevantUser.Add(group);
            }


            foreach (Group group in allGroupsRelevantUser)
            {
                //Get members of the group
                List <GroupMember>         groupMembers     = GroupMemberHelpers.GetMembersForGroup(db, group.GroupId);
                List <GroupMemberListView> groupMembersView = new List <GroupMemberListView>();

                foreach (GroupMember member in groupMembers)
                {
                    string memberName = null;

                    switch (member.Type)
                    {
                    case LevelEnum.User:
                        memberName = AppUserHelpers.GetAppUserName(db, member.ReferenceId);
                        break;

                    case LevelEnum.Branch:
                        memberName = BranchHelpers.GetBranchNameTownPostCode(db, member.ReferenceId);
                        break;

                    case LevelEnum.Company:
                        memberName = CompanyHelpers.GetCompanyNameTownPostCode(db, member.ReferenceId);
                        break;
                    }

                    GroupMemberListView groupMemberListView = new GroupMemberListView()
                    {
                        GroupMember     = member,
                        GroupMemberName = memberName
                    };

                    groupMembersView.Add(groupMemberListView);
                }

                //create view record to add to list of view records
                GroupListView view = new GroupListView();
                view.Group = group;
                view.GroupOriginatorName = AppUserHelpers.GetAppUserName(db, view.Group.GroupOriginatorAppUserId);
                view.Members             = groupMembersView;

                list.Add(view);
            }

            return(list);
        }