コード例 #1
0
        public async Task<ActionResult> Create(CloudStorageAccountCreateViewModel model, string returnUrl) {

            //ApplicationDbContext context = new ApplicationDbContext();
            //var providers = context.CloudStorageProviders.ToList();

            //var model = new CloudStorageAccountCreateViewModel {
            //    CloudStorageProviders = providers,
            //    //CloudStorageProviderId = null,
            //    //AccountName = null,
            //    //AccountKey
            //};
            CloudStorageAccount account = new CloudStorageAccount {
                // https://msdn.microsoft.com/en-us/library/97af8hh4(v=vs.110).aspx
                //CloudStorageAccountId = Guid.NewGuid().ToString("D").ToLower(), // model.AccountName,
                CloudStorageProviderId = model.CloudStorageProviderId,
                ProviderKey = model.AccountName,
                AccountName = model.AccountName,
                AccountKey = model.AccountKey,
                Alias = string.IsNullOrEmpty(model.Alias) ? model.Alias : model.AccountName,
                Description = model.Description
            };

            var user = this.CurrentSecurityUser;
            user.CloudStorageAccounts.Add(account);
            await UserManager.UpdateAsync(user);
                       

            return RedirectToLocal(returnUrl);

            //return View(model);
        }
コード例 #2
0
        public ActionResult Create() {

            ApplicationDbContext context = new ApplicationDbContext();
            var providers = context.CloudStorageProviders.ToList();

            var model = new CloudStorageAccountCreateViewModel {
                CloudStorageProviders = providers,
                //CloudStorageProviderId = null,
                //AccountName = null,
                //AccountKey
            };

            return View(model);
        }