Scenario: There are three views (Razor) named "InvoiceBill", "Index", "Create".
- The Create view contains the form page for entering Invoice data.
- The Index page contains the list of all current date invoice bills.
- The InvoiceBill contains the code which generate the excel document (as an invoice report) based on this link (http://forums.asp.net/t/1711971.aspx/1).
Once i submit the form (Create view) it can post the form data to the DB (using EF). After the data inserted, it returns the Index page.
But now i need to call the "InvoiceBill" view before calling Index page.
[HttpPost]
public ActionResult Create(FormCollection collection, InvoiceViewModel INVViewModel)
{
   if ((collection != null) && (this.ModelState.IsValid))
   {
        salesOrder.AccountNumber = INVViewModel.AccountNumber;
        salesOrder.BillToAddressID = INVViewModel.BillToAddressID;
        salesOrder.Comment = INVViewModel.Comment;
        salesOrder.ContactID = INVViewModel.ContactID;
        .
        .
        .
        .
        int sID = Using<CreateSalesOrder>().Execute(0, salesOrder);
***** From here i need to call the InvoiceBill page. Or guide me any other good way to achieve this
        return RedirectToAction("Index");
   }
}
Right now i am achieving this with some workarounds. But i feel that is not good. Please guide me how can i achieving this in a right way? Thanks
EDIT:
public ActionResult PrintInvoice(int id)
        {
            InvoiceReportViewModel invoiceReport = new InvoiceReportViewModel();
            var soToView = Using<GetSalesOrders>().ExecuteForReport(id);
            invoiceReport.InvoiceBillName = "Invoice" + id.ToString();
            invoiceReport.CustomerName = soToView.Customer.Name;
            invoiceReport.SalesOrderNumber = soToView.SalesOrderNumber;
            .
            .
            .
            .
            return View(invoiceReport);
        }
The InvoiceReport.cshtml
@model eItemBox.Web.Models.InvoiceReportViewModel
@{
    Layout = null;
    Response.ContentType = "application/vnd.ms-excel";
    Response.AddHeader("Content-Disposition", "attachment; filename=" + Model.InvoiceBillName);
    //Content-Disposition is defined in RFC-2183
}
<Worksheet ss:Name="MyInvoice">
.
.
.
</Workbook>
 
     
    