/// <summary> /// Производит вход пользователя в систему /// </summary> /// <returns>true - залогинен, false - не залогинен</returns> public bool Login() { DB db = new DB(); DB.ResponseTable users = db.QueryToRespontTable(string.Format("select * from student inner join users on student.Student_id = users.Student_id where Email='{0}' and Password='******';", this.Email, this.Password)); if (users != null && users.CountRow == 1) { users.Read(); this.userID = Convert.ToInt32(users["User_id"]); this.accessLevel = Convert.ToInt32(users["Access_level"]); this.studentID = Convert.ToInt32(users["Student_id"]); this.groupID = Convert.ToInt32(users["Group_id"]); this.name = (string)users["Name"]; this.surname = (string)users["Surname"]; this.secondName = (string)users["Second_name"]; this.currentSemester = Convert.ToInt32(users["Semester"]); this.address = (string)users["Address"]; this.telephone = (string)users["Telephone"]; this.recordBook = (string)users["Record_book"]; this.typeOfEducetion = Student.ConverStringToEnum((string)users["Type_of_education"]); this.contactsParents = (string)users["Contacts_parents"]; this.employmentInTheDepartment = (string)users["Employment_in_the_department"]; return(true); } return(false); }
public bool UpdateTypeOfEducation(int id, TypeOfEducation data) { var res = _context.TypeOfEducation.FirstOrDefault(x => x.id == id); if (res == null) { return(false); } res.title = data.title; _context.SaveChanges(); return(true); }
public int AddTypeOfEducation(TypeOfEducation data) { var checkNumber = _context.TypeOfEducation.Any(x => x.title == data.title); if (checkNumber) { return(-1); } var res = _context.TypeOfEducation.Add(data); _context.SaveChanges(); return(res.Entity.id); }
/// <summary> /// Считывает информацию об студенте из БД /// </summary> /// <returns></returns> public override bool GetInformationAboutUserFromDB() { DB db = new DB(); string query; if (this.email != string.Empty && this.passwodr != string.Empty) { query = string.Format("select * from student inner join users on student.Student_id = users.Student_id where users.Email='{0}' and users.Password='******';", this.Email, this.Password); } else if (this.userID != -1) { query = string.Format("select * from student inner join Users on student.Student_id = users.Student_id where users.User_id = {0};", this.userID); } else if (this.studentID != -1) { query = string.Format("select * from student inner join users on student.Student_id = users.Student_id where student.Student_id = {0};", this.studentID); } else { query = ""; } DB.ResponseTable users = db.QueryToRespontTable(query); if (users != null && users.CountRow == 1) { users.Read(); this.userID = Convert.ToInt32(users["User_id"]); this.email = (string)users["Email"]; this.passwodr = (string)users["Password"]; this.accessLevel = Convert.ToInt32(users["Access_level"]); this.studentID = Convert.ToInt32(users["Student_id"]); this.groupID = Convert.ToInt32(users["Group_id"]); this.name = (string)users["Name"]; this.surname = (string)users["Surname"]; this.secondName = (string)users["Second_name"]; this.currentSemester = Convert.ToInt32(users["Semester"]); this.address = (string)users["Address"]; this.telephone = (string)users["Telephone"]; this.recordBook = (string)users["Record_book"]; this.typeOfEducetion = Student.ConverStringToEnum((string)users["Type_of_education"]); this.contactsParents = (string)users["Сontacts_parents"]; this.employmentInTheDepartment = (string)users["Employment_in_the_department"]; return(true); } return(false); }
public IActionResult PutTypeofEducation(int id, [FromBody] TypeOfEducation data) { try { var res = _repository.UpdateTypeOfEducation(id, data); if (!res) { return(Conflict(409)); } return(Ok(res)); } catch (Exception error) { return(BadRequest(error)); } }
public IActionResult PostTypeofEducation(TypeOfEducation data) { try { var res = _repository.AddTypeOfEducation(data); if (res == -1) { return(Conflict(409)); } return(Ok(res)); } catch (Exception error) { return(BadRequest(error)); } }