Пример #1
0
        public static async void SaveOrphan(Orphan inOrphan)
        {
            try
            {
                // Replace this with the API code.
                using (var context = new SMSContext())
                {
                    var updatedOrphan = context.Orphans.Single(c => c.OrphanID == inOrphan.OrphanID);

                    updatedOrphan.OrphanID   = inOrphan.OrphanID;
                    updatedOrphan.FirstName  = inOrphan.FirstName;
                    updatedOrphan.LastName   = inOrphan.LastName;
                    updatedOrphan.MiddleName = inOrphan.MiddleName;
                    updatedOrphan.FullName   = inOrphan.FullName;
                    if (inOrphan.GuardianID != 0)
                    {
                        updatedOrphan.GuardianID = inOrphan.GuardianID;
                    }
                    updatedOrphan.LCMStatus     = inOrphan.LCMStatus;
                    updatedOrphan.ProfileNumber = inOrphan.ProfileNumber;
                    updatedOrphan.Gender        = inOrphan.Gender;
                    updatedOrphan.EntryDate     = inOrphan.EntryDate;
                    updatedOrphan.DateOfBirth   = inOrphan.DateOfBirth;

                    context.Orphans.Update(updatedOrphan);
                    await context.SaveChangesAsync();
                }
            }
            catch (Exception eSql)
            {
                // Your code may benefit from more robust error handling or logging.
                // This logging is just a reminder that you should handle exceptions when connecting to remote data.
                System.Diagnostics.Debug.WriteLine($"Exception: {eSql.Message} {eSql.InnerException?.Message}");
            }
        }
        public static async void SaveAcademic(int orphanID, Academic inAcademic)
        {
            try
            {
                // Replace this with the API code.
                using (var context = new SMSContext())
                {
                    var updatedAcademic = context.Academics.Single(c => c.AcademicID == inAcademic.AcademicID);

                    updatedAcademic.AcademicID = inAcademic.AcademicID;
                    updatedAcademic.OrphanID   = orphanID;
                    updatedAcademic.EntryDate  = inAcademic.EntryDate;
                    updatedAcademic.Grade      = inAcademic.Grade;
                    updatedAcademic.School     = inAcademic.School;
                    updatedAcademic.KCPE       = inAcademic.KCPE;
                    updatedAcademic.KCSE       = inAcademic.KCSE;

                    context.Academics.Update(updatedAcademic);
                    await context.SaveChangesAsync();
                }
            }
            catch (Exception eSql)
            {
                // Your code may benefit from more robust error handling or logging.
                // This logging is just a reminder that you should handle exceptions when connecting to remote data.
                System.Diagnostics.Debug.WriteLine($"Exception: {eSql.Message} {eSql.InnerException?.Message}");
            }
        }
        public static async void SaveNarration(int orphanID, Narration inNarration)
        {
            try
            {
                // Replace this with the API code.
                using (var context = new SMSContext())
                {
                    var updatedNarration = context.Narrations.Single(c => c.NarrationID == inNarration.NarrationID);

                    updatedNarration.NarrationID = inNarration.NarrationID;
                    updatedNarration.OrphanID    = orphanID;
                    updatedNarration.EntryDate   = inNarration.EntryDate;
                    updatedNarration.Subject     = inNarration.Subject;
                    updatedNarration.Note        = inNarration.Note;

                    context.Narrations.Update(updatedNarration);
                    await context.SaveChangesAsync();
                }
            }
            catch (Exception eSql)
            {
                // Your code may benefit from more robust error handling or logging.
                // This logging is just a reminder that you should handle exceptions when connecting to remote data.
                System.Diagnostics.Debug.WriteLine($"Exception: {eSql.Message} {eSql.InnerException?.Message}");
            }
        }
Пример #4
0
 public static async void AddOrphan(Orphan inOrphan)
 {
     try
     {
         // Replace this with the API code.
         using (var context = new SMSContext())
         {
             context.Orphans.Add(inOrphan);
             await context.SaveChangesAsync();
         }
     }
     catch (Exception eSql)
     {
         // Your code may benefit from more robust error handling or logging.
         // This logging is just a reminder that you should handle exceptions when connecting to remote data.
         System.Diagnostics.Debug.WriteLine($"Exception: {eSql.Message} {eSql.InnerException?.Message}");
     }
 }
 public static async void DeleteAcademic(Academic inAcademic)
 {
     try
     {
         // Replace with API code
         using (var context = new SMSContext())
         {
             context.Academics.Remove(inAcademic);
             await context.SaveChangesAsync();
         }
     }
     catch (Exception eSql)
     {
         // Your code may benefit from more robust error handling or logging.
         // This logging is just a reminder that you should handle exceptions when connecting to remote data.
         System.Diagnostics.Debug.WriteLine($"Exception: {eSql.Message} {eSql.InnerException?.Message}");
     }
 }
Пример #6
0
        public static async void DeleteGuardian(Guardian inGuardian)
        {
            //TODO: If you delete a Guardian that has an Orphan, you will need to make sure the Orphan's
            //      Guardian entry is nulled out.

            try
            {
                // Replace with API code
                using (var context = new SMSContext())
                {
                    context.Guardians.Remove(inGuardian);
                    await context.SaveChangesAsync();
                }
            }
            catch (Exception eSql)
            {
                // Your code may benefit from more robust error handling or logging.
                // This logging is just a reminder that you should handle exceptions when connecting to remote data.
                System.Diagnostics.Debug.WriteLine($"Exception: {eSql.Message} {eSql.InnerException?.Message}");
            }
        }