Beispiel #1
0
        public static List <Guid> AddPupil(string legalForename, string legalSurname, Date dateOfBirth, string genderCode)
        {
            //New Instance of PupilQuery
            PupilQuery pupilQuery = new PupilQuery();

            //Security Token
            SecurityToken sessionToken = pupilQuery.Login(TestDefaults.Default.SchoolAdministrator,
                                                          TestDefaults.Default.SchoolAdministratorPassword,
                                                          TestDefaults.Default.SchoolID,
                                                          TestDefaults.Default.TenantId.ToString(CultureInfo.InvariantCulture),
                                                          Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath,
                                                          Configuration.GetSutUrl() + TestDefaults.Default.SecurityServerPath);

            //Retrieved collection of Pupil Records
            DataEntityCollectionDTO pupilCollection = pupilQuery.RetrieveEntityByNameQuery("SIMS8PupilSearchQuery", new Dictionary <string, object>(), sessionToken);

            int pupilCollectionCount = pupilCollection.DataEntityDtos.Count;

            Guid pupilID = Guid.NewGuid();

            //Retrieve collection of Genders
            DataQuery genderQuery = CreateStandardQuery("Gender", "dbo");

            genderQuery.SelectedElements = new Dictionary <string, QuerySelectionElementBase>
            {
                { "Gender.Code", new QuerySelectionField {
                      SymbolName = "Gender.Code"
                  } }
            };
            genderQuery.Filter = new AndExpression
            {
                Expressions = new List <object> {
                    new EqualsExpression
                    {
                        CurrentValue = new ParameterValue
                        {
                            SymbolName     = "Gender.Code",
                            SymbolTypeName = "iSIMS.Common.DataTypes.String"
                        },
                        TestValue = new InputParameterValue
                        {
                            SymbolName     = "GenderCode",
                            SymbolTypeName = typeof(string).FullName
                        }
                    }
                }
            };

            var parameters = new Dictionary <string, object>()
            {
                { "GenderCode", genderCode }
            };

            DataEntityCollectionDTO genderCollection = pupilQuery.RetrieveEntityByQuery(genderQuery, parameters, sessionToken);
            DataEntityDTO           gender           = genderCollection.DataEntityDtos.FirstOrDefault().Value;

            //Create the Pupil Record
            DataEntityDTO pupil = pupilQuery.CreatePupil(pupilID,
                                                         legalForename,
                                                         legalSurname,
                                                         dateOfBirth,
                                                         gender.ID,
                                                         Guid.Parse(TestDefaults.Default.SchoolID),
                                                         pupilCollectionCount,
                                                         pupilCollection.ExtensionData);

            //Add the Pupil Record to the collection
            pupilCollection.DataEntityDtos.Add(pupilCollectionCount, pupil);
            pupilCollection.TopLevelDtoIDs.Add(pupilCollectionCount);

            //Save Scope for Pupil
            List <string> pupilSaveScope = new List <string>
            {
                "Learner.ID",
                "Learner.LegalForename",
                "Learner.LegalSurname",
                "Learner.DateOfBirth",
                "Learner.Gender",
                "Learner.School"
            };

            //Save the modified collection
            pupilQuery.Save(pupilCollection, sessionToken, Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath, pupilSaveScope);

            return(new List <Guid> {
                pupilID
            });
        }
Beispiel #2
0
        public static Guid AddStandardPupilLogNote(Guid learnerID, string title, string noteText, string categoryCode, bool pinned, string userName = "******")
        {
            //New Instance of PupilQuery
            PupilQuery pupilQuery = new PupilQuery();

            //Security Token
            SecurityToken sessionToken = pupilQuery.Login(TestDefaults.Default.SchoolAdministrator,
                                                          TestDefaults.Default.SchoolAdministratorPassword,
                                                          TestDefaults.Default.SchoolID,
                                                          TestDefaults.Default.TenantId.ToString(CultureInfo.InvariantCulture),
                                                          Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath,
                                                          Configuration.GetSutUrl() + TestDefaults.Default.SecurityServerPath);

            //Retrieve collection of Pupil Log Notes
            DataQuery noteQuery = CreateStandardQuery("PupilLogNoteStandard", "dbo");

            noteQuery.SelectedElements = new Dictionary <string, QuerySelectionElementBase>
            {
                { "PupilLogNoteStandard.Title", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.Title"
                  } },
                { "PupilLogNoteStandard.NoteText", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.NoteText"
                  } },
                { "PupilLogNoteStandard.Pinned", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.Pinned"
                  } },
                { "PupilLogNoteStandard.CreatedOn", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.CreatedOn"
                  } },
                { "PupilLogNoteStandard.CreatedByUserId", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.CreatedByUserId"
                  } },
                { "PupilLogNoteStandard.Learner", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.Learner"
                  } },
                { "PupilLogNoteStandard.PupilLogNoteCategory", new QuerySelectionField {
                      SymbolName = "PupilLogNoteStandard.PupilLogNoteCategory"
                  } }
            };
            noteQuery.Filter = new AndExpression {
                Expressions = new List <object>()
            };
            var parameters = new Dictionary <string, object>();
            DataEntityCollectionDTO noteCollection = pupilQuery.RetrieveEntityByQuery(noteQuery, parameters, sessionToken);

            var category      = GetNoteCategory(pupilQuery, sessionToken, categoryCode);
            var createdByUser = GetUser(pupilQuery, sessionToken, userName);
            int pupilLogNoteCollectionCount = noteCollection.DataEntityDtos.Count;

            Guid pupilLogNoteID = Guid.NewGuid();

            //Create the PupilLog Note
            DataEntityDTO pupilLogNote = pupilQuery.CreateStandardPupilLogNote(pupilLogNoteID,
                                                                               title,
                                                                               noteText,
                                                                               learnerID,
                                                                               category.ID,
                                                                               createdByUser.ID,
                                                                               pinned,
                                                                               category.ReferenceID,
                                                                               pupilLogNoteCollectionCount,
                                                                               noteCollection.ExtensionData);

            noteCollection.DataEntityDtos.Add(pupilLogNoteCollectionCount, pupilLogNote);
            noteCollection.TopLevelDtoIDs.Add(pupilLogNoteCollectionCount);

            //Save Scope for Pupil Log Note
            List <string> pupilLogNoteSaveScope = new List <string>
            {
                "PupilLogNoteStandard.ID",
                "PupilLogNoteStandard.Title",
                "PupilLogNoteStandard.NoteText",
                "PupilLogNoteStandard.Pinned",
                "PupilLogNoteStandard.CreatedOn",
                "PupilLogNoteStandard.CreatedByUserId",
                "PupilLogNoteStandard.Learner",
                "PupilLogNoteStandard.PupilLogNoteCategory"
            };

            //Save the modified collection
            pupilQuery.Save(noteCollection, sessionToken, Configuration.GetSutUrl() + TestDefaults.Default.ApplicationServerPath, pupilLogNoteSaveScope);

            return(pupilLogNoteID);
        }