コード例 #1
0
        /// <summary>
        /// Generates the view for the GetApplicationAsWordDocument action.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>The action result for the view.</returns>
        public ActionResult Export(int id)
        {
            var model = this.GetDetailsViewModel(id);

            ViewBag.Title = "Export";

            var htmlResult = this.RenderActionResultToString(View("Export", model));

            //get program year description for file name
            var criteria = new ProviderApplicationDTO();

            criteria.ProviderApplicationId = id;
            var provApp      = _providerApplicationService.ReadProviderApplication(criteria);
            var pyDesc       = string.Empty;
            var programYears = LookupCache.GetProgramYears();

            foreach (var py in programYears)
            {
                if (py.ProgramYearId == provApp.ProgramYearId)
                {
                    pyDesc = py.ProgramYearDesc;
                    break;
                }
            }

            var fileName = string.Format(
                pyDesc + "_ProviderApplication_{0}_{1}.doc",
                model.ProviderID,
                model.ProviderApplicationId);

            var fileContents = Encoding.UTF8.GetBytes(htmlResult);

            return(this.File(fileContents, "application/vnd.ms-word", fileName));
        }