public string Merge(Command.Infrastructure.Models.Command command) { var authors = command.Args.Split(' '); var statistic = storage.Get(); if (CheckAuthors(authors, statistic) != null) { return(CheckAuthors(authors, statistic)); } var mergeModel = ParseMergeModel(authors, statistic); if (mergeModel.ErrorMessage != null) { return(mergeModel.ErrorMessage); } var commits = statistic.Commits .Select(commit => mergeModel.Duplicates.Contains(commit.Author.Id) ? new Commit(commit.Name, mergeModel.MainAuthor, commit.Insertions, commit.Deletions, commit.Date) : commit).ToList(); var newStatistic = new StatisticCalculationHelper(commits).Calculte(); storage.Save(newStatistic); return(ReportBuilder.BuildReport(newStatistic)); }
public string Execute(_Command command) { var statistic = GetStatistic(command); statisticStorage.Save(statistic); return(reportBuilder.BuildReport(statistic)); }