示例#1
0
        public async Task <ActionResult> Delete(string accountName, string id, ContainerDeleteModel model)
        {
            var account = await _accountDbCommand.FindByNameAsync(accountName);

            if (account == null)
            {
                return(HttpNotFound());
            }
            if (account.Owner != User.Identity.Name)
            {
                return(new HttpUnauthorizedResult());
            }

            if (!ModelState.IsValid)
            {
                return(PartialView("_Delete", model));
            }

            var container = await _containerDbCommand.FindAsync(id);

            if (container == null)
            {
                return(HttpNotFound());
            }

            await _containerDbCommand.DeleteAsync(id);

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
        public async Task DeleteTest()
        {
            var container = Mock.CommonStorageAccount.CreateContainer("DeleteTest");

            container.Metadata["key1"]        = "value1";
            container.Metadata["key2"]        = "value2";
            container.IsPublic                = true;
            container.LastModifiedUtcDateTime = new DateTime(2015, 12, 31);

            await _dbCommand.SaveAsync(container);

            var exists = await _dbCommand.ExistsAsync(Mock.CommonStorageAccount, container.Name);

            exists.IsTrue();

            await _dbCommand.DeleteAsync(container.Id);

            exists = await _dbCommand.ExistsAsync(Mock.CommonStorageAccount, container.Name);

            exists.IsFalse();
        }