Exemple #1
0
        public ActionResult Create([Bind(Include = "ID,Status,EndTime,TutorID")] TutoringServiceAlert tutoringServiceAlert, DateTime?Date)
        {
            if (Date == null)
            {
                Date = (DateTime.Now);
            }

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

            tutoringServiceAlert.EndTime = Convert.ToDateTime(date + " " + endTime);

            if (ModelState.IsValid)
            {
                if (tutoringServiceAlert.Status == "Absent")
                {
                    tutoringServiceAlert.EndTime = Convert.ToDateTime(date + " " + "05:00:00 PM");
                }
                db.TutoringServiceAlerts.Add(tutoringServiceAlert);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home", "tutor"));
            }

            ViewBag.TutorID = new SelectList(db.Tutors, "ID", "VNumber", tutoringServiceAlert.TutorID);
            return(View(tutoringServiceAlert));
        }
        public ActionResult Index()
        {
            ViewBag.Current = "HomeIndex";

            ViewBag.csList = db.Classes.Where(c => c.Name.Contains("CS")).ToList();
            ViewBag.isList = db.Classes.Where(c => c.Name.Contains("IS")).ToList();

            // Remove out-dated Service Alerts
            var allServiceAppts = db.TutoringServiceAlerts;

            foreach (var alert in allServiceAppts)
            {
                if (DateTime.Now > alert.EndTime)
                {
                    var currentItem = alert.ID;
                    TutoringServiceAlert serviceAlert = db.TutoringServiceAlerts.Find(currentItem);

                    db.TutoringServiceAlerts.Remove(serviceAlert);
                }
            }

            db.SaveChanges();

            if (TempData["msg"] != null) // ref from Controllers/AccountController/ForgotPassword
            {
                ViewBag.msg = "An email will be sent to " + TempData["msg"].ToString() + " if it's assosiated with our system. Goodluck!";
            }

            return(View());
        }
Exemple #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            TutoringServiceAlert tutoringServiceAlert = db.TutoringServiceAlerts.Find(id);

            db.TutoringServiceAlerts.Remove(tutoringServiceAlert);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #4
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));
 }
Exemple #5
0
        // GET: Tutor/TutoringServiceAlerts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TutoringServiceAlert tutoringServiceAlert = db.TutoringServiceAlerts.Find(id);

            if (tutoringServiceAlert == null)
            {
                return(HttpNotFound());
            }
            return(View(tutoringServiceAlert));
        }
Exemple #6
0
        // GET: Tutor/TutoringServiceAlerts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TutoringServiceAlert tutoringServiceAlert = db.TutoringServiceAlerts.Find(id);

            if (tutoringServiceAlert == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TutorID = new SelectList(db.Tutors, "ID", "VNumber", tutoringServiceAlert.TutorID);
            return(View(tutoringServiceAlert));
        }