private void button4_Click(object sender, EventArgs e) { try { StudentDTO.UserAndStudentDTO userAndStudentDTO = new StudentDTO.UserAndStudentDTO() { StudentId = Int32.Parse(textBox3.Text), firstName = textBox4.Text, lastName = textBox5.Text, city = textBox6.Text, street = textBox7.Text, numhouse = Int32.Parse(textBox8.Text), email = textBox9.Text, password = textBox10.Text, phone = textBox11.Text, tz = textBox12.Text, IdGrade = Int32.Parse(textBox13.Text), Level = textBox14.Text }; BL.StudentBL.AddStudent(userAndStudentDTO); MessageBox.Show("ok"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public static void updateStudent(StudentDTO.UserAndStudentDTO userAndStudentDTO, int id) { using (RacheliandDiniEntities3 db = new RacheliandDiniEntities3()) { foreach (var user in db.Users) { if (user.userId == id) { user.firstName = userAndStudentDTO.firstName; user.city = userAndStudentDTO.city; user.lastName = userAndStudentDTO.lastName; user.street = userAndStudentDTO.street; user.numhouse = userAndStudentDTO.numhouse; user.phone = userAndStudentDTO.phone; user.password = userAndStudentDTO.password; user.email = userAndStudentDTO.email; user.tz = userAndStudentDTO.tz; } ; } foreach (var student in db.Students) { if (student.StudentId == id) { student.IdGrade = userAndStudentDTO.IdGrade; student.Level = userAndStudentDTO.Level; } } db.SaveChanges(); } }
public static object getIdStudent(UserDTO.userLogin baseUser) { foreach (var user in DAL.UserDal.GetUsers()) { if (user.firstName == baseUser.firstName && user.password == baseUser.password) { var s = getStudentById(user.userId); StudentDTO.UserAndStudentDTO userAndStudent = new StudentDTO.UserAndStudentDTO() { city = user.city, firstName = user.firstName, lastName = user.lastName, street = user.street, numhouse = user.numhouse, phone = user.phone, password = user.password, email = user.email, tz = user.tz, IdGrade = s.IdGrade, Level = s.Level }; return(userAndStudent); } } return(null); }
public static StudentDTO.UserAndStudentDTO getStudentAndUserById(int id) { foreach (var student in DAL.StudentDAL.GetStudents()) { if (student.StudentId == id) { var u = DAL.UserDal.GetUsers().Find(i => i.userId == id); StudentDTO.UserAndStudentDTO userAndStudentDTO = new StudentDTO.UserAndStudentDTO() { userId = u.userId, firstName = u.firstName, lastName = u.lastName, city = u.city, street = u.street, numhouse = u.numhouse, phone = u.phone, password = u.password, email = u.email, tz = u.tz, IdGrade = student.IdGrade, Level = student.Level }; return(userAndStudentDTO); } } return(null); }
public static void updateStudent(StudentDTO.UserAndStudentDTO userAndStudentDTO) { foreach (var user in DAL.UserDal.GetUsers()) { if (user.email == userAndStudentDTO.email && user.password == userAndStudentDTO.password) { DAL.StudentDAL.updateStudent(userAndStudentDTO, user.userId); } } }
public IHttpActionResult updateStudent(StudentDTO.UserAndStudentDTO userAndStudentDTO) { try { BL.StudentBL.updateStudent(userAndStudentDTO); return(Ok()); } catch (Exception) { return(BadRequest()); } }
public IHttpActionResult AddStudent(StudentDTO.UserAndStudentDTO student) { try { BL.StudentBL.AddStudent(student); return(Ok()); } catch (Exception e) { return(BadRequest()); } }