/// <summary>
        ///
        /// </summary>
        /// <param name="classMember"></param>
        public void InsertClassMember(CACCCheckInDb.ClassMember classMember)
        {
            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                proxy.InsertClassMember(classMember);
            }
        }
        /// <summary>
        /// Will add a person to class
        /// </summary>
        /// <param name="person"></param>
        private void AddPersonClassMembership(CACCCheckInDb.PeopleWithDepartmentAndClassView person)
        {
            logger.DebugFormat("Adding class membership for [{0} {1}]",
                               person.FirstName, person.LastName);

            // Get a reference to ClassMember record for current person
            CACCCheckInDb.ClassMember newClassMember = (CACCCheckInDb.ClassMember)person;

            using (CACCCheckInServiceProxy proxy =
                       new CACCCheckInServiceProxy())
            {
                proxy.Open();

                logger.Debug("Calling InsertClassMember in CACCCheckInService");
                proxy.InsertClassMember(newClassMember);
            }
        }
        /// <summary>
        /// Will move a person from current class to new class
        /// </summary>
        /// <param name="person"></param>
        /// <param name="newClass"></param>
        public void UpdatePersonClassMembership(CACCCheckInDb.PeopleWithDepartmentAndClassView person,
                                                CACCCheckInDb.Class newClass)
        {
            try
            {
                logger.DebugFormat("Updating class membership for [{0} {1}]",
                                   person.FirstName, person.LastName);

                // Get a reference to ClassMember record for current person
                CACCCheckInDb.ClassMember oldClassMember = (CACCCheckInDb.ClassMember)person;
                // Create a new ClassMember record to move current person to new class
                CACCCheckInDb.ClassMember newClassMember = new CACCCheckInDb.ClassMember();
                // The new ClassId is used along with current ClassRole and PersonId
                newClassMember.ClassId   = newClass.Id;
                newClassMember.ClassRole = oldClassMember.ClassRole;
                newClassMember.PersonId  = oldClassMember.PersonId;

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    logger.Debug("Calling DeleteClassMember in CACCCheckInService");
                    proxy.DeleteClassMember(oldClassMember);

                    logger.Debug("Calling InsertClassMember in CACCCheckInService");
                    proxy.InsertClassMember(newClassMember);
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Will add a person as teacher to specified class
        /// </summary>
        /// <param name="person"></param>
        /// <param name="newClass"></param>
        public void AddPersonAsTeacherToClass(CACCCheckInDb.PeopleWithDepartmentAndClassView person,
                                              CACCCheckInDb.Class theClass)
        {
            try
            {
                logger.DebugFormat("Updating class membership for [{0} {1}]",
                                   person.FirstName, person.LastName);

                // Get a reference to ClassMember record for current person
                CACCCheckInDb.ClassMember classMember = (CACCCheckInDb.ClassMember)person;

                // The ClassId is used along with ClassRole to update ClassMember record
                classMember.ClassId   = theClass.Id;
                classMember.ClassRole = ClassRoles.Teacher;

                using (CACCCheckInServiceProxy proxy =
                           new CACCCheckInServiceProxy())
                {
                    proxy.Open();

                    logger.Debug("Calling InsertClassMember in CACCCheckInService");
                    proxy.InsertClassMember(classMember);
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(View != null);
                View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind,
                                                new DispatcherOperationCallback(
                                                    delegate(object arg)
                {
                    View.DisplayExceptionDetail(ex);
                    return(null);
                }), null);
            }
        }