Exemple #1
0
        public static async Task <string> SaveScreenshotAndGetUrl(IHostingEnvironment env, IImageRepository img_repo, Images img, string resource_id)
        {
            bool result = true;

            DataProvider.DbResult dbResult = null;
            string igdb     = "https://images.igdb.com/igdb/image/upload/";
            string fileName = string.Format("{0}.jpg", Guid.NewGuid().ToString());

            img.ImageType = Constant.ImageType.Medium;
            img.Url       = string.Format("/{0}/{1}/{2}/{3}", Constant.Resources, img.ImageOf, img.ImageType, fileName);
            result        = await SaveImageAndGetUrl(env, string.Format("{0}/{1}/{2}.jpg", igdb, Constant.ImageType.IGdb.Medium, resource_id), img.ImageType, img.ImageOf, fileName);

            if (result)
            {
                dbResult = await img_repo.Add_New_ImageAsync(img);
            }

            img.ImageType = Constant.ImageType.Large;
            img.Url       = string.Format("/{0}/{1}/{2}/{3}", Constant.Resources, img.ImageOf, img.ImageType, fileName);
            result        = await SaveImageAndGetUrl(env, string.Format("{0}/{1}/{2}.jpg", igdb, Constant.ImageType.IGdb.Large, resource_id), img.ImageType, img.ImageOf, fileName);

            if (result)
            {
                dbResult = await img_repo.Add_New_ImageAsync(img);
            }

            return(fileName);
        }