コード例 #1
0
        public ActionResult Create([Bind(Include = "id,GameDate,IsCancelled")] WednesdaySchedule WednesdaySchedule)
        {
            if (ModelState.IsValid)
            {
                db.WednesdaySchedules.Add(WednesdaySchedule);
                try
                {
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (System.Data.Entity.Infrastructure.DbUpdateException e)
                {
                    ErrorSignal.FromCurrentContext().Raise(e);
                    Exception ex = e;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                    }
                    ModelState.AddModelError(string.Empty, ex.Message);
                }
                catch (Exception e)
                {
                    ErrorSignal.FromCurrentContext().Raise(e);
                    ModelState.AddModelError(string.Empty, "Insert failed");
                }
            }

            return(View(WednesdaySchedule));
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            WednesdaySchedule WednesdaySchedule = db.WednesdaySchedules.Find(id);

            db.WednesdaySchedules.Remove(WednesdaySchedule);
            try
            {
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateException e)
            {
                ErrorSignal.FromCurrentContext().Raise(e);
                Exception ex = e;
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                ViewBag.Error = ex.Message;
            }
            catch (Exception e)
            {
                ErrorSignal.FromCurrentContext().Raise(e);
                ViewBag.Error = "Delete failed";
            }
            return(View(WednesdaySchedule));
        }
コード例 #3
0
        // GET: WednesdaySchedules/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WednesdaySchedule WednesdaySchedule = db.WednesdaySchedules.Find(id);

            if (WednesdaySchedule == null)
            {
                return(HttpNotFound());
            }
            return(View(WednesdaySchedule));
        }
コード例 #4
0
        // GET: WednesdaySchedules/Create
        public ActionResult Create()
        {
            var      id    = 1;
            DateTime date  = DateTime.Now;
            var      items = db.WednesdaySchedules.OrderByDescending(x => x.id);

            if (items.Count() > 0)
            {
                date = items.First().GameDate.AddDays(7);
                id   = items.First().id + 1;
            }
            var item = new WednesdaySchedule()
            {
                IsCancelled = false,
                id          = id,
                GameDate    = date
            };

            return(View(item));
        }
コード例 #5
0
        protected void ConfirmBtn_Click(object sender, EventArgs e)
        {
            if (DateTime.Today.DayOfWeek.Equals(DayOfWeek.Saturday) || DateTime.Today.Day.Equals(DayOfWeek.Sunday))
            {
                LogInformation("No Email Pings on the weekend!");
                return;
            }

            using (WebhostEntities db = new WebhostEntities())
            {
                Dictionary <Faculty, List <Section> > needAttendance = new Dictionary <Faculty, List <Section> >();
                int  tid  = DateRange.GetCurrentOrLastTerm();
                Term term = db.Terms.Find(tid);

                foreach (Section section in term.Sections.ToList())
                {
                    if (section.Block.IsSpecial)
                    {
                        continue;                          // don't mark these blocks...
                    }
                    switch (DateTime.Today.DayOfWeek)
                    {
                    case DayOfWeek.Monday: if (!section.Block.MeetsMonday)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Tuesday: if (!section.Block.MeetsTuesday)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Wednesday:
                        if (!section.Block.MeetsWednesday || section.Course.Name.Contains("Tutorial"))
                        {
                            continue;
                        }
                        else if (db.WednesdaySchedules.Where(w => w.Day.Equals(DateTime.Today)).Count() > 0)
                        {
                            WednesdaySchedule wed = db.WednesdaySchedules.Where(w => w.Day.Equals(DateTime.Today)).Single();
                            if (wed.IsABC && (new Regex("[DEF]")).IsMatch(section.Block.Name))
                            {
                                continue;
                            }
                        }
                        break;

                    case DayOfWeek.Thursday: if (!section.Block.MeetsThursday)
                        {
                            continue;
                        }
                        break;

                    case DayOfWeek.Friday: if (!section.Block.MeetsFriday)
                        {
                            continue;
                        }
                        break;

                    default: break;
                    }

                    if (section.AttendanceMarkings.Where(at => at.AttendanceDate.Equals(DateTime.Today)).Count() <= 0)
                    {
                        LogWarning("No attendance has been submitted for [{0}] {1}", section.Block.LongName, section.Course.Name);
                        foreach (Faculty teacher in section.Teachers.ToList())
                        {
                            if (!needAttendance.ContainsKey(teacher))
                            {
                                LogWarning("Adding {0} {1} to the Notify list.", teacher.FirstName, teacher.LastName);
                                needAttendance.Add(teacher, new List <Section>()
                                {
                                    section
                                });
                            }
                            else
                            {
                                needAttendance[teacher].Add(section);
                            }
                        }
                    }
                }

                String Subject      = "Please submit attendance";
                String BodyTemplate = "You have not entered attendance today for the following classes:" + Environment.NewLine;
                String DigestBody   = "The following Teachers have been informed that their attendance has not been taken for the indicated classes.";

                foreach (Faculty teacher in needAttendance.Keys)
                {
                    LogInformation("Sending Request Email to {0} {1} for {2} classes.", teacher.FirstName, teacher.LastName, needAttendance[teacher].Count);
                    String Body = String.Format("Dear {0},{1}{1}{2}", teacher.FirstName, Environment.NewLine, BodyTemplate);

                    DigestBody += String.Format("{0}{0}____________________________________{0}{1} {2}:", Environment.NewLine, teacher.FirstName, teacher.LastName);

                    foreach (Section section in needAttendance[teacher])
                    {
                        Body       += String.Format("{0}[{1}] {2}", Environment.NewLine, section.Block.LongName, section.Course.Name);
                        DigestBody += String.Format("{0}[{1}] {2}", Environment.NewLine, section.Block.LongName, section.Course.Name);
                    }

                    Body += String.Format("{0}{0}Thanks,{0}Dean of Students Office{0}{0}CC:[email protected], {1}@dublinschool.org", Environment.NewLine, teacher.UserName);

                    MailControler.MailToUser(Subject, Body, String.Format("{0}@dublinschool.org", teacher.UserName), String.Format("{0} {1}", teacher.FirstName, teacher.LastName));
                    //MailControler.MailToUser(Subject, Body, MailControler.DeanOfStudents.Email, MailControler.DeanOfStudents.Name);
                    //MailControler.MailToWebmaster(Subject, Body);
                }

                MailControler.MailToWebmaster("Attendance Reminder Digest", DigestBody);
                MailControler.MailToUser("Attendance Reminder Digest", DigestBody, MailControler.DeanOfStudents.Email, MailControler.DeanOfStudents.Name);
                LogInformation("Done sending Attendance Reminders.");
            }
            ConfirmPanel.Visible = false;
        }