public IActionResult Edit(int id, [Bind("DocumentId,AuthorUserId,AgencyName,NomineeName,ClassTitle,Division,SelectedAward,Kind,AwardClass,AwardName,ComponentViewName,Description,HasRibbon,EligibilityConfirmationDate,StartDate,EndDate,SelectedAwardType")] SmartAwardViewModel form) { if (id != form.DocumentId) { return(NotFound()); } if (!ModelState.IsValid) { // rebuild and return VM ViewData["Title"] = "Edit Award Form: Error"; form.Components = _repository.Components.ToList(); form.Users = _repository.Users.ToList(); return(View(form)); } SmartDocument awardDoc = _repository.AwardForms.FirstOrDefault(x => x.DocumentId == id); if (awardDoc == null) { return(NotFound()); } SmartAwardFactory factory = new SmartAwardFactory(_repository, awardDoc); factory.UpdateAwardForm(form); return(RedirectToAction("SaveSuccess", new { id = factory.awardForm.DocumentId })); }
public ActionResult Download(int id) { // create a generator, passing the repository as a parameter SmartDocument document = _repository.Documents.FirstOrDefault(x => x.DocumentId == id); if (document != null) { switch (document.Type) { case SmartDocument.SmartDocumentType.PPA: var ppaFactory = new SmartPPAFactory(_repository, document); return(File(ppaFactory.GenerateDocument(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", document.FileName)); case SmartDocument.SmartDocumentType.JobDescription: var jobFactory = new SmartJobDescriptionFactory(_repository, document); return(File(jobFactory.GenerateDocument(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", document.FileName)); case SmartDocument.SmartDocumentType.AwardForm: var awardFactory = new SmartAwardFactory(_repository, document); return(File(awardFactory.GenerateDocument(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", document.FileName)); case SmartDocument.SmartDocumentType.PAF: var pafFactory = new SmartPAFFactory(_repository, document); return(File(pafFactory.GenerateDocument(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", document.FileName)); default: return(NotFound()); } } else { return(NotFound()); } }
public IActionResult Edit(int id) { SmartDocument award = _repository.AwardForms.FirstOrDefault(x => x.DocumentId == id); if (award == null) { return(NotFound()); } SmartAwardFactory factory = new SmartAwardFactory(_repository, award); SmartAwardViewModel vm = factory.GetViewModelFromXML(); ViewData["Title"] = "Edit Award Form"; return(View(vm)); }
public IActionResult Create([Bind("DocumentId,AuthorUserId,AgencyName,NomineeName,ClassTitle,Division,SelectedAward,Kind,AwardClass,AwardName,ComponentViewName,Description,HasRibbon,EligibilityConfirmationDate,StartDate,EndDate,SelectedAwardType")] SmartAwardViewModel form) { if (!ModelState.IsValid) { ViewData["Title"] = "Create Award Form: Error"; form.Components = _repository.Components.ToList(); form.Users = _repository.Users.ToList(); return(View(form)); } else { // do Award Form Factory stuff SmartAwardFactory factory = new SmartAwardFactory(_repository); factory.CreateSmartAwardForm(form); return(RedirectToAction("SaveSuccess", new { id = factory.awardForm.DocumentId })); } }