コード例 #1
0
ファイル: HomeController.cs プロジェクト: stringly/SmartDocs
        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());
            }
        }
コード例 #2
0
 public ActionResult Create([Bind(
                                 "SelectedPAFType," +
                                 "FirstName," +
                                 "LastName," +
                                 "DepartmentIdNumber," +
                                 "PayrollIdNumber," +
                                 "DepartmentIdNumber," +
                                 "DepartmentDivision," +
                                 "DepartmentDivisionCode," +
                                 "WorkPlaceAddress," +
                                 "AuthorUserId," +
                                 "StartDate," +
                                 "EndDate," +
                                 "JobId," +
                                 "Assessment," +
                                 "Recommendation")] PAFFormViewModel form)
 {
     if (!ModelState.IsValid)
     {
         // next, re-populate the VM drop down lists
         form.HydrateLists(_repository.Jobs.Select(x => new JobDescriptionListItem(x)).ToList(), _repository.Components.ToList(), _repository.Users.Select(x => new UserListItem(x)).ToList());
         // return the View with the validation messages
         ViewData["Title"] = "Create PAF: Error";
         return(View(form));
     }
     else
     {
         // validation success, create new generator and pass repo
         SmartPAFFactory factory = new SmartPAFFactory(_repository);
         // call generator method to pass form data
         factory.CreatePAF(form);
         // redirect to success view with PPA as querystring param
         return(RedirectToAction("SaveSuccess", new { id = factory.PAF.DocumentId }));
     }
 }
コード例 #3
0
        public ActionResult Edit(int id)
        {
            // pull the PAF from the repo
            SmartDocument   paf     = _repository.PerformanceAssessmentForms.FirstOrDefault(x => x.DocumentId == id);
            SmartPAFFactory factory = new SmartPAFFactory(_repository, paf);
            // pass the PPA to the factory method takes a SmartPPA parameter
            PAFFormViewModel vm = factory.GetViewModelFromXML();

            // populate the VM <select> lists
            vm.HydrateLists(_repository.Jobs.Select(x => new JobDescriptionListItem(x)).ToList(), _repository.Components.ToList(), _repository.Users.Select(x => new UserListItem(x)).ToList());
            // return the view
            ViewData["Title"] = "Edit PAF";
            return(View(vm));
        }
コード例 #4
0
 public ActionResult Edit(int id, [Bind(
                                       "DocumentId," +
                                       "SelectedPAFType," +
                                       "FirstName," +
                                       "LastName," +
                                       "DepartmentIdNumber," +
                                       "PayrollIdNumber," +
                                       "DepartmentIdNumber," +
                                       "DepartmentDivision," +
                                       "DepartmentDivisionCode," +
                                       "WorkPlaceAddress," +
                                       "AuthorUserId," +
                                       "StartDate," +
                                       "EndDate," +
                                       "JobId," +
                                       "Assessment," +
                                       "Recommendation")] PAFFormViewModel form)
 {
     // if the querystring parameter id doesn't match the POSTed PAFId, return 404
     if (id != form.DocumentId)
     {
         return(NotFound());
     }
     if (!ModelState.IsValid)
     {
         // next, re-populate the VM drop down lists
         form.HydrateLists(_repository.Jobs.Select(x => new JobDescriptionListItem(x)).ToList(), _repository.Components.ToList(), _repository.Users.Select(x => new UserListItem(x)).ToList());
         ViewData["Title"] = "Edit PAF: Error";
         return(View(form));
     }
     else
     {
         if (form.JobId != 0)
         {
             JobDescription job = new JobDescription(_repository.Jobs.FirstOrDefault(x => x.JobId == form.JobId));
         }
         else
         {
             return(NotFound());
         }
         // validation success, create a new PAFGenerator and pass the repo as a parameter
         SmartPAFFactory factory = new SmartPAFFactory(_repository);
         // populate the form info into the generator
         factory.UpdatePAF(form);
         // redirect to the SaveSuccess view, passing the newly created PPA as a querystring param
         return(RedirectToAction("SaveSuccess", new { id = factory.PAF.DocumentId }));
     }
 }