public int Compare(GradeModel x, GradeModel y)
        {
            var grades = GradeTypeEnum.GetAll();

            int integerX = 0;
            int integerY = 0;
            var xSplit   = x.Name.Split(' ');
            var ySplit   = y.Name.Split(' ');
            var xNumber  = Regex.Match(xSplit[0], @"\d+").Value;
            var yNumber  = Regex.Match(ySplit[0], @"\d+").Value;

            if (int.TryParse(xNumber, out integerX) && int.TryParse(yNumber, out integerY))
            {
                var gradesNumberX = grades.FirstOrDefault(g => g.Value.Equals(integerX));
                var gradesNumberY = grades.FirstOrDefault(g => g.Value.Equals(integerY));

                return(gradesNumberX.Value.CompareTo(gradesNumberY.Value));
            }

            var gradesStringX = grades.FirstOrDefault(g => g.DisplayName.ToUpper().Equals(x.Name.ToUpper()));
            var gradesStringy = grades.FirstOrDefault(g => g.DisplayName.ToUpper().Equals(y.Name.ToUpper()));

            return(gradesStringX.Value.CompareTo(gradesStringy.Value));
        }
Пример #2
0
 /// <summary>
 /// Gets the last created class from the application.
 /// </summary>
 /// <param name="gradeTypeEnum">This is the grade type enum.</param>
 /// <returns>The grade</returns>
 public static Grade Get(GradeTypeEnum gradeTypeEnum)
 {
     return(InMemoryDatabaseSingleton.DatabaseInstance.SelectMany <Grade>(x => x.GradeType == gradeTypeEnum &&
                                                                          x.IsCreated).OrderByDescending(x => x.CreationDate).First());
 }
Пример #3
0
 /// <summary>
 /// This method returns all created grade of the given type.
 /// </summary>
 /// <param name="gradeType">This is the type of the grade.</param>
 /// <returns>Grade List.</returns>
 public static List <Grade> GetAll(GradeTypeEnum gradeType)
 {
     return(InMemoryDatabaseSingleton.DatabaseInstance.SelectMany <Grade>(
                x => x.GradeType == gradeType).OrderByDescending(
                x => x.CreationDate).ToList());
 }