예제 #1
0
        public async Task <IWriterResult> UpdateWithdrawSettings(string userId, UpdateWithdrawModel model)
        {
            try
            {
                using (var context = DataContextFactory.CreateContext())
                {
                    var user = await context.Users.FirstOrDefaultAsync(u => u.Id == userId).ConfigureAwait(false);

                    if (user == null)
                    {
                        return(new WriterResult(false, "User not found."));
                    }

                    user.DisableWithdrawEmailConfirmation = model.DisableConfirmation;
                    user.IsUnsafeWithdrawEnabled          = !model.AddressBookOnly;
                    await context.SaveChangesWithAuditAsync().ConfigureAwait(false);

                    await UserSyncService.SyncUser(user.Id).ConfigureAwait(false);

                    return(new WriterResult(true, "Successfully updated withdrawal settings."));
                }
            }
            catch (Exception)
            {
                return(new WriterResult(false));
            }
        }
예제 #2
0
        public async Task <IWriterResult> UpdateApiSettings(string userId, UpdateApiModel model)
        {
            try
            {
                using (var context = DataContextFactory.CreateContext())
                {
                    var user = await context.Users.FirstOrDefaultAsync(u => u.Id == userId).ConfigureAwait(false);

                    if (user == null)
                    {
                        return(new WriterResult(false, "User not found."));
                    }

                    model.OldApiKey                 = user.ApiKey;
                    user.IsApiEnabled               = model.IsApiEnabled;
                    user.IsApiWithdrawEnabled       = model.IsApiWithdrawEnabled;
                    user.IsApiUnsafeWithdrawEnabled = model.IsApiUnsafeWithdrawEnabled;
                    user.ApiKey    = model.ApiKey;
                    user.ApiSecret = model.ApiSecret;

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

                    await UserSyncService.SyncUser(user.Id).ConfigureAwait(false);

                    return(new WriterResult(true, "Successfully updated API settings."));
                }
            }
            catch (Exception)
            {
                return(new WriterResult(false));
            }
        }