public async Task<IHttpActionResult> UpdateSet(StorageObject[] cloudObjects)
        {
            if (!cloudObjects.Any())
                return Ok();
            
            foreach (var cloudObject in cloudObjects)
            {
                var entity = await AppDatabase.Storage.FindAsync(cloudObject.ObjectId);

                if (entity == null)
                {
                    cloudObject.ModifiedOn = cloudObject.CreatedOn = DateTime.UtcNow;

                    AppDatabase.Storage.Add(cloudObject);
                }
                else
                {
                    // ACL
                    switch (entity.AclType)
                    {
                        case StorageACLType.Admin:
                            if (!User.Identity.IsAuthenticated)
                                return Unauthorized();
                            break;
                        case StorageACLType.User:
                            if (UserId != entity.AclParam)
                                return Unauthorized();
                            break;
                    }

                    if (entity.ObjectType != cloudObject.ObjectType)
                    {
                        //would cause caching errors
                        return BadRequest("Can not change object type");
                    }

                    entity.ModifiedOn = DateTime.UtcNow;
                    entity.ObjectData = cloudObject.ObjectData;
                    entity.ObjectScore = cloudObject.ObjectScore;
                }
            }
            
            await AppDatabase.SaveChangesAsync();

            return Ok();
        }
        public async Task<IHttpActionResult> Update(StorageObject cloudObject)
        {
            var entity = await AppDatabase.Storage.FindAsync(cloudObject.ObjectId);

            if (entity == null)
                return await Create(cloudObject);

            // ACL
            switch (entity.AclType)
            {
                case StorageACLType.Admin:
                    if (!User.Identity.IsAuthenticated)
                        return Unauthorized();
                    break;
                case StorageACLType.User:
                    if (UserId != entity.AclParam)
                        return Unauthorized();
                    break;
            }

            if (entity.ObjectType != cloudObject.ObjectType)
            {
                //would cause caching errors
                return BadRequest("Can not change object type");
            }

            entity.ModifiedOn = DateTime.UtcNow;
            entity.ObjectData = cloudObject.ObjectData;
            entity.ObjectScore = cloudObject.ObjectScore;

            //  Context.Update(entity);
            await AppDatabase.SaveChangesAsync();

            return Ok(entity.GetData());
        }
        public async Task<IHttpActionResult> Sync(StorageObject cloudObject)
        {
            var entity = await AppDatabase.Storage.FindAsync(cloudObject.ObjectId);

            // create ?
            if (entity == null)
                return await Create(cloudObject);
            
            // Update if newer
            if (entity.ModifiedOn < cloudObject.ModifiedOn)
                return await Update(cloudObject);

            // return old
            return Ok(entity.GetData());
        }
        public async Task<IHttpActionResult> Create(StorageObject cloudObject)
        {
            cloudObject.ModifiedOn = cloudObject.CreatedOn = DateTime.UtcNow;

            var entity = await AppDatabase.Storage.FindAsync(cloudObject.ObjectId);
            if (entity != null)
                return BadRequest("ObjectId is in use");

            AppDatabase.Storage.Add(cloudObject);
            await AppDatabase.SaveChangesAsync();

            return Ok(cloudObject.GetData());
        }