Beispiel #1
0
        /// <summary>
        /// Converts the value of the specified <see cref="TrainingCourseType"/> to its equivalent <see cref="String"/> representation.
        /// </summary>
        /// <param name="type">A CFB training course type.</param>
        /// <returns>The <see cref="String"/> equivalent of the value of <paramref name="type"/>.</returns>
        public static string ToString(TrainingCourseType type)
        {
            switch (type)
            {
            case TrainingCourseType.AdvancedCsmart:
                return("Advanced C-SMART Training");

            case TrainingCourseType.Combined:
                return("Combined Compliance and C-SMART Training");

            case TrainingCourseType.Compliance:
                return("Compliance Training Only");

            case TrainingCourseType.Csmart:
                return("C-SMART Training Only");

            case TrainingCourseType.Supplemental:
                return("Supplemental Training");

            case TrainingCourseType.Audit:
                return("Audit Training");

            case TrainingCourseType.CsmartWeb:
                return("C-SMART Web Training");

            case TrainingCourseType.CombinedWeb:
                return("Combined Compliance and C-SMART Web Training");

            default:
                return(string.Empty);
            }
        }
        public static TrainingCourseViewModel TrainingCourseFrom(TrainingStatus source, TrainingCourseType courseType, DateTime cutoffDate)
        {
            if (source == null)
            {
                return(new TrainingCourseViewModel
                {
                    Trainees = new List <TraineeViewModel>()
                });
            }
            var sessions = courseType == TrainingCourseType.Unknown ? source.Sessions.Sessions.Values.AsEnumerable() : source.Sessions[courseType];

            return(new TrainingCourseViewModel
            {
                CourseType = courseType,
                Trainees = from t in source.Trainees.Values
                           select new TraineeViewModel
                {
                    Name = t.Name,
                    Relationship = t.CampaignRelationship,
                    Sessions = from r in source.Registrations.Registrations
                               join s in sessions on r.SessionID equals s.ID
                               where r.TraineeID == t.ID
                               select new TrainingSessionViewModel
                    {
                        Attended = s.Date.Date > cutoffDate ? null : (bool?)r.Attended,
                        Completed = s.Date.Date > cutoffDate ? null : (bool?)r.Completed,
                        AchievesCompliance = source.ComplianceAchievedBy(r),
                        Date = s.Date
                    }
                }
            });
        }
Beispiel #3
0
 /// <summary>
 /// Retrieves a collection of registrations completed by a specific trainee for a specific type of training course.
 /// </summary>
 /// <param name="trainee">The trainee to search by.</param>
 /// <param name="type">The type of training course to search by.</param>
 /// <returns>A collection of registrations completed by the trainee specified and for the type of training course specified.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="trainee"/> is null.</exception>
 public IEnumerable <TrainingRegistration> GetCompletedRegistrationsBy(Trainee trainee, TrainingCourseType type)
 {
     if (trainee == null)
     {
         throw new ArgumentNullException("trainee", "Trainee must not be null.");
     }
     return(from r in _registrations.Registrations
            where r.Completed && r.TraineeID == trainee.ID
            join s in
            (from s in _sessions.Sessions.Values
             where s.CourseType == type
             select s) on r.SessionID equals s.ID
            select r);
 }
Beispiel #4
0
 /// <summary>
 /// Converts the value of the specified <see cref="TrainingCourseType"/> to its equivalent <see cref="String"/> representation.
 /// </summary>
 /// <param name="type">A CFB training course type.</param>
 /// <returns>The <see cref="String"/> equivalent of the value of <paramref name="type"/>.</returns>
 public static string ToString(this TrainingCourseType type)
 {
     return(CPConvert.ToString(type));
 }
Beispiel #5
0
 /// <summary>
 /// Gets a collection of all training sessions of a specific training course type.
 /// </summary>
 /// <param name="type">The type of training sessions to retrieve.</param>
 /// <returns>A collection of all training sessions for the campaign of type <paramref name="type"/>.</returns>
 public List <TrainingSession> this[TrainingCourseType type]
 {
     get { return(_sessions.Values.Where(s => s.CourseType == type).ToList()); }
 }