public void DropRoster(RosterEntry student) { context.Roster.Remove(student); }
public bool PromoteAlternate(int classID) { if ((context.AlternateRoster.SingleOrDefault(u => u.class_id == classID)) == null) return false; else { int entryID = context.AlternateRoster.Where(q => q.class_id == classID).Min(q => q.ID); AlternateRosterEntry entry = context.AlternateRoster.SingleOrDefault(u => u.ID == entryID); var newRoster = new RosterEntry { ClassID = entry.class_id, StudentID = entry.user_id }; context.Roster.Add(newRoster); DropAlternateRoster(entry); Class tempclass = GetClass(classID); //delete entries for this student for other classes within the course foreach (AlternateRosterEntry a in context.AlternateRoster) { Class tempclass2 = GetClass(a.class_id); if ((a.user_id == entry.user_id) && (tempclass2.CourseID == tempclass.CourseID)) DropAlternateRoster(a); } context.SaveChanges(); var MySmtp = repository.Smtp.First(); // send notification email through gmail // email address "*****@*****.**" // password "P@ttersonetsemail" (Patterson employee training system email) System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage(); email.To.Add(GetUser(entry.user_id).email); email.Subject = "Alternate Promotion"; var fromAddress = new MailAddress(MySmtp.user); email.From = fromAddress; email.Body = "This is an automated message from 'Patterson Employee Training System' to inform you that you have been promoted from an alternate " + "attendee in " + tempclass.Course.Title + ", and are now officially registered as a student for this course."; System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(MySmtp.server); smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential(fromAddress.Address, MySmtp.password); smtp.EnableSsl = true; smtp.Port = MySmtp.port; smtp.Send(email); return true; } }
public int AddRoster(int cid, int sid) { // Class tempClass = Classes.SingleOrDefault(c => c.ID == cid); // Users.SingleOrDefault(s => s.id == sid).Classes.Add(tempClass); var newRoster = new RosterEntry { ClassID = cid, StudentID = sid }; var tempRoster = context.Roster; context.Roster.Add(newRoster); var result = context.SaveChanges(); return result; }