Exemplo n.º 1
0
        public override async Task Execute()
        {
            await Authorize();

            var result = await SimpleClient.Apps();

            Log.Debug(result);

            UpdateAuthorization();
        }
Exemplo n.º 2
0
        public override async Task Execute()
        {
            await Authorize();

            if (string.IsNullOrEmpty(Id))
            {
                return;
            }
            Guid g;

            if (Guid.TryParse(Id, out g))
            {
                var apps = await SimpleClient.Apps();

                var app = (from a in apps.Response.Data where a.Id == g select a).FirstOrDefault();
                if (app == null)
                {
                    Log.Debug("Could not find app with the id:{0}", g);
                    return;
                }
                var updateApp = false;
                if (!string.IsNullOrEmpty(Name))
                {
                    app.Name  = Name;
                    updateApp = true;
                }
                if (!string.IsNullOrEmpty(Description))
                {
                    app.Description = Description;
                    updateApp       = true;
                }
                if (RedirectUris != null && RedirectUris.Length > 0)
                {
                    app.RedirectUris = RedirectUris.ToList();
                    updateApp        = true;
                }
                if (updateApp)
                {
                    var result = await SimpleClient.UpdateApp(app);

                    Log.Debug(result);
                }
                if (!string.IsNullOrEmpty(Image) && File.Exists(Image))
                {
                    Log.Debug("Updating app image");
                    var image       = File.ReadAllBytes(Image);
                    var fi          = new FileInfo(Image);
                    var imageResult = await SimpleClient.SaveImage(ImageEntities.Apps, g, image, fi.Name, "image/" + fi.Extension);

                    Log.Debug(imageResult);

                    if (imageResult.Success)
                    {
                        var images = await SimpleClient.GetImage(ImageEntities.Apps, g);

                        Log.Debug(images);
                    }
                }
            }
            else
            {
                Log.Debug("Invalid app id specified");
            }
            UpdateAuthorization();
        }