public void MoveNode(string userDetailsId, string toNodeType, string toNodeName) { int userId = int.Parse(userDetailsId); var userToMove = JournalContext.UserDetails.FirstOrDefault(ud => ud.GlobalProfileID == userId); var userProfile = UsersContext.UserProfiles.FirstOrDefault(u => u.UserId == userId); if (userToMove == null) return; switch (toNodeType) { case JsTreeNodeType.PupilClass: var newPupil = new Pupil { PupilID = userId, JournalID = int.Parse(toNodeName) }; JournalContext.Pupils.InsertOnSubmit(newPupil); JournalContext.SubmitChanges(); Roles.AddUserToRole(userProfile.UserName, JournalStatic.Pupil); break; case JsTreeNodeType.Teachers: var newTeacher = new Teacher {TeacherID = userId}; JournalContext.Teachers.InsertOnSubmit(newTeacher); JournalContext.SubmitChanges(); Roles.AddUserToRole(userProfile.UserName, JournalStatic.Teacher); break; case JsTreeNodeType.Parents: var newParent = new Parent {ParentID = userId}; JournalContext.Parents.InsertOnSubmit(newParent); JournalContext.SubmitChanges(); Roles.AddUserToRole(userProfile.UserName, JournalStatic.Parent); break; } }
partial void DeleteParent(Parent instance);
partial void InsertParent(Parent instance);
partial void UpdateParent(Parent instance);
private void detach_Parents(Parent entity) { this.SendPropertyChanging(); entity.UserDetails = null; }