Example #1
0
        public async Task <ActionResult> Create(string accountName, ContainerCreateModel 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("_Create", model));
            }

            if (await _containerDbCommand.ExistsAsync(account, model.Name))
            {
                ModelState.AddModelError("Name", "この名前はすでに使用されています。");
                return(PartialView("_Create", model));
            }

            var container = account.CreateContainer(model.Name);

            Mapper.Map(model, container);

            await _containerDbCommand.SaveAsync(container);

            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();
        }