public ActionResult Download() { _subtitle = (Subtitle)Session["EditableSubtitle"]; var stream = new SubtitleHandler().WriteSubtitle(_subtitle.Quotes); return File(stream.GetBuffer(), "text/plain", _subtitle.Name); }
public void Translate() { switch (_api) { case Translators.Bing: foreach (var quote in _subtitle.Quotes) quote.QuoteLine = new MicrosoftTranslatorProxy().Translate(BingApiId, quote.QuoteLine, _fromLanguage, _toLanguage, "text/html", "general"); break; case Translators.Google: foreach (var quote in _subtitle.Quotes) quote.QuoteLine = new GoogleTranslatorService().Translate(quote.QuoteLine, _fromLanguage, _toLanguage); break; } var stream = new SubtitleHandler().WriteSubtitle(_subtitle.Quotes); const string message = "This is the subtitle that you translated"; new Mail().SendMail("smtp.gmail.com", 587, "*****@*****.**", _toEmail, "SubRefactor", message, stream, _subtitle.Name); }
public ActionResult LoadSubtitleToSession(HttpPostedFileBase file) { if (file == null || Path.GetExtension(file.FileName) != ".srt") if (Request.UrlReferrer != null) return Redirect(Request.UrlReferrer.AbsoluteUri); else return RedirectToAction("Index", "Home"); var quotes = new SubtitleHandler().ReadSubtitle(file.InputStream); _subtitle = new Subtitle(quotes) { Name = Path.GetFileName((file.FileName)) }; Session["OriginalSubtitle"] = _subtitle; Session["EditableSubtitle"] = _subtitle.Clone(); if (Request.UrlReferrer != null) return Redirect(Request.UrlReferrer.AbsoluteUri); return RedirectToAction("Index", "Home"); }