Ejemplo n.º 1
0
        /// <summary>
        /// Creates this instance.
        /// </summary>
        /// <returns></returns>
        public ActionResult Create()
        {
            var viewModel = new PackageViewModel();

            viewModel.Products = ProductService.GetAll().ToList();
            viewModel.PackageConfigurations = PackageConfigurationService.GetAll().ToList();
            return(View(viewModel));
        }
        /// <summary>
        /// List the specified page.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns></returns>
        public ActionResult Index(int?page)
        {
            var viewModel = new PackageConfigurationListViewModel();

            var  pageNumber = (page ?? 1) - 1;
            long totalCount;
            IEnumerable <IPackageConfiguration> packageConfigurations = PackageConfigurationService.GetAll(pageNumber, PageSize, out totalCount);

            viewModel.PackageConfigurations = new StaticPagedList <IPackageConfiguration>(packageConfigurations, pageNumber + 1, PageSize, (int)totalCount);
            return(View(viewModel));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Edits the specified id.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <returns></returns>
 public ActionResult Edit(int?id)
 {
     if (id.HasValue)
     {
         var package   = PackageService.GetById(id.Value);
         var viewModel = AutoMapper.Mapper.Map <IPackage, PackageViewModel>(package);
         viewModel.Products = ProductService.GetAll().ToList();
         viewModel.PackageConfigurations = PackageConfigurationService.GetAll().ToList();
         if (viewModel.Product != null)
         {
             viewModel.SelectedProductId = viewModel.Product.Id;
             viewModel.SelectedPackageConfigurationId = viewModel.PackageConfiguration.Id;
         }
         return(View(viewModel));
     }
     return(RedirectToAction("Create"));
 }
Ejemplo n.º 4
0
        public ActionResult Edit(int?id, int?page)
        {
            if (id.HasValue)
            {
                var viewModel = AutoMapper.Mapper.Map <IWebsite, WebsiteViewModel>(WebsiteService.GetById(id.Value));
                viewModel.PackageConfigurations = PackageConfigurationService.GetAll().ToList();
                if (viewModel.ApplicationPool == null)
                {
                    viewModel.ApplicationPool = new ApplicationPoolViewModel();
                }
                else
                {
                    viewModel.ApplicationPool = AutoMapper.Mapper.Map <IApplicationPool, ApplicationPoolViewModel>(viewModel.ApplicationPool);
                }

                return(View(viewModel));
            }
            return(RedirectToAction("Create"));
        }
Ejemplo n.º 5
0
        public ActionResult Edit(WebsiteViewModel viewModel, int?page)
        {
            if (ModelState.IsValid)
            {
                var website = AutoMapper.Mapper.Map <WebsiteViewModel, IWebsite>(viewModel);
                if (viewModel.SelectedPackageConfigurationId > 0)
                {
                    website.PackageConfiguration = PackageConfigurationService.GetById(viewModel.SelectedPackageConfigurationId);

                    var appPool = AutoMapper.Mapper.Map <ApplicationPoolViewModel, IApplicationPool>(viewModel.ApplicationPool as ApplicationPoolViewModel);

                    website.ApplicationPool = ApplicationPoolService.CreateOrUpdate(appPool);
                }
                WebsiteService.CreateOrUpdate(website);
            }
            else
            {
                viewModel.PackageConfigurations = PackageConfigurationService.GetAll().ToList();
                return(View(viewModel));
            }

            return(RedirectToAction("Index"));
        }