コード例 #1
0
        public ActionResult UpdateTutor([Bind(Include = "ID,ClassOf,VNumber,AdminApproved")] Tutor tutor)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tutor).State = EntityState.Modified;
                db.SaveChanges();

                BTTUser them      = db.BTTUsers.Find(tutor.ID);
                string  firstName = them.FirstName;
                string  lastName  = them.LastName;

                if (tutor.AdminApproved)
                {
                    TempData["t"] = "You have successfully approved " + firstName + " " + lastName + " as a tutor.";
                }
                else if (!tutor.AdminApproved)
                {
                    TempData["f"] = "You have successfully denied " + firstName + " " + lastName + " as a tutor.";
                }


                return(RedirectToAction("Index"));
            }
            ViewBag.ID = new SelectList(db.BTTUsers, "ID", "FirstName", tutor.ID);
            return(View(tutor));
        }
コード例 #2
0
        // GET: Student/Home
        public ActionResult Index()
        {
            ViewBag.Current = "StuHomeIndex";

            var userID        = User.Identity.GetUserId();
            var currentUserID = db.BTTUsers.Where(m => m.ASPNetIdentityID.Equals(userID)).FirstOrDefault().ID;

            // --------------BEGIN section for custom portal display--------------
            // get student name to display in portal
            var    currentUser = db.BTTUsers.Where(m => m.ASPNetIdentityID.Equals(userID)).FirstOrDefault();
            string firstName   = currentUser.FirstName;
            string lastName    = currentUser.LastName;

            ViewBag.User     = currentUser.FirstName;
            ViewBag.Class    = currentUser.Student.ClassStanding;
            ViewBag.GradYear = currentUser.Student.GraduatingYear;
            ViewBag.fullName = firstName + " " + lastName;

            // --------------END section for custom portal display--------------

            var allTutoringAppts = db.TutoringAppts.Where(a => a.StudentID == currentUserID);

            foreach (var appt in allTutoringAppts)
            {
                if (DateTime.Now > appt.EndTime.AddMinutes(30) && (appt.Status == "Approved"))
                {
                    var          currentItem  = appt.ID;
                    TutoringAppt tutoringAppt = db.TutoringAppts.Find(currentItem);

                    tutoringAppt.Status = "Completed";

                    db.Entry(tutoringAppt).State = EntityState.Modified;
                }
                else if (DateTime.Now > appt.EndTime && (appt.Status == "Requested"))
                {
                    var          currentItem  = appt.ID;
                    TutoringAppt tutoringAppt = db.TutoringAppts.Find(currentItem);

                    tutoringAppt.Status = "Declined";

                    db.Entry(tutoringAppt).State = EntityState.Modified;
                }
            }

            db.SaveChanges();

            return(View());
        }
コード例 #3
0
        public ActionResult Edit([Bind(Include = "ID,StartTime,EndTime,TypeOfMeeting,ClassID,Length,Status,Note,StudentID,TutorID")] TutoringAppt tutoringAppt, DateTime?Date)
        {
            if (Date == null)
            {
                Date = (DateTime.Now).AddDays(2);
            }

            var date      = Date?.ToString("yyyy-MM-dd");
            var startTime = tutoringAppt.StartTime.ToString("HH:mm:ss tt");
            var endTime   = tutoringAppt.EndTime.ToString("HH:mm:ss tt");

            tutoringAppt.StartTime = Convert.ToDateTime(date + " " + startTime);
            tutoringAppt.EndTime   = Convert.ToDateTime(date + " " + endTime);

            if (ModelState.IsValid)
            {
                db.Entry(tutoringAppt).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var stuID    = db.TutoringAppts.Where(a => a.ID == tutoringAppt.ClassID).Select(a => a.StudentID).FirstOrDefault();
            var stuFName = db.BTTUsers.Where(a => a.ID == stuID).Select(a => a.FirstName).FirstOrDefault();
            var stuLName = db.BTTUsers.Where(a => a.ID == stuID).Select(a => a.LastName).FirstOrDefault();
            var stuName  = stuFName + " " + stuLName;

            ViewBag.StudentName = stuName;
            return(View(tutoringAppt));
        }
コード例 #4
0
        public async Task <ActionResult> CreateShift(TutorTimeSheetCustomModel model)
        {
            if (model.ShiftVM != null)
            {
                db.WorkHours.Add(model.ShiftVM);
                Day d = db.Days.Find(model.ShiftVM.DayID);
                d.RegularHrs += (int)(model.ShiftVM.ClockedOut - model.ShiftVM.ClockedIn).TotalMinutes;
                if (d.RegularHrs < 0.01)
                {
                    TempData["try_again"] = "true";
                    return(RedirectToAction("ViewMonth", new { tsid = model.ShiftVM.Day.TimeSheetID }));
                }
                db.Entry(d).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("ViewMonth", new { tsid = model.ShiftVM.Day.TimeSheetID }));
            }

            return(RedirectToAction("Index"));
        }
コード例 #5
0
 public ActionResult Edit([Bind(Include = "ID,StartTime,EndTime,TypeOfMeeting,ClassID,Length,Status,Note,StudentID,TutorID")] TutoringAppt tutoringAppt)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tutoringAppt).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tutoringAppt));
 }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "ID,GraduatingYear,ClassStanding")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("StudentProfile"));
     }
     ViewBag.ID = new SelectList(db.BTTUsers, "ID", "FirstName", student.ID);
     return(View(student));
 }
