コード例 #1
0
ファイル: TrainingService.cs プロジェクト: hahn-kev/gis
        public void MarkAllComplete(List <Guid> staffIds, Guid requirementId, DateTime completeDate)
        {
            var existingTrainings = StaffTraining.Where(training =>
                                                        training.TrainingRequirementId == requirementId && staffIds.Contains(training.StaffId) &&
                                                        training.CompletedDate.Value.InSchoolYear(completeDate.SchoolYear())).ToList();

            if (existingTrainings.Any())
            {
                staffIds.RemoveAll(id => existingTrainings.Any(training => training.StaffId == id));
            }

            _trainingRepository.InsertAll(staffIds.Select(staffId => new StaffTraining
            {
                Id                    = Guid.NewGuid(),
                CompletedDate         = completeDate,
                StaffId               = staffId,
                TrainingRequirementId = requirementId
            }));
        }