public void putcourse(String CourseName, int coursenumber) { courseslist course = new courseslist { courseName = CourseName, courseNumber = coursenumber }; _db.courseslists.Add(course); _db.SaveChanges(); _db.Dispose(); }
public void addCommittee(String CommitteeName) { Committee committee = new Committee { Committee_Name = CommitteeName, Committee_Startdate = DateTime.Now, Committee_Enddate = DateTime.Now.AddYears(10), Committee_Active = "yes", Committee_Faculty = "Supply Chain" }; _db.Committees.Add(committee); _db.SaveChanges(); _db.Dispose(); }
public void addNote(agendanote note, String commName, int meetingId, string username) { agendanote notes = new agendanote { Post_date = System.DateTime.Now, Poster = username, Post = note.Post, meetingId = meetingId, creation_dateOfCommittee = System.DateTime.Now, committee_name = commName }; _db.agendanotes.Add(notes); _db.SaveChanges(); _db.Dispose(); }
public ActionResult unassign(String email) { //var committeename = Request.QueryString["committeeName"]; System.Diagnostics.Debug.WriteLine("from unassign" + commName); var userdeleted = (from users in _db.committee_Memberlist where users.Uname_ofMember == email where users.name_ofCommittee == commName select users); if (userdeleted != null) { foreach (var users in userdeleted) { _db.committee_Memberlist.Remove(users); } } var model2 = (from prof in _db.committee_Memberlist join users in _db.users on prof.Uname_ofMember equals users.email select new loadcourseprofessors { Name = users.FIRSTName, Lname = users.LASTName, email = users.email, Role = users.role, Assigned = (from profs in _db.committee_Memberlist where profs.Uname_ofMember == users.email where profs.name_ofCommittee == commName select profs.Uname_ofMember).Any() ? true : false }).Distinct().ToList(); try { _db.SaveChanges(); _db.Dispose(); } catch (Exception) { } return(PartialView("LoadCommitteeproffessors", model2)); }
public void addmeetingtodb(meeting m) { var cname = m.committee_name; var message = m.Message_Agenda; var endtime = m.end_date; meeting newmeeting = new meeting { committee_name = cname, creation_date = DateTime.Now, end_date = endtime, active = "yes", Message_Agenda = message }; _db.meetings.Add(newmeeting); _db.SaveChanges(); _db.Dispose(); }
public void CreateAccount(user s) { var hashedpassword = Crypto.HashPassword(s.password); var user = new user { FIRSTName = s.FIRSTName.ToString(), LASTName = s.LASTName.ToString(), email = s.email.ToString(), password = hashedpassword.ToString(), role = s.role.ToString() }; _db.users.Add(user); try { _db.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } _db.Dispose(); }
public void dispose() { _db.Dispose(); }