コード例 #1
0
ファイル: PackagesController.cs プロジェクト: sap-sh/t
        public ActionResult EditPackage(PackageFullViewModel packageViewModel)
        {
            var package = Mapper.Map<PackageFullViewModel, Package>(packageViewModel);

            try
            {
                dynamic viewModel = new ExpandoObject();

                    _packageService.EditPackage(package);

                    ViewBag.Message = ScreenMessages.ValidMessage("Package updated.");

                    // Set up dropdowns
                    ViewBag.cmbWiSPOSProductName = new SelectList(_packageService.GetWISPOS(), "Key", "Value", package.cmbWiSPOSProductName);
                    ViewBag.cmbWiSPOSBaselineInterim = new SelectList(_packageService.GetWISPBaselineInterim(), "Key", "Value", package.cmbWiSPOSBaselineInterim);

                    // Set up package types
                    switch ((PackageTypeEnum)package.cmbPackageType)
                    {
                        case PackageTypeEnum.App_Install_Not_iSAC_Managed:

                            // Set up dropdowns
                            ViewBag.cmbSMSPackageWrapper = new SelectList(_packageService.GetSMSPackageType(), "Key", "Value", package.cmbSMSPackageWrapper);
                            ViewBag.cmbAlways32Bit = new SelectList(_packageService.GetAlways32Bit(), "Key", "Value", package.cmbAlways32Bit);
                            ViewBag.radInstigatesReboot_No = new SelectList(_packageService.GetInvestigateReboot(), "Key", "Value", package.radInstigatesReboot_No);

                            viewModel = Mapper.Map<Package, PackageType1ViewModel>(package);
                            break;
                        case PackageTypeEnum.WiSP_OS_Baseline_Not_TS:

                            // Set up dropdowns
                            ViewBag.cmbWiSPOSProductName = new SelectList(_packageService.GetWISPOS(), "Key", "Value", package.cmbWiSPOSProductName);
                            ViewBag.cmbWiSPOSBaselineInterim = new SelectList(_packageService.GetWISPBaselineInterim(), "Key", "Value", package.cmbWiSPOSBaselineInterim);

                            viewModel = Mapper.Map<Package, PackageType2ViewModel>(package);
                            break;
                        case PackageTypeEnum.WiSP_OS_Baseline_TS:

                            // Set up dropdowns
                            ViewBag.cmbTSOSProductName = new SelectList(_packageService.GetWISPTSPRoductName(), "Key", "Value", package.cmbTSOSProductName);

                            viewModel = Mapper.Map<Package, PackageType3ViewModel>(package);
                            break;
                        case PackageTypeEnum.WSP_OS_Baseline_Not_TS:
                            viewModel = Mapper.Map<Package, PackageType4ViewModel>(package);
                            break;
                        case PackageTypeEnum.WGS_OS_Baseline:
                            viewModel = Mapper.Map<Package, PackageType5ViewModel>(package);
                            break;
                        case PackageTypeEnum.App_Install_iSAC_Managed:
                            viewModel = Mapper.Map<Package, PackageType6ViewModel>(package);
                            break;
                    }

                    return View(viewModel);

            }
            catch (ValidationException vex)
            {
                ModelState.AddErrors(vex);
            }
            catch (Exception ex)
            {
                TempData["Message"] = ScreenMessages.ErrorMessage("Standard", ex.Message);

                return RedirectToAction("Error", "Error");
            }
            return View();
        }
コード例 #2
0
ファイル: PackagesController.cs プロジェクト: sap-sh/t
        public ActionResult AddPackage(PackageFullViewModel packageViewModel)
        {
            try
            {
                    // Populate completion page
                    ViewBag.PackageName = packageViewModel.strName;

                    var viewModel = new object();

                    // Set up package types
                    switch ((PackageTypeEnum)packageViewModel.cmbPackageType)
                    {
                        case PackageTypeEnum.App_Install_Not_iSAC_Managed:

                            // Set up dropdowns
                            ViewBag.cmbSMSPackageWrapper = new SelectList(_packageService.GetSMSPackageType(), "Key", "Value", packageViewModel.cmbSMSPackageWrapper);
                            ViewBag.cmbAlways32Bit = new SelectList(_packageService.GetAlways32Bit(), "Key", "Value", packageViewModel.cmbAlways32Bit);
                            ViewBag.radInstigatesReboot_No = new SelectList(_packageService.GetInvestigateReboot(), "Key", "Value", packageViewModel.radInstigatesReboot_No);

                            // Populate completion page
                            if (packageViewModel.chkRebootBefore == true && packageViewModel.chkRebootAfter == true)
                            {
                                ViewBag.SMSReboot = "<p>A reboot will be performed <strong>before and after</strong> the application is installed.</p>";
                            }
                            else if (packageViewModel.chkRebootBefore == true)
                            {
                                ViewBag.SMSReboot = "<p>A reboot will be performed <strong>before</strong> the application is installed.</p>";
                            }
                            else
                            {
                                ViewBag.SMSReboot = "<p>A reboot will be performed <strong>after</strong> the application is installed.</p>";
                            }

                            // Update values
                            if (packageViewModel.radInstigatesReboot_No == false)
                                packageViewModel.radInstigatesReboot_Yes = true;
                            break;

                        case PackageTypeEnum.WiSP_OS_Baseline_Not_TS:

                            // Set up dropdowns
                            ViewBag.cmbWiSPOSProductName = new SelectList(_packageService.GetWISPOS(), "Key", "Value", packageViewModel.cmbWiSPOSProductName);
                            ViewBag.cmbWiSPOSBaselineInterim = new SelectList(_packageService.GetWISPBaselineInterim(), "Key", "Value", packageViewModel.cmbWiSPOSBaselineInterim);

                            break;
                        case PackageTypeEnum.WiSP_OS_Baseline_TS:

                            // Set up dropdowns
                            ViewBag.cmbTSOSProductName = new SelectList(_packageService.GetWISPTSPRoductName(), "Key", "Value", packageViewModel.cmbTSOSProductName);

                            // Populate completion page
                            switch (packageViewModel.cmbTSOSProductName)
                            {
                                case "TSPATCHES_1.00":
                                    ViewBag.Server = "Windows 2003 x86";
                                    break;
                                case "TSPATCHESx64_1.00":
                                    ViewBag.Server = "Windows 2003 x64";
                                    break;
                            }
                            break;
                        case PackageTypeEnum.WSP_OS_Baseline_Not_TS:
                            break;
                        case PackageTypeEnum.WGS_OS_Baseline:
                            break;
                        case PackageTypeEnum.App_Install_iSAC_Managed:
                            break;
                    }

                    // Add new package
                    var package = Mapper.Map<PackageFullViewModel, Package>(packageViewModel);

                    _packageService.AddPackage(package);

                    ViewBag.Status = "AddComplete";
            }
            catch (ValidationException vex)
            {
                ModelState.AddErrors(vex);
            }

            catch (Exception ex)
            {
                TempData["Message"] = ScreenMessages.ErrorMessage("Standard", ex.Message);

                return RedirectToAction("Error", "Error");
            }
            return View();
        }