/// <summary>
        /// Delete product specified by id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="page">The page.</param>
        /// <returns></returns>
        public ActionResult Delete(int id, int?page)
        {
            var packageConfiguration = PackageConfigurationService.GetById(id);

            if (packageConfiguration != null)
            {
                PackageConfigurationService.Delete(packageConfiguration);
            }
            return(RedirectToAction("Index", new { page }));
        }
 /// <summary>
 /// Edits the specified id.
 /// </summary>
 /// <param name="id">The id.</param>
 /// <returns></returns>
 public ActionResult Edit(int?id)
 {
     if (id.HasValue)
     {
         var packageConfiguration = PackageConfigurationService.GetById(id.Value);
         var viewModel            = AutoMapper.Mapper.Map <IPackageConfiguration, PackageConfigurationViewModel>(packageConfiguration);
         viewModel.Products = ProductService.GetAll().ToList();
         if (viewModel.Product != null)
         {
             viewModel.SelectedProductId = viewModel.Product.Id;
         }
         return(View(viewModel));
     }
     return(RedirectToAction("Create"));
 }
Ejemplo n.º 3
0
 public ActionResult Edit(PackageViewModel viewModel, int?page)
 {
     if (ModelState.IsValid && viewModel.SelectedProductId > 0 && viewModel.SelectedPackageConfigurationId > 0)
     {
         var package = AutoMapper.Mapper.Map <PackageViewModel, IPackage>(viewModel);
         if (viewModel != null)
         {
             if (viewModel.SelectedProductId > 0)
             {
                 package.Product = ProductService.GetById(viewModel.SelectedProductId);
             }
             if (viewModel.SelectedPackageConfigurationId > 0)
             {
                 package.PackageConfiguration = PackageConfigurationService.GetById(viewModel.SelectedPackageConfigurationId);
             }
         }
         PackageService.CreateOrUpdate(package);
         return(RedirectToAction("Index", new { page }));
     }
     return(View(viewModel));
 }
Ejemplo n.º 4
0
        public ActionResult Create(PackageViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var package = AutoMapper.Mapper.Map <PackageViewModel, IPackage>(viewModel);
                if (viewModel.SelectedProductId > 0)
                {
                    package.Product = ProductService.GetById(viewModel.SelectedProductId);
                }
                if (viewModel.SelectedPackageConfigurationId > 0)
                {
                    package.PackageConfiguration = PackageConfigurationService.GetById(viewModel.SelectedPackageConfigurationId);
                }

                PackageService.CreateOrUpdate(package);
            }
            else
            {
                return(View(viewModel));
            }

            return(RedirectToAction("Index"));
        }
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"));
        }