コード例 #1
0
        public async Task <ActionResult> Edit(int id)
        {
            var query = new GetApplicationInfo(id);
            var app   = await _queryBus.QueryAsync(query);

            var model = new EditViewModel
            {
                ApplicationId = app.Id,
                Name          = app.Name
            };

            return(View(model));
        }
コード例 #2
0
        public async Task <ActionResult> ConfigurePackage(ConfigurePackageViewModel model, bool validationFailed = false)
        {
            await Init();

            var query   = new GetApplicationInfo(model.ApplicationId);
            var appInfo = await _queryBus.QueryAsync(this.ClaimsUser(), query);

            try
            {
                var hash = CalculateMd5Hash(appInfo.AppKey);

                // Fetch updates instructions from the git documentation
                // without having to manage it locally.
                var uri =
                    $"https://coderrapp.com/client/{model.LibraryName}/configure/{hash}";
                var client = new HttpClient {
                    Timeout = TimeSpan.FromSeconds(10)
                };
                var html = await client.GetStringAsync(uri);

                model.Instruction = html
                                    .Replace("yourAppKey", appInfo.AppKey)
                                    .Replace("yourSharedSecret", appInfo.SharedSecret)
                                    .Replace("http://yourServer/coderr/", _baseConfiguration.BaseUrl.ToString())
                                    .Replace("\"/documentation/", "\"https://coderrapp.com/documentation/");
            }
            catch (Exception)
            {
                model.ErrorMessage = "Failed to download package information. Search nuget.org after the correct package (starting with 'coderr.client')";
            }

            model.SharedSecret = appInfo.SharedSecret;
            model.AppKey       = appInfo.AppKey;
            model.ReportUrl    = _baseConfiguration.BaseUrl;
            return(View(model));
        }