Skip to content

Instantly share code, notes, and snippets.

@eamonnmcevoy
Created March 29, 2017 10:07
Show Gist options
  • Save eamonnmcevoy/b94b78d8a3ace86f6eb3c1c2e4692dc5 to your computer and use it in GitHub Desktop.
Save eamonnmcevoy/b94b78d8a3ace86f6eb3c1c2e4692dc5 to your computer and use it in GitHub Desktop.
using System.Text;
using System;
namespace BigLegacyApplication
{
internal class ReportGenerator
{
public ReportGenerator(){}
internal string GetUserReport(int userId)
{
var userService = GetUserService();
var user = userService.GetUser(userId);
var resultsService = GetResultsService();
var results = resultsService.GetUserResults(userId);
var sb = new StringBuilder();
sb.AppendLine(string.Format("{0} {1}", user.Firstname, user.Surname));
sb.AppendLine(string.Join(",", results));
sb.AppendLine(string.Format("Date: {0}", GetNow().ToString()));
return sb.ToString();
}
protected virtual IUserService GetUserService()
{
return new UserService();
}
protected virtual IResultService GetResultsService()
{
return new ResultsService();
}
protected virtual DateTime GetNow()
{
return DateTime.Now;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment