public ActionResult Tools(string host, FortuneType fortuneType) { if (IsUserLoggedIn() == false) { return(RedirectToLogin(HttpContext.Request.RawUrl)); } var viewModel = new ToolViewModel(); viewModel.Host = host; viewModel.PingResult = Ping(host); viewModel.FortuneResult = Fortune(fortuneType); return(View("Tools", viewModel)); }
private string Fortune(FortuneType fortuneType) { var actualFileName = $"{fortuneType}.txt"; var output = new StringBuilder(); try { var file = HostingEnvironment.MapPath("~/Resources/bin/" + actualFileName); return(System.IO.File.ReadAllText(file)); } catch (Exception ex) { logger.Error(ex); } return(output == null ? "" : output.ToString()); }