Example #1
0
        public void FixClassPersonInsert()
        {
            var districtIds = new List <Guid>
            {
                Guid.Parse("69b1f18e-333e-4aa8-83d5-2647edea4a48"),
            };

            ForEachDistrict(districtIds, delegate(District d, ConnectorLocator cl, UnitOfWork u)
            {
                var da   = new ClassPersonDataAccess(u);
                var inDb = da.GetAll();

                var new_ = (cl.SyncConnector.GetDiff(typeof(StudentScheduleTerm), 25063934) as SyncResult <StudentScheduleTerm>).Inserted;

                var toDELETE =
                    inDb.Where(
                        x =>
                        new_.Any(
                            y =>
                            x.PersonRef == y.StudentID && x.ClassRef == y.SectionID &&
                            x.MarkingPeriodRef == y.TermID)).ToList();


                toDELETE.ForEach(x => Debug.WriteLine($"{x.PersonRef} {x.ClassRef} {x.MarkingPeriodRef}"));
                da.Delete(toDELETE);
            });
        }
        public void SendMessageToClass(int classId, string subject, string body)
        {
            if (!CanSendMessageToClass(classId))
            {
                throw new ChalkableSecurityException("Current user have no right for sending message to class");
            }

            using (var uow = Update())
            {
                var studentsIds = new ClassPersonDataAccess(uow).GetClassPersons(classId).Select(cp => cp.PersonRef).Distinct().ToList();
                if (studentsIds.Count == 0)
                {
                    throw new ChalkableException("Invalid classId param. Selected class has no students.");
                }
                var messageId = CreatePrivateMessage(studentsIds, classId, subject, body, uow);
                uow.Commit();
                ServiceLocator.NotificationService.AddPrivateMessageNotification(messageId);
            }
        }