Exemplo n.º 1
0
        public async Task <IWriterResult> AdminUpdatePoolConnection(AdminUpdatePoolConnectionModel model)
        {
            var sanitizer = new HtmlSanitizer();

            using (var context = PoolDataContextFactory.CreateContext())
            {
                var connection = await context.Connection.FirstOrDefaultNoLockAsync(x => x.AlgoType == model.AlgoType);

                if (connection == null)
                {
                    return(new WriterResult(false, "Algorithm not found"));
                }

                connection.FixedDiffSummary     = sanitizer.Sanitize(model.FixedDiffSummary);
                connection.VarDiffHighSummary   = sanitizer.Sanitize(model.VarDiffHighSummary);
                connection.VarDiffMediumSummary = sanitizer.Sanitize(model.VarDiffMediumSummary);
                connection.VarDiffLowSummary    = sanitizer.Sanitize(model.VarDiffLowSummary);
                connection.Name        = model.Name;
                connection.Host        = model.Host;
                connection.DefaultDiff = model.DefaultDiff;
                connection.DefaultPool = model.DefaultPool;

                await context.SaveChangesAsync().ConfigureAwait(false);

                return(new WriterResult(true, "Successfully updated connection."));
            }
        }
        public async Task <ActionResult> UpdateConnection(AdminUpdatePoolConnectionModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("UpdatePoolConnectionModal", model));
            }

            var result = await PoolWriter.AdminUpdatePoolConnection(model);

            if (!ModelState.IsWriterResultValid(result))
            {
                return(View("UpdatePoolConnectionModal", model));
            }

            return(CloseModalSuccess(result.Message));
        }