/// <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); } }
/// <summary> /// Will delete a person as teacher from specified class /// </summary> /// <param name="person"></param> /// <param name="newClass"></param> public void DeletePersonAsTeacherFromClass(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 DeleteClassMember in CACCCheckInService"); proxy.DeleteClassMember(classMember); } } catch (Exception ex) { Debug.Assert(View != null); View.ViewDispatcher.BeginInvoke(DispatcherPriority.DataBind, new DispatcherOperationCallback( delegate(object arg) { View.DisplayExceptionDetail(ex); return(null); }), null); } }