© 2018 Capita Business Services Ltd. All rights reserved.

Capita Education Software Solutions is a trading name of Capita Business Services Ltd. Our Registered office is 30 Berners Street, London, W1T 3LR and our registered number is 02299747. Further information about Capita plc can be found in our legal statement.

Local - Meal Register

Meal / Dinner registers are not available via the third party APIs.  TIs wishing to use this feature would need to use DRAS 'Date Range and Scope' which underpins the SIMS implementation.

This can be slow when used in a manner that is different to how it flows within the SIMS application. 

[That was the major reason for the provision of the third party apis in this section of the code.

 

public XmlDocument GetStudMealTypes()
        {
 
            //DMp.Cache.Populate();
            SIMS.Processes.DinnerMoney.Cache.Populate();
 
            XmlDocument mealTypeListXML = new XmlDocument();
            XmlNode typesNode = mealTypeListXML.CreateElement("MealTypes");
            mealTypeListXML.AppendChild(typesNode);
 
            //foreach (DMe.StudentMealType studMealType in DMe.Cache.GetStudentMealTypes())
            foreach (SIMS.Entities.DinnerMoney.StudentMealType studMealType in SIMS.Entities.DinnerMoney.Cache.GetStudentMealTypes())
                {
                XmlNode typeNode = mealTypeListXML.CreateElement("MealType");
 
                XmlAttribute IDAttribute = mealTypeListXML.CreateAttribute("ID");
                IDAttribute.Value = studMealType.StudentMealTypeID.ToString();
                typeNode.Attributes.Append(IDAttribute);
                typesNode.AppendChild(typeNode);
 
                XmlAttribute codeAttribute = mealTypeListXML.CreateAttribute("Code");
                codeAttribute.Value = studMealType.Code;
                typeNode.Attributes.Append(codeAttribute);
                typesNode.AppendChild(typeNode);
 
                XmlAttribute descAttribute = mealTypeListXML.CreateAttribute("Description");
                descAttribute.Value = studMealType.Description;
                typeNode.Attributes.Append(descAttribute);
                typesNode.AppendChild(typeNode);
 
                XmlAttribute activeAttribute = mealTypeListXML.CreateAttribute("Active");
                activeAttribute.Value = studMealType.Active.ToString();
                typeNode.Attributes.Append(activeAttribute);
                typesNode.AppendChild(typeNode);
            }
 
            return mealTypeListXML;
        }
 
        public bool WriteBackAttendanceDinnerRegister(int personID, DateTime startDate, string mark, string mealCode, int minsLate, string comment)
        {
            // create the DRAS objects 
            SIMS.Processes.DateRangeAndScopeBrowserProcess dateRangeProcessAPM;
            SIMS.Entities.DateRangeAndScope drasAPM;
 
            dateRangeProcessAPM = new SIMS.Processes.DateRangeAndScopeBrowserProcess(DRASScopeTypeEnum.DetailScreen);
            drasAPM = dateRangeProcessAPM.DateRangeAndScope;
            drasAPM.StartDate = startDate.Date;
            drasAPM.EndDate = startDate.Date.AddDays(1).AddMinutes(-1);
            drasAPM.IncludeAcceptedApplicants = true;
            drasAPM.DateSelectionType = SIMS.Entities.DRASDateSelectionTypeEnum.DateOnly;
            drasAPM.PersonID = SIMS.Entities.Cache.CurrentUser.PersonID;
            drasAPM.UserID = SIMS.Entities.Cache.CurrentUser.UserID;
            drasAPM.SelectedScope = new SIMS.Entities.Scope(SIMS.Entities.InformationDomainEnum.StudentAttendance, "INDIVL", "Individual");
            dateRangeProcessAPM.PopulateBrowserGroups();
            drasAPM.SelectedBrowserGroups = dateRangeProcessAPM.BrowserGroups.CreateEmptyCollection();
 
            // create a table for student id
            DataTable dtTable = new DataTable();
            dtTable.Columns.Add("PersonID");
            DataRow row = dtTable.NewRow();
            row["PersonID"] = personID;
 
            // get the student
            SIMS.Entities.ATWAttendee attendee = new SIMS.Entities.ATWAttendee(row, SIMS.Entities.InformationDomainEnum.StudentAttendance);
            dateRangeProcessAPM.DateRangeAndScope.SelectedBrowserGroups.Add(attendee);
 
            SIMS.Processes.EditSessionMarksProcess sessionMarksProcess = new EditSessionMarksProcess();
            sessionMarksProcess.Populate(drasAPM, 0);
            SIMS.Entities.StudentSessionMarks studentSessionMarks = sessionMarksProcess.SessionMarks;
 
            // set what will become xml for the Dinner Register 
            foreach (SIMS.Entities.DinnerMoney.StudentMealTaken studMealTaken in sessionMarksProcess.MealTakens)
            {
                studMealTaken.MealType = (SIMS.Entities.DinnerMoney.StudentMealType)SIMS.Entities.DinnerMoney.Cache.StudentMealTypes.ItemByCode(mealCode);
            }
 
            // set what will become xml for the registration Attendance 
            foreach (SIMS.Entities.StudentSessionMark studentSessionMark in studentSessionMarks)
            {
                if (studentSessionMark.AMPM == "AM")
                {
                    studentSessionMark.Mark = mark;
                    studentSessionMark.MinutesLate = minsLate;
                    studentSessionMark.Comments = comment;
                    break;
                }
            }
 
            if (sessionMarksProcess.SaveChanges())
                return true;
 
            else
            {
                return false;
            }
 
        }