// Конструктор представления модели
        public StudentListViewModel(StudentHostelContext context) : base(context)
        {
            GetData();
            GetStudentsList();

            if (StudentList != null)
            {
                CurrentStudent = null;
            }
            else if (StudentList.Count == 0)
            {
                CurrentStudent = null;
            }
            else
            {
                CurrentStudent = StudentList.First();
            }

            // Инициализация команд
            AddCommand          = new Command(Add, () => { return(!(IsAdding || IsEditing) && context != null); });
            EditCommand         = new Command(Edit, () => { return(!(IsAdding || IsEditing) && context != null); });
            SaveCommand         = new Command(SaveChanges, () => { return((IsAdding || IsEditing) && context != null); });
            DeleteCommand       = new Command(Delete, () => { return(!(IsAdding && !IsEditing) && context != null); });
            CancelCommand       = new Command(DiscardChanges, () => { return((IsAdding || IsEditing) && context != null); });
            UpdateCommand       = new Command(Update, () => { return(!(IsAdding || IsEditing) && context != null); });
            FilterCommand       = new Command(Filter, () => { return(IsBrowsing); });
            CancelFilterCommand = new Command(CancelFilter, () => { return(IsBrowsing); });
        }
Exemplo n.º 2
0
 private void StudentLogin(WSDESubVoterSelectRequest response)
 {
     if (response.SubVoterResult.Equals("login") && StudentList.Any(k => k.StudentNumber == response.SubVoterNumber))
     {
         StudentList.First(k => k.StudentNumber == response.SubVoterNumber).IsLogin = true;
     }
 }
Exemplo n.º 3
0
        private void init()
        {
            MessageSubscribeRelations.AddSubscribe(MessageType.WSDEDataEvent, new Relation()
            {
                CanUninstall     = true,
                IsActive         = true,
                IsKeep           = false,
                RelationDescribe = Title,
                RelationGuid     = this.StrGuid,
                RelationAction   = messageData =>
                {
                    base.BindingPropInOtherTask(() =>
                    {
                        JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                        var response = javaScriptSerializer.Deserialize <WSDESubVoterSelectRequest>(messageData.MessageData);
                        if (!Start)
                        {
                            StudentLogin(response);
                            return;
                        }
                        StudentLogin(response);
                        if (String.IsNullOrWhiteSpace(response.SubVoterResult) || response.SubVoterResult.Equals("login"))
                        {
                            return;
                        }
                        if (!StudentList.Any(k => k.StudentNumber == response.SubVoterNumber) && RefuseOutOfStudentList)
                        {
                            return;
                        }
                        response.SubVoterResult = response.SubVoterResult.Replace(".", "");
                        response.SubVoterResult = StringUtils.RemoveDuplicateCharacters(response.SubVoterResult);
                        var number = System.Convert.ToInt32(response.SubVoterSelectNumber);
                        examination.Add(response.SubVoterNumber, number, response.SubVoterResult);
                        if (QuestionList.Any(k => k.QuestionNumber == response.SubVoterSelectNumber))
                        {
                            QuestionList.First(k => k.QuestionNumber == response.SubVoterSelectNumber).Set(examination.ExaminationQuestions.First(k => k.QuestionNumber == number));
                        }
                        if (!StudentList.Any(k => k.StudentNumber == response.SubVoterNumber) && examination.Voters != null && examination.Voters.Count() > 0)
                        {
                            StudentVM studentNM = new StudentVM();
                            studentNM.Set(examination.Voters.First(k => k.VoterId == response.SubVoterNumber));
                            StudentList.Add(studentNM);
                        }
                        if (examination.Voters != null && examination.Voters.Count() > 0)
                        {
                            StudentList.First(k => k.StudentNumber == response.SubVoterNumber).Set(examination.Voters.First(k => k.VoterId == response.SubVoterNumber));
                        }

                        base.ViewChange();
                    });
                },
            });
        }
Exemplo n.º 4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _context.Teacher.Load();                            // wczytanie nauczycieli, aby wyswietlac całe nazwy przedmiotow

            SubjectList            = _context.Subject.ToList(); // wczytanie przedmiotow
            subjectBox.ItemsSource = SubjectList;               // przypisanie przedmiotow do listboxa
            StudentList            = _context.Student.ToList(); // wczytanie uczniow
            studentBox.ItemsSource = StudentList;               // przypisanie uczniow do listboxa

            if (Group != null)                                  // jezeli dane sa do edycji
            {
                // wczytanie danych z GroupStudent tylko dla danej grupy
                GroupStudentList = _context.GroupStudent.Where(gs => gs.GroupId == Group.Id).ToList();

                // wczytanie danych z GroupSubject tylko dla danej grupy
                GroupSubjectList = _context.GroupSubject.Where(gs => gs.GroupId == Group.Id).ToList();

                // przypisanie nazwy grupy
                name.Text    = Group.Name;
                OldGroupName = Group.Name;

                // przypisanie listy uczniów
                foreach (GroupStudent gs in GroupStudentList)
                {
                    Student student = StudentList.First(s => s.Id == gs.StudentId);
                    studentList.Items.Add(student);
                }

                // przypisanie listy przedmiotów
                foreach (GroupSubject gs in GroupSubjectList)
                {
                    Subject subject = SubjectList.First(s => s.Id == gs.SubjectId);
                    subjectList.Items.Add(subject);
                }
            }
        }
        public Student FindByStudentByName(string studentName)
        {
            Student foundStudent = StudentList.First(singleStudent => singleStudent.FirstName == studentName);

            return(foundStudent);
        }