Пример #1
0
        public async Task <ForgetResponse> ForgetPasswordUpdate(ForgetRequestUpdate forgetRequest)
        {
            var           responseCode  = new ForgetResponse();
            var           connection    = _configuration.GetConnectionString("DBConnection");
            SqlConnection sqlConnection = new SqlConnection(connection);
            DataTable     table         = new DataTable();
            DataTable     dt            = new DataTable();

            try
            {
                string querySelect = ConnectionQueryForget(forgetRequest.Email);
                dt = _databaseAccesReuseable.ReturnTable(querySelect);
                if (dt.Rows.Count > 0)
                {
                    DataColumn[] columns = dt.Columns.Cast <DataColumn>().ToArray();
                    bool         anyFieldContainsSecurity = dt.AsEnumerable()
                                                            .Where(c => c.Field <string>("securityQuestion1").Equals(forgetRequest.securityQuestion1))
                                                            .Where(c => c.Field <string>("securityAnswer1").Equals(forgetRequest.securityAnswer1))
                                                            .Where(c => c.Field <string>("securityQuestion2").Equals(forgetRequest.securityQuestion2))
                                                            .Where(c => c.Field <string>("securityAnswer2").Equals(forgetRequest.securityAnswer2))
                                                            .Where(c => c.Field <string>("securityQuestion3").Equals(forgetRequest.securityQuestion3))
                                                            .Where(c => c.Field <string>("securityAnswer3").Equals(forgetRequest.securityAnswer3))
                                                            .Count() > 0;
                    if (anyFieldContainsSecurity)
                    {
                        string     query      = connectionqueryforgetupdate(forgetRequest);
                        SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
                        sqlConnection.Open();
                        int count = (int)sqlCommand.ExecuteNonQuery();
                        if (sqlConnection.State == System.Data.ConnectionState.Open)
                        {
                            sqlConnection.Close();
                        }
                        if (count > 0)
                        {
                            responseCode.Message = "Updated Successfully";
                            responseCode.Email   = forgetRequest.Email;
                        }
                    }
                    else
                    {
                        responseCode.Message = "Email Not Exist";
                    }
                }
                else
                {
                    responseCode.Message = "Email Not Exist";
                }
            }
            catch (Exception ex)
            {
                Log.Information("DB Having Error" + ex.Message);
            }
            finally
            {
                sqlConnection.Dispose();
            }
            return(responseCode);
        }
Пример #2
0
        public async Task <IActionResult> ForgetUpdate(
            [FromBody] ForgetRequestUpdate forgetRequestUpdate)
        {
            ForgetResponse response = new ForgetResponse();

            response = await _databaseAccess.ForgetPasswordUpdate(forgetRequestUpdate);

            return(StatusCode(200, response));
        }