コード例 #1
0
        public async Task <IWriterResult> AdminUpdatePoolSettings(AdminUpdatePoolSettingsModel model)
        {
            using (var context = PoolDataContextFactory.CreateContext())
            {
                var settings = await context.Settings.FirstOrDefaultNoLockAsync().ConfigureAwait(false);

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

                settings.ProcessorEnabled          = model.ProcessorEnabled;
                settings.HashRateCalculationPeriod = model.HashRateCalculationPeriod;
                settings.StatisticsPollPeriod      = model.StatisticsPollPeriod;
                settings.PayoutPollPeriod          = model.PayoutPollPeriod;
                settings.SitePayoutPollPeriod      = model.SitePayoutPollPeriod;
                settings.ProfitabilityPollPeriod   = model.ProfitabilityPollPeriod;
                settings.ProfitSwitchEnabled       = model.ProfitSwitchEnabled;
                settings.ProfitSwitchDepthBTC      = model.ProfitSwitchDepthBTC;
                settings.ProfitSwitchDepthLTC      = model.ProfitSwitchDepthLTC;

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

                return(new WriterResult(true, "Successfully updated settings."));
            }
        }
コード例 #2
0
        public async Task <ActionResult> UpdateSettings(AdminUpdatePoolSettingsModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("UpdateSettingsModal", model));
            }

            var result = await PoolWriter.AdminUpdatePoolSettings(model);

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

            return(CloseModal(result));
        }