Created
March 29, 2017 10:07
-
-
Save eamonnmcevoy/b94b78d8a3ace86f6eb3c1c2e4692dc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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