public IList <Date> GetLastDays(int schoolYearId, bool schoolDaysOnly, DateTime?fromDate, DateTime?tillDate, int count = Int32.MaxValue)
 {
     using (var uow = Read())
     {
         var da = new DateDataAccess(uow);
         return(da.GetDates(new DateQuery
         {
             SchoolYearId = schoolYearId,
             FromDate = fromDate,
             ToDate = tillDate,
             Count = count,
             SchoolDaysOnly = schoolDaysOnly
         }));
     }
 }
Exemple #2
0
        public void FixBellScheduleDelete(Guid districtid)
        {
            District d;
            var      mcs = "Data Source=yqdubo97gg.database.windows.net;Initial Catalog=ChalkableMaster;UID=chalkableadmin;Pwd=Hellowebapps1!";

            using (var uow = new UnitOfWork(mcs, false))
            {
                var da = new DistrictDataAccess(uow);
                d = da.GetById(districtid);
            }

            var cs = String.Format("Data Source={0};Initial Catalog={1};UID=chalkableadmin;Pwd=Hellowebapps1!", d.ServerUrl, d.Id);
            IList <SyncVersion> versions;

            using (var uow = new UnitOfWork(cs, true))
            {
                versions = (new SyncVersionDataAccess(uow)).GetAll();
                uow.Commit();
            }

            var cl = ConnectorLocator.Create("Chalkable", d.SisPassword, d.SisUrl);
            var deletedBellSchedules = (cl.SyncConnector.GetDiff(typeof(BellSchedule), versions.First(x => x.TableName == "BellSchedule").Version) as SyncResult <BellSchedule>).Deleted;

            using (var uow = new UnitOfWork(cs, true))
            {
                var da    = new DateDataAccess(uow);
                var all   = da.GetAll();
                var dates = all.Where(x => deletedBellSchedules.Any(y => x.BellScheduleRef == y.BellScheduleID)).ToList();
                foreach (var date in dates)
                {
                    date.BellScheduleRef = null;
                }
                da.Update(dates.ToList());
                uow.Commit();
            }
        }