Esempio n. 1
0
        public async Task<IActionResult> Save()
        {
            var formFields = Request.Form.ToDictionary(f => f.Key, f => f.Value.ToString());

            try
            {
                var factory = new ServerConfigurationFactory();
                var configuration = factory.CreateFromDictionary(formFields);

                var createServerResponse = await _apiClient.Servers.CreateServerAsync(new CreateServerRequest(configuration));

                if (!createServerResponse?.Success ?? false)
                {
                    _notificationService.PushMessage("Unable to create new server.", MessageLevel.Error);

                    return RedirectToRoute(DashboardRoutes.Home);
                }   
                
                return RedirectToRoute(DashboardRoutes.ViewServerDetails, new { slug = createServerResponse.Server.Slug });                
            }
            catch (Exception exception)
            {
                _logger.LogError($"Error creating new server: {exception.Message}");

                _notificationService.PushMessage("Error when creating new server.", MessageLevel.Error);
            }

            return RedirectToRoute(DashboardRoutes.Home);
        }
Esempio n. 2
0
        public IActionResult Create(ServerType serverType)
        {
            var factory = new ServerConfigurationFactory();

            return View(factory.CreateFromServerType(serverType));
        }