Esempio n. 1
0
        public async Task UpdateCommonTest()
        {
            var storage = Storage.NewStorage("UpdateCommonTest", "Owner", StorageType.Common);

            storage.ConnectionProperties = new ConnectionProperties(@"(localdb)\v11.0", "BloqsTest_UpdateCommon", "sa", "password");
            storage.IsSuspended          = true;
            storage.ThresholdLength      = 20000;

            await _dbCommand.CreateAsync(storage);

            var created = await _dbCommand.FindAsync(storage.Id);

            created.Name  = "UpdatedCommonTest";
            created.Owner = "Owner2";
            storage.ConnectionProperties    = new ConnectionProperties(@"(localdb)\v12.0", "BloqsTest_UpdatedCommon", "user", "password2");
            created.IsSuspended             = false;
            created.ThresholdLength         = 30000;
            created.LastModifiedUtcDateTime = DateTime.UtcNow;

            await _dbCommand.UpdateAsync(created.Id, created);

            var updated = await _dbCommand.FindAsync(created.Id);

            updated.IsStructuralEqual(created);
        }
Esempio n. 2
0
        public async Task <ActionResult> EditPersonal(string id, PersonalStorageEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var storage = await _storageDbCommand.FindAsync(id);

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

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

            Mapper.Map(model, storage);
            storage.LastModifiedUtcDateTime = DateTime.UtcNow;

            try
            {
                BlobStorageConfig.Initialize(storage);
            }
            catch (SqlException exception)
            {
                ModelState.AddModelError("", exception.Message);
                return(View(model));
            }

            await _storageDbCommand.UpdateAsync(id, storage);

            return(RedirectToAction("Index"));
        }