public async Task <long> RegisterAsync([FromForm] DoctorsModel model) { try { var ss = model.PICTURE_2; string path = Path.Combine(@"E:\reactProjects\NEWAPP\components\Doctors\Admin\assets\img"); string query = "INSERT INTO doctors(`NAME`, `FATHER_NAME`, `EMAIL`, `DESCRIPTION`, `EDUCATIONAL_INSTITUTE`, `AGE`, `GENDER`, `EXPERIENCE`, `D_PASSWORD`, `CONTACT`, `ADDRESS`, `PICTURE`, `SPECIALIZATION_ID`, `DISTRICT_ID`)" + " VALUES('" + model.NAME + "','" + model.FATHER_NAME + "','" + model.EMAIL + "','" + model.DESCRIPTION + "'," + "'" + model.EDUCATIONAL_INSTITUTE + "','" + model.AGE + "','" + model.GENDER + "','" + model.EXPERIENCE + "','" + model.PASSWORD + "','" + model.CONTACT + "','" + model.ADDRESS + "','" + ss.FileName.ToString() + "','" + model.SPECIALIZATION_ID + "','" + model.DISTRICT_ID + "')"; connection.Open(); MySqlCommand cmd = new MySqlCommand(query, connection); int result = cmd.ExecuteNonQuery(); connection.Close(); if (result != 0) { var fs = new FileStream(Path.Combine(path, ss.FileName), FileMode.Create); await ss.CopyToAsync(fs); return(1); } return(0); } catch (Exception e) { return(0); } }
public int ForgotPassword([FromForm] DoctorsModel model) { try { string sql = "UPDATE DOCTORS SET DOCTORS.D_PASSWORD='******' WHERE DOCTORS.EMAIL='" + model.EMAIL + "'"; connection.Open(); MySqlCommand cmd = new MySqlCommand(sql, connection); int res = cmd.ExecuteNonQuery(); connection.Close(); return(res); } catch (Exception ex) { return(0); } }
public DoctorsModel Login([FromForm] string data) { DoctorsModel model = new DoctorsModel(); try { var login = data.Split(','); string query = "SELECT DOCTORS.*, DOCTORS_SPECIALIZATION.SPECIALIZATION, DISTRICTS.DISTRICT FROM DOCTORS " + "INNER JOIN DOCTORS_SPECIALIZATION INNER JOIN DISTRICTS ON DOCTORS.SPECIALIZATION_ID=DOCTORS_SPECIALIZATION.ID AND DOCTORS.DISTRICT_ID=DISTRICTS.ID " + "WHERE DOCTORS.EMAIL='" + login[0] + "' AND DOCTORS.D_PASSWORD='******'"; connection.Open(); MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { model.ID = reader.GetInt16("ID"); model.NAME = reader.GetString("NAME"); model.FATHER_NAME = reader.GetString("FATHER_NAME"); model.EMAIL = reader.GetString("EMAIL"); model.DESCRIPTION = reader.GetString("DESCRIPTION"); model.EDUCATIONAL_INSTITUTE = reader.GetString("EDUCATIONAL_INSTITUTE"); model.AGE = reader.GetInt16("AGE"); model.GENDER = reader.GetString("GENDER"); model.EXPERIENCE = reader.GetInt16("EXPERIENCE"); model.PASSWORD = reader.GetString("D_PASSWORD"); model.CONTACT = reader.GetString("CONTACT"); model.ADDRESS = reader.GetString("ADDRESS"); model.PICTURE = reader.GetString("PICTURE"); model.SPECIALIZATION_ID = reader.GetInt16("SPECIALIZATION_ID"); model.DISTRICT_ID = reader.GetInt16("DISTRICT_ID"); model.SPECIALIZATION = reader.GetString("SPECIALIZATION"); model.DISTRICT = reader.GetString("DISTRICT"); } connection.Close(); return(model); } catch (Exception e) { return(model); } }