Add: GetChildByID
Add: GetGuardiansByChild() //MAY NEED DEBUGGING
This commit is contained in:
parent
acf7b2a405
commit
6ca8d8453e
|
@ -21,6 +21,21 @@ namespace GreatHomeChildcare
|
||||||
// ***************** Create *****************
|
// ***************** Create *****************
|
||||||
// ***************** Read *******************
|
// ***************** Read *******************
|
||||||
|
|
||||||
|
/* Gets a single child from the sqlite database
|
||||||
|
* provided an id number.
|
||||||
|
* INPUT: integer id
|
||||||
|
* OUTPUT: Child object
|
||||||
|
*/
|
||||||
|
internal Child GetChildByID(int id_in)
|
||||||
|
{
|
||||||
|
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||||
|
{
|
||||||
|
string strQuery = "SELECT * FROM Children WHERE id=@id";
|
||||||
|
Child output = cnn.Query<Child>(strQuery, new { id = id_in }).SingleOrDefault();
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Gets all children from the sqlite database.
|
/* Gets all children from the sqlite database.
|
||||||
* INPUT: void
|
* INPUT: void
|
||||||
* OUTPUT: list of Child objects
|
* OUTPUT: list of Child objects
|
||||||
|
@ -43,6 +58,20 @@ namespace GreatHomeChildcare
|
||||||
|
|
||||||
// ***************** Read *****************
|
// ***************** Read *****************
|
||||||
|
|
||||||
|
/* Gets all guardians for a single child.
|
||||||
|
* INPUT: Child
|
||||||
|
* OUTPUT: List of guardian object.
|
||||||
|
*/
|
||||||
|
internal List<Guardian> GetGuardiansByChild(Child child_in)
|
||||||
|
{
|
||||||
|
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||||
|
{
|
||||||
|
string strQuery = "SELECT * FROM Guardians WHERE id IN (SELECT guardian_id FROM Authorized_Guardians WHERE child_id = @id)";
|
||||||
|
var output = cnn.Query<Guardian>(strQuery, child_in);
|
||||||
|
return output.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Gets a Guardian by a distinct pin number. Distinctness enforced elsewhere.
|
/* Gets a Guardian by a distinct pin number. Distinctness enforced elsewhere.
|
||||||
* INPUT: integer pin#
|
* INPUT: integer pin#
|
||||||
* OUTPUT: Guardian object
|
* OUTPUT: Guardian object
|
||||||
|
|
Loading…
Reference in New Issue
Block a user