コード例 #1
0
        public void UpdateTranscripts(List <AcademicTranscript> transcripts)
        {
            var ids     = transcripts.Select(t => t.Id).ToList();
            var origins = repository.GetTranscripts(ids);

            if (origins.Count != transcripts.Count)
            {
                throw new Exception("Wrong infomation of transcript");
            }
            Dictionary <int, AcademicTranscript> originMap = new Dictionary <int, AcademicTranscript>();

            origins.ForEach(at => originMap.Add(at.Id, at));
            transcripts.ForEach(at =>
            {
                AcademicTranscript origin = null;
                if (originMap.TryGetValue(at.Id, out origin))
                {
                    origin.Score = at.Score;
                }
                else
                {
                    throw new Exception("Not found a specific row of transcript");
                }
            });
            repository.UpdateTranscripts(origins);
        }