//SetConversationSeen public dynamic SetConversationToSeen(Conversation request, int id) { dynamic result = null; try { var dyParam = new OracleDynamicParameters(); dyParam.Add("p_id", OracleDbType.Int32, ParameterDirection.Input, id, sizeof(Int32)); dyParam.Add("p_sender_id", OracleDbType.Int32, ParameterDirection.Input, request.otherUserID, sizeof(Int32)); dyParam.Add("cursorParam", OracleDbType.RefCursor, ParameterDirection.Output); var conn = MatchboxConnection.GetConnection(this.configuration); if (conn.State == ConnectionState.Closed) { conn.Open(); } if (conn.State == ConnectionState.Open) { var query = "USP_CONVERSATIONSEEN"; result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { // throw ex; result = "ERROR"; } return(result); }
//GetUserInfo public dynamic GetInfo(int id) { dynamic result = null; try { var dyParam = new OracleDynamicParameters(); dyParam.Add("id_in", OracleDbType.Int32, ParameterDirection.Input, id, sizeof(Int32)); dyParam.Add("cursorParam", OracleDbType.RefCursor, ParameterDirection.Output); var conn = MatchboxConnection.GetConnection(this.configuration); if (conn.State == ConnectionState.Closed) { conn.Open(); } if (conn.State == ConnectionState.Open) { var query = "USP_GETUSERINFO"; result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { // throw ex; result = "ERROR"; } return(result); }
//set like public dynamic SetLike(LikeRequest request, int id) { dynamic result = null; try { var dyParam = new OracleDynamicParameters(); dyParam.Add("p_from_user", OracleDbType.Int32, ParameterDirection.Input, id, sizeof(Int32)); dyParam.Add("p_to_user", OracleDbType.Int32, ParameterDirection.Input, request.id, sizeof(Int32)); dyParam.Add("p_like_box", OracleDbType.Int32, ParameterDirection.Input, request.like, sizeof(Int32)); dyParam.Add("cursorParam", OracleDbType.RefCursor, ParameterDirection.Output); var conn = MatchboxConnection.GetConnection(this.configuration); if (conn.State == ConnectionState.Closed) { conn.Open(); } if (conn.State == ConnectionState.Open) { var query = "USP_SETLIKE"; result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { // throw ex; result = "ERROR"; } return(result); }
//set user location info public dynamic SetUserLocationInfo(LocationRequest request, int id) { dynamic result = null; try { var dyParam = new OracleDynamicParameters(); dyParam.Add("p_id", OracleDbType.Int32, ParameterDirection.Input, id, sizeof(Int32)); dyParam.Add("p_country", OracleDbType.Varchar2, ParameterDirection.Input, request.country, request.country.Length * sizeof(Char)); dyParam.Add("p_city", OracleDbType.Varchar2, ParameterDirection.Input, request.city, request.city.Length * sizeof(Char)); dyParam.Add("p_latitude", OracleDbType.Varchar2, ParameterDirection.Input, request.latitude, request.latitude.Length * sizeof(Char)); dyParam.Add("p_longitude", OracleDbType.Varchar2, ParameterDirection.Input, request.longitude, request.longitude.Length * sizeof(Char)); dyParam.Add("cursorParam", OracleDbType.RefCursor, ParameterDirection.Output); var conn = MatchboxConnection.GetConnection(this.configuration); if (conn.State == ConnectionState.Closed) { conn.Open(); } if (conn.State == ConnectionState.Open) { var query = "USP_SETUSERLOCATIONINFO"; result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { // throw ex; result = "ERROR"; } return(result); }
//register public dynamic Register(RegisterRequest request) { dynamic result = null; if (request.password != request.rePassword) { return("Password not matching"); } else { string encrypted = Sha256.CalculateSHA256Hash(request.password); try { var dyParam = new OracleDynamicParameters(); dyParam.Add("p_email", OracleDbType.Varchar2, ParameterDirection.Input, request.email, request.email.Length * sizeof(Char)); dyParam.Add("p_password", OracleDbType.Varchar2, ParameterDirection.Input, encrypted, encrypted.Length * sizeof(Char)); dyParam.Add("cursorParam", OracleDbType.RefCursor, ParameterDirection.Output); var conn = MatchboxConnection.GetConnection(this.configuration); if (conn.State == ConnectionState.Closed) { conn.Open(); } if (conn.State == ConnectionState.Open) { var query = "USP_ADDUSER"; result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { // throw ex; string errorCode = ex.Message.Split(':')[0]; if (errorCode == "ORA-02290") { result = "Email format incorrect"; } else if (errorCode == "ORA-00001") { result = "This email is already used"; } else if (errorCode == "ORA-01400") { result = "Field cannot be empty"; } else { result = "Error"; } } return(result); } }
//login public dynamic Login(LoginRequest request) { dynamic result = null; string encrypted = Sha256.CalculateSHA256Hash(request.password); try { var dyParam = new OracleDynamicParameters(); dyParam.Add("p_email", OracleDbType.Varchar2, ParameterDirection.Input, request.email, request.email.Length * sizeof(Char)); dyParam.Add("cursorParam", OracleDbType.RefCursor, ParameterDirection.Output); var conn = MatchboxConnection.GetConnection(this.configuration); if (conn.State == ConnectionState.Closed) { conn.Open(); } if (conn.State == ConnectionState.Open) { var query = "USP_GETUSER"; result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { //throw ex; result = "ERROR"; } int flag = 0; foreach (IDictionary <string, object> row in result) { foreach (var pair in row) { var num = pair.Key; var val = pair.Value; if (num == "PASSWORD") { if (encrypted == val.ToString()) { flag = 1; } } } } if (flag == 1) { return(result); } else { return("Not Matching"); } }
//set user info public dynamic SetUserInfo(UserInfoRequest request, int id) { dynamic result = null; try { var dyParam = new OracleDynamicParameters(); dyParam.Add("p_id", OracleDbType.Int32, ParameterDirection.Input, id, sizeof(Int32)); dyParam.Add("p_name", OracleDbType.Varchar2, ParameterDirection.Input, request.name, request.name.Length * sizeof(Char)); dyParam.Add("p_age", OracleDbType.Int32, ParameterDirection.Input, request.age, sizeof(Int32)); dyParam.Add("p_minAge", OracleDbType.Int32, ParameterDirection.Input, request.minAge, sizeof(Int32)); dyParam.Add("p_maxAge", OracleDbType.Int32, ParameterDirection.Input, request.maxAge, sizeof(Int32)); dyParam.Add("p_maxDistance", OracleDbType.Int32, ParameterDirection.Input, request.maxDistance, sizeof(Int32)); dyParam.Add("p_gender", OracleDbType.Varchar2, ParameterDirection.Input, request.gender, request.gender.Length * sizeof(Char)); dyParam.Add("p_school", OracleDbType.Varchar2, ParameterDirection.Input, request.school, request.school.Length * sizeof(Char)); dyParam.Add("p_job", OracleDbType.Varchar2, ParameterDirection.Input, request.job, request.job.Length * sizeof(Char)); dyParam.Add("p_company", OracleDbType.Varchar2, ParameterDirection.Input, request.company, request.company.Length * sizeof(Char)); dyParam.Add("p_description", OracleDbType.Varchar2, ParameterDirection.Input, request.description, request.description.Length * sizeof(Char)); dyParam.Add("cursorParam", OracleDbType.RefCursor, ParameterDirection.Output); var conn = MatchboxConnection.GetConnection(this.configuration); if (conn.State == ConnectionState.Closed) { conn.Open(); } if (conn.State == ConnectionState.Open) { var query = "USP_SETUSERINFO"; result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure); } } catch (Exception ex) { // throw ex; result = "ERROR"; } return(result); }