public ActionResult Overlay(string url, int entry) { if (string.IsNullOrEmpty(url)) url = "https://twimg0-a.akamaihd.net/profile_images/769005756/paulstork_foto.png"; //url = "http://museummobile.info/wp-content/uploads/2010/05/NancyPic.png"; using (var db = new DatabaseService()) { string cachefile = @"c:\MWHackathon\Assets\uploaded\" + url.Substring(url.LastIndexOf('/') + 1) + ".json"; string json = ""; if (System.IO.File.Exists(cachefile)) json = System.IO.File.ReadAllText(cachefile); else { json = db.FacialData(url); System.IO.File.WriteAllText(cachefile, json); } var upFaces = new Faces(json, url, null, null); int amount = upFaces.Amount; if (amount < 1) { Response.Write("Darn, I can't find a face in there! Please go back and try a different one."); return new EmptyResult(); } if (amount > 1) { Response.Write("Sorry, this one seems to have multiple faces. I haven't built that yet. Please go back and try a different one."); return new EmptyResult(); } var dbEntry = db.GetAllEntries().First(e => e.id == entry); var dbFace = GetFace(dbEntry); var rnd = new Random(); var allentries = GetEntries(db, amount); var dbNextEntry = allentries.ElementAt(rnd.Next(0,allentries.Count)); var dbNextFace = GetFace(dbNextEntry); ViewBag.Entry = dbEntry; ViewBag.Faces = upFaces; ViewBag.NextFace = dbNextEntry; return View(dbFace); } }