public List <AdminUserDTO> GetAllAdminUsers() { List <AdminUserDTO> adminUsers = new List <AdminUserDTO>(); using (officehoursEntities officeHoursDB = new officehoursEntities()) { var adminUserData = from f in officeHoursDB.officehours_Admin_Users select f; foreach (officehours_Admin_Users usr in adminUserData) { if (usr != null) { AdminUserDTO faculty = new AdminUserDTO() { AdminUserId = usr.Admin_User_Id, UserName = usr.User_Name, Password = usr.Password, DateCreated = (DateTime)usr.Date_Created }; adminUsers.Add(faculty); } } return(adminUsers); } }
public List <StudentMessageDTO> GetStudentMessagesById(int id) { List <StudentMessageDTO> studentMessages = new List <StudentMessageDTO>(); using (officehoursEntities officeHoursDB = new officehoursEntities()) { var adminUserData = from f in officeHoursDB.officehours_messages where f.message_id == id select f; foreach (officehours_messages usr in adminUserData) { if (usr != null) { StudentMessageDTO studentMessage = new StudentMessageDTO() { studentName = usr.student_Name, studentId = usr.student_id, DateCreated = (DateTime)usr.Date_Created, facultyMail = usr.faculty_mail, isArchived = Convert.ToInt32(usr.is_archived), message = usr.message, messageId = usr.message_id }; studentMessages.Add(studentMessage); } } return(studentMessages); } }
public string CreateStudentMessage(StudentMessageDTO studentMessage) { using (officehoursEntities officeHoursDB = new officehoursEntities()) { officehours_messages messageData = new officehours_messages() { faculty_mail = studentMessage.facultyMail, Date_Created = DateTime.Now, is_archived = studentMessage.isArchived, message = studentMessage.message, student_id = studentMessage.studentId, student_Name = studentMessage.studentName, message_id = studentMessage.messageId }; officeHoursDB.officehours_messages.Add(messageData); try { officeHoursDB.SaveChanges(); return(messageData.faculty_mail); } catch (Exception e) { Console.WriteLine(e); return(e.Message); } } }
public List <FacultyScheduleDTO> GetFacultyScheduleByMailandDate(string email, DateTime startDate, DateTime endDate) { List <FacultyScheduleDTO> facultySchedules = new List <FacultyScheduleDTO>(); using (officehoursEntities officeHoursDB = new officehoursEntities()) { var facultyData = from f in officeHoursDB.officehours_schedule where f.faculty_email == email && (f.schedule_start >= startDate && f.schedule_end <= endDate) select f; foreach (officehours_schedule fac in facultyData) { if (fac != null) { FacultyScheduleDTO faculty = new FacultyScheduleDTO() { facultyEmail = fac.faculty_email, scheduleColor = fac.schedule_color, scheduleId = fac.schedule_id, scheduleNote = fac.schedule_note, scheduleStart = fac.schedule_start, scheduleEnd = fac.schedule_end, scheduleGroup = fac.schedule_group }; facultySchedules.Add(faculty); } } return(facultySchedules); } }
public int CreateAdmin(AdminUserDTO user) { using (officehoursEntities officeHoursDB = new officehoursEntities()) { officehours_Admin_Users userData = new officehours_Admin_Users() { Admin_User_Id = user.AdminUserId, Date_Created = DateTime.Now, Password = user.Password, User_Name = user.UserName }; officeHoursDB.officehours_Admin_Users.Add(userData); try { officeHoursDB.SaveChanges(); return(userData.Admin_User_Id); } catch (Exception e) { Console.WriteLine(e); return(0); } } }
public string CreateFacultySchedule(FacultyScheduleDTO schedule) { using (officehoursEntities officeHoursDB = new officehoursEntities()) { officehours_schedule scheduleData = new officehours_schedule() { faculty_email = schedule.facultyEmail, schedule_color = schedule.scheduleColor, schedule_note = schedule.scheduleNote, schedule_start = schedule.scheduleStart, schedule_end = schedule.scheduleEnd, schedule_id = schedule.scheduleId, schedule_group = schedule.scheduleGroup }; officeHoursDB.officehours_schedule.Add(scheduleData); try { officeHoursDB.SaveChanges(); return(scheduleData.faculty_email); } catch (Exception e) { Console.WriteLine(e); return(e.Message); } } }
public List <FacultyDTO> GetFacultyByMail(string email) { List <FacultyDTO> faculties = new List <FacultyDTO>(); using (officehoursEntities officeHoursDB = new officehoursEntities()) { var facultyData = from f in officeHoursDB.officehours_faculty where f.Email == email select f; foreach (officehours_faculty fac in facultyData) { if (fac != null) { FacultyDTO faculty = new FacultyDTO() { memberId = fac.member_id, Email = fac.Email, accountStatus = Convert.ToInt32(fac.account_status), authCode = fac.auth_code, createDate = (DateTime)fac.create_date, firstName = fac.first_Name, lastName = fac.last_Name, Password = fac.Password, phoneNumber = fac.phone_number }; faculties.Add(faculty); } } return(faculties); } }
public bool UpdateFaculty(FacultyDTO user) { using (officehoursEntities officeHoursDB = new officehoursEntities()) { var facultyData = (from f in officeHoursDB.officehours_faculty where f.member_id == user.memberId select f).FirstOrDefault(); facultyData.member_id = user.memberId; facultyData.first_Name = user.firstName; facultyData.last_Name = user.lastName; facultyData.Email = user.Email; facultyData.Password = user.Password; facultyData.account_status = user.accountStatus; facultyData.auth_code = user.authCode; facultyData.create_date = DateTime.Now; facultyData.phone_number = user.phoneNumber; officeHoursDB.Entry(facultyData).State = EntityState.Modified; try { officeHoursDB.SaveChanges(); return(true); } catch (Exception ex) { return(false); } } }
public string CreateFaculty(FacultyDTO user) { using (officehoursEntities officeHoursDB = new officehoursEntities()) { officehours_faculty facultyData = new officehours_faculty() { member_id = user.memberId, first_Name = user.firstName, last_Name = user.lastName, Email = user.Email, Password = user.Password, account_status = user.accountStatus, auth_code = user.authCode, create_date = DateTime.Now, phone_number = user.phoneNumber }; officeHoursDB.officehours_faculty.Add(facultyData); try { officeHoursDB.SaveChanges(); return(facultyData.Email); } catch (Exception e) { Console.WriteLine(e); return(e.Message); } } }
public int DeleteMessageById(int id) { using (officehoursEntities officeHoursDB = new officehoursEntities()) { var deleteMessage = from f in officeHoursDB.officehours_messages where f.message_id == id select f; foreach (var item in deleteMessage) { officeHoursDB.officehours_messages.Remove(item); } try { officeHoursDB.SaveChanges(); return(1); } catch (Exception e) { Console.WriteLine(e); return(0); } } }
public int DeleteFacultyByMail(string email) { using (officehoursEntities officeHoursDB = new officehoursEntities()) { var deleteFaculty = from f in officeHoursDB.officehours_faculty where f.Email == email select f; foreach (var item in deleteFaculty) { officeHoursDB.officehours_faculty.Remove(item); } try { officeHoursDB.SaveChanges(); return(1); } catch (Exception e) { Console.WriteLine(e); return(0); } } }