public ActionResult Edit(int id, ExceptionGroupEditModel exceptionGroupEditModel)
        {
            ExceptionGroupRepository exceptionGroupRepository = new ExceptionGroupRepository();

            exceptionGroupRepository.Save(id, exceptionGroupEditModel.UserComment, exceptionGroupEditModel.UserFixedInCommitHash);
            return(RedirectToAction("Edit", id));
        }
        public ExceptionGroupEditModel GetExceptionGroupById(int id)
        {
            // get details for the exception group
            ExceptionGroupEditModel editModel = EvaluateQuery(
                from ex in _db.ExceptionGroups
                where ex.ExceptionGroupId == id
                let commits = (
                    from e in ex.Exceptions
                    let s = e.Session
                            where s.CommitId != null
                            select s.Commit
                    )
                              select new ExceptionGroupEditModel {
                ExceptionFingerprint    = ex.ExceptionFingerprint,
                ExceptionGroupId        = ex.ExceptionGroupId,
                ExceptionLocation       = ex.ExceptionLocation,
                ExceptionType           = ex.ExceptionType,
                UserComment             = ex.UserComment,
                UserFixedInCommitId     = ex.UserFixedInCommitId,
                FirstOccurrenceCommitId = commits.OrderBy(c => c.CommitDate).FirstOrDefault().Id,
                LastOccurrenceCommitId  = commits.OrderByDescending(c => c.CommitDate).FirstOrDefault().Id
            }).Single();

            // get friendly names for the commits
            List <int> interestingCommitIds = new List <int>();

            interestingCommitIds.Add(editModel.FirstOccurrenceCommitId);
            interestingCommitIds.Add(editModel.LastOccurrenceCommitId);
            if (editModel.UserFixedInCommitId != null)
            {
                interestingCommitIds.Add((int)editModel.UserFixedInCommitId);
            }

            var scm = SourceControlRepository.GetCached();
            var map = CreateCommitIdToVersionMap(interestingCommitIds);

            editModel.FirstOccurrenceCommitHash = scm.GetCommitById(editModel.FirstOccurrenceCommitId).Hash;
            editModel.FirstOccurrenceCommit     = map.GetValueOrDefault(editModel.FirstOccurrenceCommitId);
            editModel.LastOccurrenceCommitHash  = scm.GetCommitById(editModel.LastOccurrenceCommitId).Hash;
            editModel.LastOccurrenceCommit      = map.GetValueOrDefault(editModel.LastOccurrenceCommitId);

            if (editModel.UserFixedInCommitId != null)
            {
                editModel.UserFixedInCommitHash = scm.GetCommitById((int)editModel.UserFixedInCommitId).Hash;
                editModel.UserFixedInCommit     = map.GetValueOrDefault((int)editModel.UserFixedInCommitId) ?? editModel.UserFixedInCommitHash.Truncate(8);
            }

            // get statistics about this exception
            editModel.CrashProbabilities = GetCrashStatisticsForExceptionGroup(id);

            // get details about the exception instances
            editModel.Exceptions = EvaluateQuery((
                                                     from ex in _db.Exceptions
                                                     where ex.ExceptionGroupId == editModel.ExceptionGroupId && ex.IsFirstInSession
                                                     orderby ex.ThrownAt descending
                                                     let session = ex.Session
                                                                   select new ExceptionModel {
                ThrownAt = ex.ThrownAt,
                Stacktrace = ex.Stacktrace,
                UserId = session.UserId,
                Environment =
                    from ed in session.EnvironmentDatas
                    select new EnvironmentDataModel {
                    Name = ed.EnvironmentDataName.EnvironmentDataName1,
                    Value = ed.EnvironmentDataValue.EnvironmentDataValue1
                },
                PreviousFeatureUses = (
                    from fu in session.FeatureUses
                    where fu.UseTime <= ex.ThrownAt
                    orderby fu.UseTime descending
                    select new ExceptionModelFeatureUse {
                    UseTime = fu.UseTime,
                    ActivationMethod = fu.ActivationMethod.ActivationMethodName,
                    FeatureName = fu.Feature.FeatureName
                }
                    ).Take(5)
            }
                                                     ).Take(20)
                                                 );
            return(editModel);
        }