public ActionResult Details(int Id) { dynamic proposal = _proposalctx.GetProposalById(Id); proposal.ProjectHistory = _projectx.IsProjectHistory(Id); if (User.IsInRole("Admin")) { if (HttpContext.Session.GetBoolean("IndexExternal") ?? default(bool)) { ViewBag.Type = "External"; HttpContext.Session.SetBoolean("IndexExternal", false); } if (HttpContext.Session.GetBoolean("IndexStudent") ?? default(bool)) { ViewBag.Type = "Student"; HttpContext.Session.SetBoolean("IndexStudent", false); } return(View("~/Views/_Admin/Proposal/Details.cshtml", proposal)); } return(View("~/Views/_Lecturer/Proposal/Details.cshtml", proposal)); }
public ActionResult Download(int id) { InitiatedProjectViewModel proposal = _proposalctx.GetProposalById(id); string templateName = "External_Project_Proposal.docx"; string path = Path.Combine(environment.ContentRootPath, "~/App_Data/Generated", templateName); string downloadPath = string.Format(@"{0}{1}.docx", path, "-" + proposal.Title); DateTime currentDt = DateTime.Now; DateTime Sem1Start = new DateTime(currentDt.Year, 4, 20); DateTime Sem2Start = new DateTime(currentDt.Year, 10, 19); string semester = ""; if (DateHelper.Between(currentDt, Sem1Start, Sem2Start)) { semester = "1"; } else { semester = "2"; } DocX document = new DocxFormatter().GetInitiatedProjectProposal(currentDt, semester); document.SaveAs(path); using (DocX doc = DocX.Load(path)) { doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("ProjectTitle", proposal.Title)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("ProjectOverview", proposal.ProjectOverview)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("IntroBackground", proposal.IntroBackground)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("Approach", proposal.KeyInnovationAndResearchGoals)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("ComparisonMerits", proposal.ComparisonOfTheMerits)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("TargetAudience", proposal.TargetAudience)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("BusinessModel", proposal.BusinessModelAndMarketPotential)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("MainFunction", proposal.MainFunction)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("ProjectPlan", proposal.ProjectPlan)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("HardwareAndSoftwareRequirements", proposal.HardwareAndSoftwareRequirements)); doc.AddCustomProperty(new Xceed.Words.NET.CustomProperty("ProblemsAndCountermeasures", proposal.ProblemsAndCountermeasures)); doc.SaveAs(downloadPath); } return(File(downloadPath, System.Net.Mime.MediaTypeNames.Application.Octet, Path.GetFileName(downloadPath))); }