public ActionResult Editmember(loadcourseprofessors lc) { if (ModelState.IsValid) { var newmodel = new committee_Memberlist { Uname_ofMember = lc.email, name_ofCommittee = commName, member_joindate = System.DateTime.Now, memeber_endate = System.DateTime.Now.AddYears(1), active = "yes" }; _db.committee_Memberlist.Add(newmodel); } try { _db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } return(Content("success")); }
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 add(String username, String CourseName, int CourseNum) { System.Diagnostics.Debug.WriteLine("ADDING" + username); System.Diagnostics.Debug.WriteLine("length:" + username.Length); var newuser = (from users in _db.courses_memberlist where users.instructor == username where users.CourseName == CourseName where users.CourseNum == CourseNum select users).FirstOrDefault(); System.Diagnostics.Debug.WriteLine("user:"******"START ADDING" + username); courses_memberlist newmember = new courses_memberlist { CourseName = CourseName, CourseNum = CourseNum, instructor = username, add_date = System.DateTime.Now, end_date = System.DateTime.Now.AddYears(1), active = "yes" }; _db.courses_memberlist.Add(newmember); try { _db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } } }
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 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 ActionResult EmailView(int msgid, String Read) { HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); var username = ticket.UserData; if (Read == "read") { var update = (from msg in _db.Inboxes where msg.ID == msgid select msg).FirstOrDefault(); if (update != null) { update.Read = "read"; _db.SaveChanges(); } } var email = (from msg in _db.Inboxes where msg.ID == msgid select new EmailViewModel { Recipient = msg.Recipient, Sender = msg.Sender, Senddate = msg.Senddate, Message = msg.Message, subject = msg.subject, attachments = msg.attachments }).FirstOrDefault(); return(View(email)); }