public ActionResult Index(InputModel model) { if (ModelState.IsValid) { var parser = new InputParser(); using (var stream = parser.Parse(model)) { var result = new FileStreamResult(stream, "audio/wav"); result.FileDownloadName = model.NumberAsString + ".wav"; } } return View(model); }
public Stream Parse(InputModel model) { var reversedNumber = model.NumberAsString.Reverse(); var parsedModel = new ParsedModel(); var actions = new Dictionary<int, Action<ParsedModel, string>> { {0, (pm, value) => pm.Ones = value}, {1, (pm, value) => pm.Tens = value}, {2, (pm, value) => pm.Hundreds = value}, {3, (pm, value) => pm.Thousands = value}, {4, (pm, value) => pm.TenThousands = value}, {5, (pm, value) => pm.HundredThousands = value}, {6, (pm, value) => pm.Millions = value}, {7, (pm, value) => pm.TenMillions = value}, {8, (pm, value) => pm.HundredMillions = value}, {9, (pm, value) => pm.Billions = value}, {10, (pm, value) => pm.TenBillions = value}, {11, (pm, value) => pm.HundredBillions = value} }; }