Example #1
0
        /// <summary>
        /// Update the risk factor in the student's retention history
        /// </summary>
        /// <param name="s"> The Student </param>
        /// <param name="factorChange"> How much is the factor changing </param>
        /// <param name="reason"> Why is the factor changing </param>
        public void UpdateStudentHistory(Student s, double factorChange, string reason)
        {
            factorChange = Math.Abs(factorChange);
            var sh = _studenthistory.All().SingleOrDefault(x => x.StudentID == s.ID && x.Date == DateTime.Today);

            if (sh == null)
            {
                StudentHistory sh2 = new StudentHistory
                {
                    StudentID   = s.ID,
                    Date        = DateTime.Today,
                    RiskFactor  = s.RiskFactor,
                    DeltaReason = reason,
                    MaxFactor   = factorChange
                };

                _studenthistory.Add(sh2);
                _uow.Save();
            }
            else
            {
                sh.RiskFactor = s.RiskFactor;
                if (factorChange >= sh.MaxFactor)
                {
                    sh.MaxFactor   = factorChange;
                    sh.DeltaReason = reason;
                }
                _uow.Save();
            }
        }
Example #2
0
        public async Task DeleteStudentAsync(string id)
        {
            var hist = new StudentHistory(HistoryEvent.Delete, id);

            await _studentRepository.SentStudentInactiveAsync(id);

            await _studentHistoryRepository.AddHistory(hist);
        }
Example #3
0
        public async Task UpdateStudentAsync(Student s)
        {
            var hist = new StudentHistory(HistoryEvent.Update, s.StudentId);

            await _studentRepository.UpdateStudentAsync(s);

            await _studentHistoryRepository.AddHistory(hist);
        }
Example #4
0
        public async Task CreateStudentAsync(Student student)
        {
            var hist = new StudentHistory(HistoryEvent.Add, student.StudentId);

            await _studentRepository.CreateStudentAsync(student);

            await _studentHistoryRepository.AddHistory(hist);
        }
 /// <summary>
 /// Cast StudentHistory to StudentHistoryDTO
 /// </summary>
 /// <param name="sh"></param>
 /// <returns></returns>
 public StudenthistoryDTO Studenthistory2StudenthistoryDTO(StudentHistory sh)
 {
     return(new StudenthistoryDTO
     {
         StudentID = sh.StudentID,
         Date = sh.Date,
         RiskFactor = sh.RiskFactor,
         DeltaReason = sh.DeltaReason,
         MaxFactor = sh.MaxFactor
     });
 }
        public static int AddStudentHistory(StudentHistory studentHistory)
        {
            //create DBContext object
            using (var smsDB = new SMSEntities())
            {
                //Add Student object into Students DBset
                smsDB.StudentHistories.Add(studentHistory);

                // call SaveChanges method to save student into database
                return(smsDB.SaveChanges());
            }
        }
Example #7
0
        public async Task LogStudentOut(string id, DateTime?differentDate = null)
        {
            var hist = new StudentHistory(HistoryEvent.Logout, id);

            if (differentDate != null)
            {
                hist.TimeOfEvent = differentDate.Value;
            }

            await _studentRepository.LogStudentOut(id);

            await _studentHistoryRepository.AddHistory(hist);
        }
Example #8
0
 public async Task AddHistory(StudentHistory history)
 {
     await _studentHistoryContext.StudentHistory
     .InsertOneAsync(history);
 }
Example #9
0
 /// <summary>
 /// 获取某一个聚合id下的所有事件,也就是得到了历史记录
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public IList <StudentHistoryData> GetAllHistory(Guid id)
 {
     return(StudentHistory.ToJavaScriptCustomerHistory(_eventStoreRepository.All(id)));
 }