/// <summary> /// Function to add a new grade to the repository /// </summary> /// <param name="stId">id of the student</param> /// <param name="hwId">id of the homework</param> /// <param name="gradeValue">grade value</param> /// <param name="professor">professor name</param> /// <param name="feedback">feedback</param> /// <exception cref="StudentOrHomeworNotFoundException">if the given homework or student does not exist</exception> /// <returns>null if the grade was added, the given grade otherwise</returns> public Grade AddGrade(int stId, string hwId, double gradeValue, string professor, string feedback) { var st = _stRepo.FindOne(stId); var hw = _hwRepo.FindOne(hwId); if (st == null || hw == null) { throw new StudentOrHomeworNotFoundException("The given student or homework does not exist!"); } var diff = hw.DeadlineWeek - Utility.GetCurrentWeek(); if (diff == -1 || diff == -2) { gradeValue += (2.5d) * diff; } else if (diff < -2) { gradeValue = 1.0d; } return(_grRepo.Save(new Grade(stId, hwId, gradeValue, professor, feedback))); }
public static Category FindByName(AbstractRepository repo, string name) { return(repo.FindOne <Category>(c => c.Name == name)); }
public static Category FindById(AbstractRepository repo, int id) { return(repo.FindOne <Category>(c => c.Id == id)); }
public static Account FindByName(AbstractRepository repo, string name) { return(repo.FindOne <Account>(a => a.NormalizedUserName.Contains(name))); }
public static Account FindById(AbstractRepository repo, Guid id) { return(repo.FindOne <Account>(a => a.Id.Equals(id))); }
/// <summary> /// Function to get a homework by id /// </summary> /// <param name="id">id of the homework to search for</param> /// <returns>the homework with the given id if it exists, null otherwise</returns> public Homework FindHomework(string id) { return(_hwRepo.FindOne(id)); }
public static Format FindByName(AbstractRepository repo, string name) { return(repo.FindOne <Format>(c => c.Name == name)); }
public static Format FindById(AbstractRepository repo, int id) { return(repo.FindOne <Format>(c => c.Id == id)); }
/// <summary> /// Function to find a grade in the repository /// </summary> /// <param name="stId">student id</param> /// <param name="hwId">homework id</param> /// <returns>the grade with the given id if it exists, null otherwise</returns> public Grade FindGrade(int stId, string hwId) { var pair = new KeyValuePair <int, string>(stId, hwId); return(_grRepo.FindOne(pair)); }
/// <summary> /// Function to find a student /// </summary> /// <param name="id">id of the student to search</param> /// <returns>the student if it exists, null otherwise</returns> public Student FindStudent(int id) { return(_studRepo.FindOne(id)); }