예제 #1
0
 public IList <Data.School.Model.School> GetSchools()
 {
     using (var uow = Read())
     {
         var da = new SchoolDataAccess(uow);
         return(da.GetAll());
     }
 }
예제 #2
0
 public void Delete(IList <int> localIds, Guid districtId)
 {
     BaseSecurity.EnsureSysAdmin(Context);
     using (var uow = Update())
     {
         var da      = new SchoolDataAccess(uow);
         var schools = da.GetSchools(districtId, 0, int.MaxValue).ToList();
         schools = schools.Where(x => localIds.Contains(x.LocalId)).ToList();
         da.Delete(schools.Select(x => x.Id).ToList());
         uow.Commit();
     }
 }
예제 #3
0
 public Data.Master.Model.School GetById(Guid districtRef, int localId)
 {
     using (var uow = Read())
     {
         var da = new SchoolDataAccess(uow);
         return(da.GetAll(
                    new AndQueryCondition
         {
             new SimpleQueryCondition(Data.Master.Model.School.DISTRICT_REF_FIELD, districtRef, ConditionRelation.Equal),
             new SimpleQueryCondition(Data.Master.Model.School.LOCAL_ID_FIELD, localId, ConditionRelation.Equal)
         }
                    )
                .First());
     }
 }
예제 #4
0
 private void ModifySchool(Action <SchoolDataAccess> modifySchool, Action <Master.ISchoolService, Guid> modifyMasterSchool)
 {
     if (Context.Role.Id != CoreRoles.SUPER_ADMIN_ROLE.Id)
     {
         throw new ChalkableSecurityException();
     }
     if (!Context.DistrictId.HasValue)
     {
         throw new UnassignedUserException();
     }
     using (var uow = Update())
     {
         var da = new SchoolDataAccess(uow);
         modifySchool(da);
         uow.Commit();
     }
     modifyMasterSchool(ServiceLocator.ServiceLocatorMaster.SchoolService, Context.DistrictId.Value);
 }
예제 #5
0
 public void Edit(IList <SchoolInfo> schoolInfos, Guid districtId)
 {
     BaseSecurity.EnsureSysAdmin(Context);
     using (var uow = Update())
     {
         var da      = new SchoolDataAccess(uow);
         var schools = da.GetSchools(districtId, 0, int.MaxValue).ToList();
         schools = schools.Where(x => schoolInfos.Any(y => y.LocalId == x.LocalId)).ToList();
         foreach (var school in schools)
         {
             var si = schoolInfos.FirstOrDefault(x => x.LocalId == school.LocalId);
             if (si != null)
             {
                 school.IsChalkableEnabled = si.IsChalkableEnabled;
                 school.IsLESyncComplete   = si.IsLESyncComplete;
                 school.IsLEEnabled        = si.IsLEEnabled;
                 school.Name = si.Name;
             }
         }
         da.Update(schools);
         uow.Commit();
     }
 }