public ActionResult getCurrentSemesterStudentPoint(String studentId) { try { DateTime now = DateTime.Now; int currentMonth = now.Month; string currentSemester; switch (currentMonth) { case 1: case 2: case 3: case 4: currentSemester = "spring"; break; case 5: case 6: case 7: case 8: currentSemester = "summer"; break; default: currentSemester = "fall"; break; } List <Accumulation> accumulations = AccumulationService .GetMany(_ => _.studentId.Equals(studentId) && _.semester.Equals(currentSemester)).ToList(); int point = 0; accumulations.ForEach(_ => { point += (int)_.point; }); AccumulationGetModel result = new AccumulationGetModel { studentId = studentId, point = point, accumulations = accumulations, }; return(Ok(result)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult getAllSemesterStudentPoint(String studentId) { try { List <Accumulation> accumulations = AccumulationService .GetMany(_ => _.studentId.Equals(studentId)).ToList(); int point = 0; accumulations.ForEach(_ => { point += (int)_.point; }); AccumulationGetModel result = new AccumulationGetModel { studentId = studentId, point = point, accumulations = accumulations, }; return(Ok(result)); } catch (Exception e) { return(BadRequest(e.Message)); } }