Exemplo n.º 1
0
        public ActionResult OnPost()
        {
            if (Configuration.SecurityType == SecurityType.ApiKey &&
                (string.IsNullOrEmpty(Configuration.SecurityKeyName) || string.IsNullOrWhiteSpace(Configuration.SecurityKeyName)))
            {
                ModelState.AddModelError("SecurityKeyName", "ApiKey requires a name");
            }

            if (!string.IsNullOrWhiteSpace(Configuration.LicenseName) &&
                (string.IsNullOrEmpty(Configuration.LicenseUrl) || string.IsNullOrWhiteSpace(Configuration.LicenseUrl)))
            {
                ModelState.AddModelError("LicenseUrl", "License requires a url");
            }

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            using (var scope = new TransactionScope())
            {
                _saveConfiguration.Execute(Configuration);
                _updateServicesToTriggerMerge.Execute();

                scope.Complete();
            }

            return(RedirectToPage("Index"));
        }
Exemplo n.º 2
0
        public ActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var services = _getServices.Execute();

            services.ForEach(x => x.Enabled = x.Status != ServiceStatus.Disabled);

            var updates = Services.Where(x => !services.Any(s => x.Id == s.Id && x.Enabled == s.Enabled)).ToList();

            if (updates.Count == 0)
            {
                return(RedirectToPage("List"));
            }

            updates.ForEach(x => x.Status = x.Enabled ? ServiceStatus.Deployed : ServiceStatus.Disabled);

            using (var scope = new TransactionScope())
            {
                _updateServiceStatus.Execute(updates);
                _updateServicesToTriggerMerge.Execute();

                scope.Complete();
            }

            return(RedirectToPage("List"));
        }