public ActionResult Create(string id) { ApplicationDbContext context = new ApplicationDbContext(); //var providers = context.CloudStorageProviders.ToList(); var account = context.CloudStorageAccounts.Find(id); var containers = CloudStorageMananger.ImportContainers(account.AccountName, account.AccountKey); var model = new CloudStorageContainerCreateViewModel { //CloudStorageAccountId = id, CloudStorageAccountPublicKey = Guid.Parse(id), //CloudStorageContainerId = Guid.NewGuid().ToString("D").ToLower(), CloudStorageContainers = containers, //CloudStorageContainersId = null, //AccountName = null, //AccountKey }; return View(model); }
public async Task<ActionResult> Create(CloudStorageContainerCreateViewModel model, string returnUrl) { //ApplicationDbContext context = new ApplicationDbContext(); //var providers = context.CloudStorageProviders.ToList(); //var model = new CloudStorageAccountCreateViewModel { // CloudStorageProviders = providers, // //CloudStorageProviderId = null, // //AccountName = null, // //AccountKey //}; CloudStorageContainer container = new CloudStorageContainer { // CloudStorageAccountId = model.AccountName, // CloudStorageProviderId = model.CloudStorageProviderId, //CloudStorageContainerId = model.CloudStorageContainerId, //CloudStorageAccountId = model.CloudStorageAccountId, ProviderKey = model.ProviderKey, ContainerName = model.ContainerName, Alias = string.IsNullOrEmpty(model.Alias) ? model.Alias : model.ContainerName, Description = model.Description // , }; var user = this.CurrentSecurityUser; var accounts = user.CloudStorageAccounts.ToList(); // .Select(m => m.CloudStorageAccountId == model.CloudStorageAccountId).FirstOrDefault(); var account = accounts.Where(m => m.PublicKey == model.CloudStorageAccountPublicKey).FirstOrDefault(); // user.CloudStorageAccounts.Add(container); account.CloudStorageContainers.Add(container); await UserManager.UpdateAsync(user); return RedirectToLocal(returnUrl); //return View(model); }