Exemple #1
0
        public void LoadSingleMember(Data.Member member)
        {
            MemberCard card = new MemberCard(member.Id);

            card.IsInteractive = Type != MemberSelectionCategory.None;
            card.SetGraphics(ViewType.SelectedIndex == 0 ? MemberCard.MemberGraphics.Chip : MemberCard.MemberGraphics.Card);
            MembersArea.Children.Add(card);
            card.MemberSelected += Card_MemberSelected;
            automatic            = true;
            Card_MemberSelected(card.Member);
        }
Exemple #2
0
        public void ListMembers(string text)
        {
            text = text ?? "";
            MembersArea.Children.Clear();
            IQueryable <Data.Member> queryable;
            List <int> list;

            if (Type == MemberSelectionCategory.PersonnelTransit)
            {
                queryable = db.Members.Where(m => (m.IsMentor == true || m.IsStaff == true) && !m.IsDeleted);
            }
            else
            {
                queryable = db.Members.Where(m => m.IsMentor == false && m.IsStaff == false && !m.IsDeleted);
            }

            if (!string.IsNullOrEmpty(text))
            {
                if (int.TryParse(text, out int code))
                {
                    queryable = queryable.Where(m => m.Id == code);
                }
                else
                {
                    queryable = queryable.Where(m => m.Firstname.Contains(text) || m.Lastname.Contains(text));
                }
            }

            if (showOnlyPresentMembers)
            {
                queryable = queryable.Where(m => m.Passages.Any() && m.Passages.OrderByDescending(p => p.Id).FirstOrDefault().IsEntrance == true);
            }

            if (!showIrregularMembers)
            {
                queryable = queryable.Where(m => m.IsRegular);
            }

            if (Type == MemberSelectionCategory.TutitionDebtorsList)
            {
                queryable = queryable.Where(m => m.Debtor > 0);
            }
            else if (Type == MemberSelectionCategory.ShoppingDebtorsList)
            {
                queryable = queryable.Where(m => m.Credit < 0);
            }
            else if (Type == MemberSelectionCategory.NearExpiryList)
            {
                queryable = queryable.Where(m => m.Enrolls.Where(e => e.ExpireDate != null &&
                                                                 e.StartDate <= DateTime.Today &&
                                                                 e.ExpireDate >= DateTime.Today &&
                                                                 e.ExpireDate < DateTime.Today.AddDays(4) &&
                                                                 e.IsActive).Count() > 0);
            }

            list = queryable.Select(q => q.Id).ToList();

            list.ForEach(m =>
            {
                MemberCard card    = new MemberCard(m);
                card.IsInteractive = Type != MemberSelectionCategory.None;
                card.SetGraphics(ViewType.SelectedIndex == 0 ? MemberCard.MemberGraphics.Chip : MemberCard.MemberGraphics.Card);
                MembersArea.Children.Add(card);
                card.MemberSelected += Card_MemberSelected;
            });
        }