Example #1
0
        public async Task <DashboardVM> GetDashboardInfo(LoginUserInfo LoginUser)
        {
            var TempVModel = new DashboardVM();

            TempVModel.DashboardData = await _DBClassroomRepository.GetDashboardData();

            if (!LoginUser.UserType.Equals("A"))
            {
                DateTime StartRangeDt = DateTime.Now;
                DateTime EndRangeDt   = DateTime.Now.AddDays(30);
                List <ClassRoomDashboardInfo> MyRecentClasses = new List <ClassRoomDashboardInfo>();
                var MyClassInfoList = await GetAllMyClassInfo(LoginUser);

                foreach (var item in MyClassInfoList)
                {
                    var NextClassDt = item.NextClassDate;
                    if (NextClassDt > StartRangeDt && NextClassDt < EndRangeDt)
                    {
                        //add recent 30 days classes
                        MyRecentClasses.Add(new ClassRoomDashboardInfo
                        {
                            ClassId            = item.ID,
                            ClassRefId         = item.RefID,
                            ClassName          = item.ClassName,
                            ClassTeacherName   = string.IsNullOrEmpty(item.ClassTeacherName) ? "No Teacher Assign" : item.ClassTeacherName,
                            TotalClassTeachers = item.TotalClassTeacher,
                            Frequency          = item.Frequency,
                            TotalClassStudents = item.TotalClassStudents,
                            ClassTime          = item.ClassTime,
                            NextClass          = item.NextClass,
                            RecurringType      = item.RecurringType,
                            ClassActiveBefore  = string.Format("Before {0} min", item.ActivationTime)
                        });
                    }
                }
                TempVModel.DashboardDataObj = MyRecentClasses;
            }

            return(TempVModel);
        }