コード例 #7
0
 public ActionResult Edit([Bind(Include = "ID,Description,StartTime,EndTime,ThemeColor,IsFullDay,TutorID")] TutorSchedule tutorSchedule)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tutorSchedule).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("UpdateSchedule"));
     }
     ViewBag.TutorID = new SelectList(db.Tutors, "ID", "FirstName", tutorSchedule.TutorID);
     return(View(tutorSchedule));
 }
コード例 #8
0
 public ActionResult Edit([Bind(Include = "ID,TimeStamp,Subject,Message,Expiration,AdminID")] StudentAlert studentAlert)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studentAlert).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AdminID = new SelectList(db.BTTUsers, "ID", "FirstName", studentAlert.AdminID);
     return(View(studentAlert));
 }
コード例 #9
0
 public ActionResult Edit([Bind(Include = "ID,Status,EndTime,TutorID")] TutoringServiceAlert tutoringServiceAlert)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tutoringServiceAlert).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TutorID = new SelectList(db.Tutors, "ID", "VNumber", tutoringServiceAlert.TutorID);
     return(View(tutoringServiceAlert));
 }
コード例 #10
0
 public ActionResult Edit([Bind(Include = "ID,Topic,URL,DisplayText,UserID")] StudentResource studentResource)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studentResource).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ManageResources"));
     }
     ViewBag.UserID = new SelectList(db.BTTUsers, "ID", "FirstName", studentResource.UserID);
     return(View(studentResource));
 }
コード例 #11
0
 public ActionResult Edit([Bind(Include = "ID,StartTime,EndTime,TypeOfMeeting,ClassID,Length,Status,Note,StudentID,TutorID")] TutoringAppt tutoringAppt)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tutoringAppt).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ClassID   = new SelectList(db.Classes, "ID", "Name", tutoringAppt.ClassID);
     ViewBag.StudentID = new SelectList(db.Students, "ID", "ClassStanding", tutoringAppt.StudentID);
     ViewBag.TutorID   = new SelectList(db.Tutors, "ID", "VNumber", tutoringAppt.TutorID);
     return(View(tutoringAppt));
 }
コード例 #12
0
        public ActionResult Edit([Bind(Include = "ID,Name")] Class @class)
        {
            if (ModelState.IsValid)
            {
                db.Entry(@class).State = EntityState.Modified;
                db.SaveChanges();
                TempData["msg"] = "You have successfully renamed a class to " + @class.Name.ToString();
                return(RedirectToAction("Index"));
            }

            TempData["err"] = "Your change has not been saved";

            return(View(@class));
        }
コード例 #13
0
        // GET: Tutor/Home
        public ActionResult Index()
        {
            ViewBag.Current = "TutorHomeIndex";

            // --------------BEGIN section for custom portal display--------------
            // get tutor name to display in portal
            var userID      = User.Identity.GetUserId();
            var currentUser = db.BTTUsers.Where(m => m.ASPNetIdentityID.Equals(userID)).FirstOrDefault();

            ViewBag.User = currentUser.FirstName;
            var currentUserID = db.BTTUsers.Where(m => m.ASPNetIdentityID.Equals(userID)).FirstOrDefault().ID;

            // get num resources belonging to tutor for stats display
            ViewBag.resources = currentUser.StudentResources.Count();

            // get information for tutoring sessions menu display
            ViewBag.completeSessions      = currentUser.Tutor.TutoringAppts.Where(m => m.Status == "Completed").Count();
            ViewBag.futureSessions        = currentUser.Tutor.TutoringAppts.Where(m => m.Status == "Approved").Count();
            ViewBag.allTutorSessions      = currentUser.Tutor.TutoringAppts.Count();
            ViewBag.requestedSessions     = db.TutoringAppts.Where(m => m.Status == "Requested").Count();
            ViewBag.allDepartmentSessions = db.TutoringAppts.Count();

            // get saved calculator results num for stats display
            var weightedGrades = currentUser.WeightedGrades.Count();
            var finalGrades    = currentUser.FinalGrades.Count();
            var cumulativeGPAs = currentUser.CumulativeGPAs.Count();

            ViewBag.totalGrades = weightedGrades + finalGrades + cumulativeGPAs;

            // schedule for current tutor
            DateTime getCurrentDateTime = DateTime.Now.Date;

            var currentTutorSchedules = currentUser.Tutor.TutorSchedules
                                        .Where(m => m.StartTime.Date > getCurrentDateTime).OrderBy(m => m.StartTime).Take(5);
            List <TutorSchedule> scheduleList = new List <TutorSchedule>();


            foreach (var appts in currentTutorSchedules)
            {
                scheduleList.Add(appts);
            }

            // --------------END section for custom portal display--------------

            // --------------BEGIN section for handling automated banners--------------
            var allTutoringAppts = db.TutoringAppts;

            foreach (var appt in allTutoringAppts)
            {
                if (DateTime.Now > appt.EndTime && (appt.Status == "Approved"))
                {
                    var          currentItem  = appt.ID;
                    TutoringAppt tutoringAppt = db.TutoringAppts.Find(currentItem);

                    tutoringAppt.Status = "Completed";

                    db.Entry(tutoringAppt).State = EntityState.Modified;
                }
                else if (DateTime.Now > appt.EndTime && (appt.Status == "Requested"))
                {
                    var          currentItem  = appt.ID;
                    TutoringAppt tutoringAppt = db.TutoringAppts.Find(currentItem);

                    tutoringAppt.Status = "Declined";

                    db.Entry(tutoringAppt).State = EntityState.Modified;
                }
            }

            db.SaveChanges();
            // --------------END section for handling automated banners--------------

            return(View(scheduleList));
        }