public PasswordDetails GetStudentPasswordData(string IndexNumber) { PasswordDetails response = new PasswordDetails(); try { using SqlConnection con = new SqlConnection(ConString); using SqlCommand com = new SqlCommand { Connection = con, CommandText = "Select Password,Salt from Student where IndexNumber=@index" }; com.Parameters.AddWithValue("@index", IndexNumber); con.Open(); SqlDataReader reader = com.ExecuteReader(); if (reader.Read()) { response.Password = reader["StudentPassword"].ToString().Trim(); response.Salt = reader["Salt"].ToString().Trim(); reader.Close(); return(response); } reader.Close(); return(null); } catch (Exception) { return(null); } }
public async Task <ActionResult <PasswordDetails> > PostPasswordDetails(PasswordDetails PasswordDetails) { _context.PasswordsDetails.Add(PasswordDetails); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPasswordDetails", new { id = PasswordDetails.PasswordDetailsId }, PasswordDetails)); }
public async Task <IActionResult> PutPasswordDetails(int id, PasswordDetails PasswordDetails) { if (id != PasswordDetails.PasswordDetailsId) { return(BadRequest()); } _context.Entry(PasswordDetails).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PasswordDetailsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Add(PasswordDetails password) { var elasticsearchUrl = _configuration["Elasticsearch:Url"]; EnsureIndex(elasticsearchUrl); try { var node = new Uri(elasticsearchUrl); var client = new ElasticClient(node); client.Index(password, idx => idx.Index("passwords")); } catch (Exception ex) { Console.WriteLine($"Index password FAILED, ex: {ex}"); } }
public PasswordDetails GetStudentPasswordData(string IndexNumber) { PasswordDetails response = new PasswordDetails(); try { var tmp = db.Student.Where(s => s.IndexNumber == IndexNumber).Select(s => new { Password = s.Pass, Salt = s.Salt }).First(); if (tmp != null) { response.Password = tmp.Password; response.Salt = tmp.Salt; return(response); } return(null); } catch (Exception) { return(null); } }
public void OnPost(PasswordDetails passwordDetails) { }