public int GetUserIdByAccessToken(string accessToken) { UserQuery userQuery = new UserQuery(language); System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname("users", "accessToken", accessToken)); if (dataTable.Rows.Count > 0) { return(Convert.ToInt32(dataTable.Rows[0]["id"].ToString())); } else { return(-1); } }
public int GetUserIdByWarshaId(int supplier_id) { UserQuery userQuery = new UserQuery(language); System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname("supplier", "id", supplier_id)); if (dataTable.Rows.Count > 0) { return(Convert.ToInt32(dataTable.Rows[0]["user_id"].ToString())); } else { return(-1); } }
public int GetUserIdByPhoneNumber(string phoneNumber) { UserQuery userQuery = new UserQuery(language); System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname("users", "PHONENUMBER", phoneNumber)); if (dataTable.Rows.Count > 0) { return(Convert.ToInt32(dataTable.Rows[0]["id"].ToString())); } else { return(-1); } }
public bool CheckphoneNumberAvailability(string phoneNumber) { UserQuery userQuery = new UserQuery(language); System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname("users", "phoneNumber", phoneNumber)); if (dataTable.Rows.Count > 0) // if exist return false , do not insert { return(true); } else { return(false); } }
//public UserDb GetUserByUsername(string username) //{ // UserQuery userQuery = new UserQuery(); // System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname<string>("users_v", "username", username)); // UserDb userdb = new UserDb(); // if (dataTable.Rows.Count > 0) // { // userdb.userId =Convert.ToInt32( dataTable.Rows[0]["USER_ID"].ToString()); // userdb.username = dataTable.Rows[0]["USERNAME"].ToString(); // userdb.fullname = dataTable.Rows[0]["FULLNAME"].ToString(); // userdb.email = dataTable.Rows[0]["EMAIL"].ToString(); // userdb.password = dataTable.Rows[0]["PASSWORD"].ToString(); // userdb.phoneNumber = dataTable.Rows[0]["PHONENUMBER"].ToString(); // userdb.countryCode = dataTable.Rows[0]["countryCode"].ToString(); // userdb.isActive = Convert.ToInt32(dataTable.Rows[0]["isActive"].ToString()); // userdb.rating = Convert.ToDouble(dataTable.Rows[0]["RATING"].ToString()); // userdb.userType = Convert.ToInt32(dataTable.Rows[0]["USERTYPE"].ToString()); // userdb.accessToken = dataTable.Rows[0]["ACCESSTOKEN"].ToString(); // userdb.img = dataTable.Rows[0]["IMG"].ToString(); // userdb.socialId = dataTable.Rows[0]["SOCIAL_ID"].ToString(); // } // else // return null; // return userdb; //} public string GetWarshaImageByUser_id(int user_id) { UserQuery userQuery = new UserQuery(language); System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname <string>("users_v", "user_id", user_id.ToString())); UserDb userdb = new UserDb(); if (dataTable.Rows.Count == 0) { throw new EmptyViewException(language); } return(dataTable.Rows[0]["IMG"].ToString()); }
public UserDb GetPhoneInfoByPhoneNumber(string phoneNumber) { UserQuery userQuery = new UserQuery(language); System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname <string>("users_v", "phoneNumber", phoneNumber)); UserDb userdb = new UserDb(); if (dataTable.Rows.Count == 0) { throw new EmptyViewException(language); } userdb.phoneNumber = dataTable.Rows[0]["PHONENUMBER"].ToString(); userdb.countryCode = dataTable.Rows[0]["countryCode"].ToString(); return(userdb); }
//public bool UpdatePersonProfile(PersonDb person, int user_id) //{ // UserQuery userQuery = new UserQuery(); // try // { // return userQuery.UpdatePersonProfile(person, user_id); // } // catch (Exception ex) // { // return false; // } //} //public bool UpdateWarshaProfile(WorkshopDb workshop, int user_id) //{ // UserQuery userQuery = new UserQuery(); // try // { // return userQuery.UpdateWarshaProfile(workshop, user_id); // } // catch (Exception ex) // { // return false; // } //} //public PersonDb GetPersonProfile(int user_id) //{ // UserQuery userQuery = new UserQuery(); // System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname("persons_v", "user_id", user_id)); // PersonDb person = new PersonDb(); // if (dataTable.Rows.Count > 0) // { // person.id = Convert.ToInt32(dataTable.Rows[0]["ID"].ToString()); // person.fullname = dataTable.Rows[0]["FULLNAME"].ToString(); // person.IqammaNumber = Convert.ToInt32(dataTable.Rows[0]["IQAMMANUMBER"].ToString()); // person.rating = Convert.ToDouble(dataTable.Rows[0]["RATING"].ToString()); // } // else // return null; // return person; //} //public WorkshopDb GetWarshaProfile(int user_id) //{ // UserQuery userQuery = new UserQuery(); // System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname("workshop_v", "user_id", user_id)); // WorkshopDb workshop = new WorkshopDb(); // if (dataTable.Rows.Count > 0) // { // workshop.id = Convert.ToInt32(dataTable.Rows[0]["ID"].ToString()); // workshop.fullName = dataTable.Rows[0]["FULLNAME"].ToString(); // workshop.recordNumber = dataTable.Rows[0]["RECORDNUMBER"].ToString(); // try // {workshop.expiryDate = Convert.ToDateTime(dataTable.Rows[0]["EXPIRYDATE"].ToString());} // catch // {workshop.expiryDate = DateTime.Now;} // workshop.shopNumber = dataTable.Rows[0]["SHOPNUMBER"].ToString(); // workshop.shopName = dataTable.Rows[0]["SHOPNAME"].ToString(); // try // { workshop.expiryDate = Convert.ToDateTime(dataTable.Rows[0]["EXPIRYDATE"].ToString()); } // catch // { workshop.expiryDate = DateTime.Now; } // try // { workshop.LocationX = Convert.ToDouble(dataTable.Rows[0]["LOCATIONX"].ToString()); } // catch // { workshop.LocationX = 0; } // try // { workshop.LocationY = Convert.ToDouble(dataTable.Rows[0]["LOCATIONY"].ToString()); } // catch // { workshop.LocationY = 0; } // try // { workshop.industrialAreaId = Convert.ToInt32(dataTable.Rows[0]["INDUSTRIALAREA_ID"].ToString()); } // catch // { workshop.industrialAreaId = 0; } // try // { workshop.rating = Convert.ToDouble(dataTable.Rows[0]["RATING"].ToString()); } // catch // { workshop.rating = 0; } // workshop.industrialAreaName = dataTable.Rows[0]["AREANAME"].ToString(); // workshop.cityId =Convert.ToInt32(dataTable.Rows[0]["CITY_ID"].ToString()); // workshop.cityName = dataTable.Rows[0]["CITYNAME"].ToString(); // } // else // return null; // return workshop; //} public double GetRaingByUserId(int user_id) { UserQuery userQuery = new UserQuery(language); System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname("rating", "user_id", user_id)); double rating = new Rating().ratingRatio; if (dataTable.Rows.Count == 0) { throw new EmptyViewException(language); } rating = Convert.ToDouble(dataTable.Rows[0]["ID"].ToString()); return(rating); }
public LoginDTO LoginControl(string phoneNumber, string password) { UserQuery userQuery = new UserQuery(language); var status = false; System.Data.DataTable dataTable; dataTable = conn_db.ReadTable(userQuery.GetObjectByColname("users", "phoneNumber", phoneNumber)); if (dataTable.Rows.Count == 0) { throw new EmptyViewException(language); } if (PasswordHash.ValidatePassword(password, dataTable.Rows[0]["PASSWORD"].ToString())) { status = true; } LoginDTO user = new LoginDTO { user_id = dataTable.Rows[0]["id"].ToString(), accessToken = dataTable.Rows[0]["accessToken"].ToString(), username = dataTable.Rows[0]["username"].ToString(), userType = dataTable.Rows[0]["USER_TYPE_ID"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["USER_TYPE_ID"]) }; if (status) { return(user); } else { return(null); } }
public bool GetIsOlderFlag(string phonenumber) { UserQuery userQuery = new UserQuery(language); System.Data.DataTable dataTable = conn_db.ReadTable(userQuery.GetObjectByColname <string>("users", "phonenumber", phonenumber)); int flag = 0; if (dataTable.Rows.Count == 0) { return(false); } flag = dataTable.Rows[0]["ISOLDUSER"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["ISOLDUSER"].ToString()); if (flag == 0) { return(false); } else { return(true); } }