/// <summary> /// Les Cours dont le Proff est designer Correcteur /// </summary> /// <returns></returns> public IEnumerable GetStaffScoringWork(Guid staffGuid, DateTime?startDate = null, DateTime?endDate = null) { using (var db = new SchoolContext()) { // ReSharper disable once InvertIf if (startDate == null || endDate == null) { startDate = DateTime.Today.AddMonths(-1); endDate = DateTime.Today; } return(db.Studies.Where(c => c.GraderGuid == staffGuid && !c.IsDeleted && (( c.StartDate <= startDate && c.EndDate >= startDate ) || ( c.StartDate >= startDate && c.StartDate <= endDate ))).OrderByDescending(c => c.StartDate) .ThenBy(c => c.StartTime) .Include(c => c.Classe) .Include(c => c.Subject) .ToList() .Where(s => CoursHelper.IsGraded(s.Type)) .Select(s => new DataCard(s))); } }
/// <summary> /// Determine si le Staff a aucune Tache Active /// </summary> /// <param name="profileGuid"></param> /// <returns></returns> public bool HasAnyJob(Guid profileGuid) { if ( GetStaffSupervisionBetween(profileGuid, DateTime.Today, DateTime.Today) .Any(study => StaticGetCoursEvents(study.StudyGuid, DateTime.Today, DateTime.Today).Any())) { return(true); } using (var db = new SchoolContext()) return(db.Studies.Where(c => c.GraderGuid == profileGuid && !c.IsDeleted && (( c.StartDate <= DateTime.Today && c.EndDate >= DateTime.Today ) || ( c.StartDate >= DateTime.Today && c.StartDate <= DateTime.Today ))).ToList().Any(s => CoursHelper.IsGraded(s.Type))); }
public bool AddCours(Study myStudy) { using (var db = new SchoolContext()) { if (db.Classes.Find(myStudy.ClasseGuid) == null) { throw new InvalidOperationException("CLASSE_NOT_FOUND"); } if (db.Staffs.Find(myStudy.ProffGuid) == null) { throw new InvalidOperationException("STAFF_NOT_FOUND"); } var recDays = CoursHelper.DecodeRecurrence(myStudy.RecurrenceDays); if (!StaticIsClasseFree(myStudy.ClasseGuid, recDays, myStudy.StartDate.GetValueOrDefault(), myStudy.EndDate.GetValueOrDefault(), myStudy.StartTime, myStudy.EndTime)) { throw new InvalidOperationException("CLASSE_IS_NOT_FREE"); } if (!StaticIsStaffFree(myStudy.ProffGuid, recDays, myStudy.StartDate.GetValueOrDefault(), myStudy.EndDate.GetValueOrDefault(), myStudy.StartTime, myStudy.EndTime)) { throw new InvalidOperationException("STAFF_IS_NOT_FREE"); } if (!StaticIsSalleFree(myStudy.Room, recDays, myStudy.StartDate.GetValueOrDefault(), myStudy.EndDate.GetValueOrDefault(), myStudy.StartTime, myStudy.EndTime)) { throw new InvalidOperationException("CLASSROOM_IS_NOT_FREE"); } if (!StaticGetCoursEvents(myStudy, null, null).Any()) { throw new InvalidOperationException("COURS_WITH_NO_OCCURRENCE"); } if (CoursHelper.IsGraded(myStudy.Type)) { myStudy.EndDate = myStudy.StartDate; myStudy.RecurrenceDays = ((int)myStudy.StartDate.GetValueOrDefault().DayOfWeek).ToString(); } if (myStudy.StudyGuid == Guid.Empty) { myStudy.StudyGuid = Guid.NewGuid(); } if (myStudy.GraderGuid == null || myStudy.GraderGuid == Guid.Empty) { myStudy.GraderGuid = myStudy.ProffGuid; } if (myStudy.SupervisorGuid == null || myStudy.SupervisorGuid == Guid.Empty) { myStudy.SupervisorGuid = myStudy.ProffGuid; } if (!string.IsNullOrEmpty(myStudy.Room)) { myStudy.Room = myStudy.Room.Trim(); } db.Studies.Add(myStudy); return(db.SaveChanges() > 0); } }