Skip to content

An application used to manage a list of candidates for studies.

Notifications You must be signed in to change notification settings

BloodShop/Students-Manager-MVVM-UWP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StudentsContainer

Simple application used to manage a list of candidates for studies, The manager class is able to Add, Remove, Get, Update students. This class Inhertice from IEnumrable and IRepository<T>.

MVVM Project devided to three parts

  1. Model (Student / Person, Configuration, StudentsManager...)

Sudents manager class which organizes all the students and is able to Update, Get, Add, Remove any student and a sorting function which sort the whole Students to the UI.

public List<Student> Sort(IComparer<Student> comparison)
{
List<Student> temp = GetAll().ToList();
temp.Sort(comparison);
return temp;
}
public void Add(Student student)
{
if (student != null && !_data.Students.ContainsValue(student))
_data.Students.Add(uniqueSeed++, student);
}
public void Remove(Student student)
{
if (student != null && _data.Students.ContainsValue(student))
{
var keyValuePair = _data.Students.First(kvp => kvp.Value == student);
_data.Students.Remove(keyValuePair.Key);
}
}
public Student Update(Student old, Student @new)
{
if (@new != null && old != null)
{
_data.Students.Remove(old.Id);
_data.Students.Add(@new.Id, @new);
}
return @new;
}
public IQueryable<Student> GetAll() => _data.Students.Values.AsQueryable();
public IEnumerator GetEnumerator()
{
// instead of writing CustomerEnum
foreach (var std in _data.Students)
yield return std;
}

  1. View (XAML)

Running application - Manger page contains Search, Add, Sort and etc..

  1. View-Model (MainView model)
public class MainViewModelBase : INotifyPropertyChanged, INotifyCollectionChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        public event NotifyCollectionChangedEventHandler CollectionChanged;
        event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
        {
            add { this.PropertyChanged += value; }
            remove { this.PropertyChanged -= value; }
        }
        protected virtual void RaisePropertyChanged([CallerMemberName] string propertyName = "")
            => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        public virtual void RaiseCollectionChanged(NotifyCollectionChangedEventArgs e) => this.CollectionChanged?.Invoke(this, e);
        public virtual void RaisePropertyChanged(PropertyChangedEventArgs e) => this.PropertyChanged?.Invoke(this, e);
    }

Sorting Comparers

A sorting comparer allows the manager to select any kind of sort and display the results. Sorting comparers are delegates which the manager selects and passes it to the StudentsContainer class.

public class CompareGradesHigh : IComparer<Student>
{
public int Compare(Student x, Student y) => y.FinalGrade.CompareTo(x.FinalGrade);
public override string ToString() => "Grades [ 100 - 1 ]";
}

About

An application used to manage a list of candidates for studies.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages