Ejemplo n.º 1
0
        private void PopulateSelectListsToModel(BindingViewModel viewModel, IBinding binding)
        {
            if (viewModel != null)
            {
                if (viewModel.SelectedWebsiteId > 0)
                {
                    binding.Website = WebsiteService.GetById(viewModel.SelectedWebsiteId);
                }

                if (viewModel.SelectedServerIds.Any())
                {
                    if (binding.Servers == null)
                    {
                        binding.Servers = new HashSet <IServer>();
                    }
                    foreach (long selectedServerId in viewModel.SelectedServerIds)
                    {
                        binding.Servers.Add(ServerService.GetById(selectedServerId));
                    }
                }
                if (viewModel.SelectedEnvironmentIds.Any())
                {
                    if (binding.Environments == null)
                    {
                        binding.Environments = new HashSet <IEnvironment>();
                    }
                    foreach (long selectedEnvironmentId in viewModel.SelectedEnvironmentIds)
                    {
                        binding.Environments.Add(EnvironmentService.GetById(selectedEnvironmentId));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int id, int?page)
        {
            var website = WebsiteService.GetById(id);

            if (website != null)
            {
                WebsiteService.Delete(website);
            }

            return(RedirectToAction("Index", new { page }));
        }
Ejemplo n.º 3
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"));
        }