示例#1
0
        public ActionResult Create([Bind(Include = "ID,TeacherName,Minutes,BadgeNumber,School,Grade,Activity,InstructionTime,SubstituteName,IsApproved,ApprovedBy,ApproveTime,InstructionTime")] EnteredPeMinute enteredPeMinute)
        {
            if (!ModelState.IsValid)
            {
                return(View(enteredPeMinute));
            }
            var enteredBadgeString = User.Identity.Name;
            var badgeNumber        = int.Parse(enteredBadgeString); // convert string to int

            // Associate Badge => Staff
            var selectedTeacher = _db.SchoolTeachersWithADLogins.FirstOrDefault(i => i.BADGE_NUM == enteredBadgeString);

            // Build variable with information not gathered from user.
            var teacherNameVariable = selectedTeacher.TeacherFirstName + " " + selectedTeacher.TeacherLastName;

            enteredPeMinute.TeacherName = teacherNameVariable;
            enteredPeMinute.School      = selectedTeacher.Organization_Name;
            enteredPeMinute.Grade       = selectedTeacher.COURSE_TITLE;
            enteredPeMinute.BadgeNumber = badgeNumber;
            enteredPeMinute.Timestamp   = DateTime.Now;

            // Apply the modifications and then save to the database
            _db.EnteredPeMinutes.Add(enteredPeMinute);
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "ID,TeacherName,Minutes,BadgeNumber,School,Grade,Activity,Timestamp,SubstituteName,IsApproved,ApprovedBy,ApproveTime,InstructionTime")] EnteredPeMinute enteredPeMinute)
 {
     if (!ModelState.IsValid)
     {
         return(View(enteredPeMinute));
     }
     enteredPeMinute.IsApproved       = 1;                       // If the minute is entered by the teacher it does not need approval, so set 1.
     enteredPeMinute.ApprovedBy       = enteredPeMinute.TeacherName;
     enteredPeMinute.ApproveTime      = DateTime.Now;
     _db.Entry(enteredPeMinute).State = EntityState.Modified;
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
示例#3
0
        public ActionResult MoveSubToTeacher(string selectedSubstituteName, int selectedMinutes, string selectedActivity, DateTime selectedInstructionTime, EnteredPeMinute enteredPeMinute)
        {
            var enteredBadgeString  = User.Identity.Name;
            var selectedTeacher     = _db.SchoolTeachersWithADLogins.FirstOrDefault(i => i.BADGE_NUM == enteredBadgeString);
            var teacherNameVariable = selectedTeacher.TeacherFirstName + " " + selectedTeacher.TeacherLastName;

            enteredPeMinute.TeacherName     = selectedTeacher.TeacherFirstName + " " + selectedTeacher.TeacherLastName;
            enteredPeMinute.Minutes         = selectedMinutes;
            enteredPeMinute.Activity        = selectedActivity;
            enteredPeMinute.Timestamp       = DateTime.Now;
            enteredPeMinute.InstructionTime = selectedInstructionTime;
            enteredPeMinute.SubstituteName  = selectedSubstituteName;
            var badgeNumber = int.Parse(selectedTeacher.BADGE_NUM);  // convert string to int

            enteredPeMinute.BadgeNumber = badgeNumber;
            enteredPeMinute.School      = selectedTeacher.Organization_Name;
            enteredPeMinute.Grade       = selectedTeacher.COURSE_TITLE;
            enteredPeMinute.IsApproved  = 1;
            enteredPeMinute.ApprovedBy  = teacherNameVariable;
            enteredPeMinute.ApproveTime = DateTime.Now;
            _db.EnteredPeMinutes.Add(enteredPeMinute);
            _db.SaveChanges();
            return(Json(new { success = true }));
        }