using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Hosting;
using System.Web.Mvc;

namespace HelperService.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return Content("Online " + DateTime.Now.ToLongTimeString());
        }

        public ActionResult Echo(string m, int? d)
        {
            Thread.Sleep(d ?? 0);

            return Content(m);

        }

        public ActionResult CreditReport(string agency) {
            //pretend this is a high-latency operation, possibly
            // involving a call to a credit agency web service
            Thread.Sleep(500);
            return this.File(HostingEnvironment.MapPath(@"~/Content/data/" + agency + ".js"),
                             "application/json",
                             "credit-" + agency + ".js");
        }

    }
}
