Add query to get guardian object by pin#
Add query to get children by guardian object.
This commit is contained in:
parent
bf174c3003
commit
ca702e1ca2
@ -17,6 +17,58 @@ namespace GreatHomeChildcare
|
||||
#endregion
|
||||
|
||||
#region guardian
|
||||
// ***************** Read *****************
|
||||
|
||||
/* Gets a Guardian by a distinct pin number. Distinctness enforced elsewhere.
|
||||
* INPUT: integer pin#
|
||||
* OUTPUT: Guardian object
|
||||
*/
|
||||
internal Guardian GetGuardianByPin(int guardian_pin_in)
|
||||
{
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = "SELECT * FROM Guardians WHERE PinNumber = @pin_in";
|
||||
Guardian guardian = cnn.Query<Guardian>(strQuery, new { pin_in = guardian_pin_in }).SingleOrDefault();
|
||||
return guardian;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region authorized_guardians
|
||||
// ***************** Read *****************
|
||||
|
||||
/* Gets a list of all children per a specific guardian.
|
||||
* INPUT: Guardian
|
||||
* OUTPUT: List of Child object.
|
||||
*/
|
||||
internal List<Child> GetChildrenByGuardian(Guardian guardian_in)
|
||||
{
|
||||
//TODO: Remove once valid login check is implemented.
|
||||
if (guardian_in == null)
|
||||
return null;
|
||||
|
||||
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
|
||||
{
|
||||
string strQuery = @"
|
||||
SELECT
|
||||
Children.id,
|
||||
Children.FirstName,
|
||||
Children.LastName,
|
||||
DOB,
|
||||
address,
|
||||
race,
|
||||
gender,
|
||||
photo
|
||||
FROM Children
|
||||
INNER JOIN Authorized_Guardians on Children.ID = Authorized_Guardians.child_id
|
||||
INNER JOIN Guardians on Authorized_Guardians.guardian_id = Guardians.id
|
||||
WHERE Guardians.id = @id
|
||||
";
|
||||
var output = cnn.Query<Child>(strQuery,guardian_in);
|
||||
return output.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region attendance
|
||||
@ -42,12 +94,6 @@ namespace GreatHomeChildcare
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: implement
|
||||
internal List<Child> GetChildrenByGuardianID(int guardian_id_in)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#region reports
|
||||
#endregion
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user