Exemplo n.º 1
0
        public List <String> ValidRollCall(RollCall InRollCall, TimeSpan?otherTime)
        {
            SubjectBusiness  SubBO     = new SubjectBusiness(this.RollSystemDB);
            ClassBusiness    ClassBO   = new ClassBusiness(this.RollSystemDB);
            RollCallBusiness RcBO      = new RollCallBusiness(this.RollSystemDB);
            List <string>    ErrorList = new List <string>();

            //var rollSubject = SubBO.GetSubjectByID(InRollCall.SubjectID);
            ////Check may cai nhu gio hoc, giao vien dang day v...v trong nay
            //if ((InRollCall.StartTime.ToString(@"hh\:mm") == "10:30"
            //    || InRollCall.StartTime.ToString(@"hh\:mm") == "16:00") &&
            //rollSubject.NumberOfSlot == 2)
            //{
            //    ErrorList.Add("Mon nay 2 slot, gio nay ko phu hop");
            //}

            ////Check thu xem class cua roll call nay co dang hoc roll call nao ko
            //List<RollCall> ClassRcList = RcBO.GetList().Where(r => r.ClassID == InRollCall.ClassID).ToList();
            //Boolean Classflag = true;
            //foreach (var item in ClassRcList)
            //{
            //    if (otherTime.ToString() != "")
            //    {
            //        InRollCall.StartTime = TimeSpan.Parse(otherTime.ToString());
            //    }
            //    if (item.StartTime == InRollCall.StartTime && item.BeginDate <= InRollCall.BeginDate && InRollCall.BeginDate <= item.EndDate)
            //    {
            //        Classflag = false;
            //    }
            //}
            //if (Classflag == false)
            //{
            //    ErrorList.Add("class");
            //}
            //Check xem giao vien roll call nay co dang day roll call nao cung gio ko
            Boolean         Insflag   = true;
            List <RollCall> InsRcList = RcBO.GetList().Where(r => r.InstructorID == InRollCall.InstructorID).ToList();

            foreach (var item in InsRcList)
            {
                if (item.StartTime == otherTime && item.BeginDate < InRollCall.BeginDate && InRollCall.BeginDate < item.EndDate)
                {
                    Insflag = false;
                }
            }
            if (Insflag == false)
            {
                ErrorList.Add("instructor");
            }

            //Nho check luon, start date va end date cua roll call so voi semester

            return(ErrorList);
        }
Exemplo n.º 2
0
        public bool Insert(RollCall InRollCall)
        {
            SubjectBusiness SubBO   = new SubjectBusiness(this.RollSystemDB);
            ClassBusiness   ClassBO = new ClassBusiness(this.RollSystemDB);

            RollCall rollcall = InRollCall;
            //Set thoi gian EndTime, dua vao start time
            var rollSubject = SubBO.GetSubjectByID(InRollCall.SubjectID);

            rollcall.EndTime = rollcall.StartTime.
                               Add(TimeSpan.FromMinutes(90 * rollSubject.NumberOfSlot)).
                               Add(TimeSpan.FromMinutes(15 * (rollSubject.NumberOfSlot - 1)));

            //VD: 20 slot se la 28 ngay. 15 slot la 21 ngay, 18 slot van 28 ngay
            int TotalDate = (int)Math.Ceiling((double)rollSubject.NumberOfSession / 5) * 7;

            //Tru 1 ngay de ket thuc vao chu nhat
            rollcall.EndDate = rollcall.BeginDate.AddDays(TotalDate).AddDays(-1);

            //Dua toan bo hoc sinh hien tai cua class vao
            var rollClass = ClassBO.GetClassByID(InRollCall.ClassID);

            foreach (var Student in rollClass.Students)
            {
                rollcall.Students.Add(Student);
            }

            //Tao cac studying session cua roll call nay
            DateTime SessionDate = rollcall.BeginDate;

            for (int i = 0; i < rollSubject.NumberOfSession; i++)
            {
                StudySession StuSes = new StudySession()
                {
                    InstructorID = InRollCall.InstructorID,
                    ClassID      = rollcall.ClassID,
                    StartTime    = rollcall.StartTime,
                    EndTime      = rollcall.EndTime,
                    SessionDate  = SessionDate,
                    Note         = SessionDate.ToString("dd-MM-yyyy") + " : "
                };
                rollcall.StudySessions.Add(StuSes);
                do
                {
                    SessionDate = SessionDate.AddDays(1);
                } while (SessionDate.DayOfWeek == DayOfWeek.Saturday || SessionDate.DayOfWeek == DayOfWeek.Sunday);
            }

            //Set trang thai của roll call la incoming
            rollcall.Status = 1;

            return(base.Insert(rollcall));
        }