public string CloudUploadEdit(Course course)
        {
            if (HandleFileUpload(ref course))
            {
                var courseCurrentPicture = db.Courses.Select(x => x.PictureUrl);
                var array = courseCurrentPicture.ToArray();
                var lastElement = array[array.Length - 1];
                Account acount = new Account("gigantor", "986286566519458", "GT87e1BTMnfLut1_gXhSH0giZPg");
                Cloudinary cloudinary = new Cloudinary(acount);

                if (lastElement != null && course.PictureUrl.StartsWith("http://res.cloudinary.com/gigantor/image/upload/"))  //this block of code deletes the previous image if the user had one
                {
                    //this here is just a string manipulation to get to the ImageID from cloudinary
                    string assist = "http://res.cloudinary.com/gigantor/image/upload/";
                    string part1 = lastElement.Remove(lastElement.IndexOf(assist), assist.Length);
                    string part2 = part1.Remove(0, 12);
                    string toDelete = part2.Remove(part2.Length - 4);
                    cloudinary.DeleteResources(toDelete);  //this finally deletes the image
                }
                   
                course.PictureUrl = CloudinaryUpload(course);
            
                return course.PictureUrl;
            }

            course.PictureUrl = "http://res.cloudinary.com/gigantor/image/upload/v1441017337/wwgb50xuqulq7utflsjo.gif";
            return course.PictureUrl;
        }
Ejemplo n.º 2
0
        public static DelResResult DeleteResources(this Cloudinary cloudinary, params string[] publicIds)
        {
            var parameters = new DelResParams();

            parameters.PublicIds.AddRange(publicIds);
            return(cloudinary.DeleteResources(parameters));
        }
        public string CloudUpload(Models.RegisterBindingModel user)
        {
            if (HandleFileUpload(ref user))
            {
                Account acount = new Account("gigantor", "986286566519458", "GT87e1BTMnfLut1_gXhSH0giZPg");
                Cloudinary cloudinary = new Cloudinary(acount);

                string userId = this.User.Identity.GetUserId();
                ApplicationUser user1 = db.Users.Find(userId);
                if (user1.ProfilePicUrl != null && user1.ProfilePicUrl.StartsWith("http://res.cloudinary.com/gigantor/image/upload/"))  //this block of code deletes the previous image if the user had one
                {
                    //this here is just a string manipulation to get to the ImageID from cloudinary
                    string assist = "http://res.cloudinary.com/gigantor/image/upload/";
                    string part1 = user1.ProfilePicUrl.Remove(user1.ProfilePicUrl.IndexOf(assist), assist.Length);
                    string part2 = part1.Remove(0, 12);
                    string toDelete = part2.Remove(part2.Length - 4);
                    cloudinary.DeleteResources(toDelete);  //this finally deletes the image
                }

                user1.ProfilePicUrl = CloudinaryUpload(user);
                db.Entry(user1).State = EntityState.Modified;
                db.SaveChanges();
                return user1.ProfilePicUrl;
            }
            return user.ProfileUrl;
        }
Ejemplo n.º 4
0
        public void DeleteImage(List <string> publicId)
        {
            var settings = ConfigurationManager.AppSettings;

            CloudinaryDotNet.Account account =
                new CloudinaryDotNet.Account(settings["cloudinary.cloud"], settings["cloudinary.apikey"], settings["cloudinary.apisecret"]);

            CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary(account);
            foreach (var item in publicId)
            {
                cloudinary.DeleteResources(item);
            }
        }
Ejemplo n.º 5
0
        public void DeleteCloudinaryRecipeImage(string imageName)
        {
            CloudinaryDotNet.Cloudinary cloudinaryDelete = new CloudinaryDotNet.Cloudinary(cloudinaryAccount);

            var delParams = new DelResParams()
            {
                PublicIds = new List <string>()
                {
                    Path.GetFileNameWithoutExtension(imageName)
                },
                Invalidate = true
            };
            DelResResult result = cloudinaryDelete.DeleteResources(delParams);
        }
Ejemplo n.º 6
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            LinkButton Delete = (LinkButton)sender;
            string imageID = Delete.CommandArgument;

            HEWDataContext context = new HEWDataContext();
            ProjectsImage image = context.ProjectsImages.SingleOrDefault(i=>i.ID == int.Parse(imageID));

            Account account = new Account("dlyvxs7of", "634626974285569", "FtB_0jhcmFypFS7QTwCBKcPRGzE");
            Cloudinary cloudinary = new Cloudinary(account);
            cloudinary.DeleteResources(new [] {image.ImgPublicID});

            context.ProjectsImages.DeleteOnSubmit(image);
            context.SubmitChanges();

            rptImages.DataBind();
        }
Ejemplo n.º 7
0
        public ActionResult DeleteImage(int id)
        {
            Image imageToDelete = imageDataBase.Images.Find(id);
            DelResParams deleteParams = new DelResParams()
            {
                PublicIds = new System.Collections.Generic.List<String>() { imageToDelete.PublicId },
                Invalidate = true
            };
            Cloudinary cloudinary = new Cloudinary(new Account(
            "raisky",
            "712813241936831",
            "Z9cprR-2l0R51ehGj5PIsUr2d3I"));

            cloudinary.DeleteResources(deleteParams);
            imageDataBase.Entry(imageToDelete).State = System.Data.Entity.EntityState.Deleted;
            imageDataBase.SaveChanges();
            return RedirectToAction("Task");
        }
Ejemplo n.º 8
0
        private string UploadImg(string picPublicId)
        {
            byte[] imageBytes = Convert.FromBase64String(hdnImage.Value);
            MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);

            Account account = new Account("dlyvxs7of", "634626974285569", "FtB_0jhcmFypFS7QTwCBKcPRGzE");

            Cloudinary cloudinary = new Cloudinary(account);
            if (!string.IsNullOrEmpty(picPublicId))
                cloudinary.DeleteResources(new string[] {picPublicId});

            ImageUploadParams uploadParams = new ImageUploadParams()
            {
                File = new FileDescription("file", ms),
            };

            ImageUploadResult result = cloudinary.Upload(uploadParams);
            return result.PublicId;
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Course course = db.Courses.Find(id);
            db.Courses.Remove(course);
            db.SaveChanges();

            //this block of code deletes the image from cloudinary, after the course is deleted
            Account acount = new Account("gigantor", "986286566519458", "GT87e1BTMnfLut1_gXhSH0giZPg");
            Cloudinary cloudinary = new Cloudinary(acount);

            if (course.PictureUrl != null && course.PictureUrl.StartsWith("http://res.cloudinary.com/gigantor/image/upload/")) 
            {
                //this here is just a string manipulation to get to the ImageID from cloudinary
                string assist = "http://res.cloudinary.com/gigantor/image/upload/";
                string part1 = course.PictureUrl.Remove(course.PictureUrl.IndexOf(assist), assist.Length);
                string part2 = part1.Remove(0, 12);
                string toDelete = part2.Remove(part2.Length - 4);
                cloudinary.DeleteResources(toDelete);  //this finally deletes the image
            }
            return RedirectToAction("Index");
        }
Ejemplo n.º 10
0
        public async Task <Dictionary <string, string> > RemoveAsync(IEnumerable <string> objectIds)
        {
            var result = await Task.Run(() => _cloudinary.DeleteResources(objectIds.ToArray()));

            return(result.Deleted);
        }
        public ActionResult DeleteConfirmed(string userId)
        {
            var user = db.Users.Find(userId);
            var role = db.Roles.Select(u => u.Users.Where(x => x.UserId == userId)).ToList();
            

            UserCascadeDeleteManager userManager = new UserCascadeDeleteManager();
            userManager.DeleteUserConnections(userId);

            db.Users.Remove(user);

            try   //ovo ovdje stoji jer ako neko pokusa izbrisat prvog admina sto je napravljen a ima vise od 2 admina padne ovdje, pa nek stoji ovo sad za sad
            {
                db.SaveChanges();
            }
            catch
            {
                return View("Error");
            }


            //this block of code deletes the image from cloudinary, after the course is deleted
            Account acount = new Account("gigantor", "986286566519458", "GT87e1BTMnfLut1_gXhSH0giZPg");
            Cloudinary cloudinary = new Cloudinary(acount);

            if (user.ProfilePicUrl != null && user.ProfilePicUrl.StartsWith("http://res.cloudinary.com/gigantor/image/upload/"))
            {
                //this here is just a string manipulation to get to the ImageID from cloudinary
                string assist = "http://res.cloudinary.com/gigantor/image/upload/";
                string part1 = user.ProfilePicUrl.Remove(user.ProfilePicUrl.IndexOf(assist), assist.Length);
                string part2 = part1.Remove(0, 12);
                string toDelete = part2.Remove(part2.Length - 4);
                cloudinary.DeleteResources(toDelete);  //this finally deletes the image
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 12
0
 public static DelResResult DeleteResourcesByTag(this Cloudinary cloudinary, string tag)
 {
     return(cloudinary.DeleteResources(new DelResParams {
         Tag = tag
     }));
 }
Ejemplo n.º 13
0
 public static DelResResult DeleteResourcesByPrefix(this Cloudinary cloudinary, string prefix, bool keepOriginal, string nextCursor)
 {
     return(cloudinary.DeleteResources(new DelResParams {
         Prefix = prefix, KeepOriginal = keepOriginal, NextCursor = nextCursor
     }));
 }
Ejemplo n.º 14
0
 public static DelResResult DeleteResourcesByPrefix(this Cloudinary cloudinary, string prefix)
 {
     return(cloudinary.DeleteResources(new DelResParams {
         Prefix = prefix
     }));
 }
Ejemplo n.º 15
0
 public static DelResResult DeleteAllResources(this Cloudinary cloudinary, bool keepOriginal, string nextCursor)
 {
     return(cloudinary.DeleteResources(new DelResParams {
         All = true, KeepOriginal = keepOriginal, NextCursor = nextCursor
     }));
 }
Ejemplo n.º 16
0
 public static DelResResult DeleteAllResources(this Cloudinary cloudinary)
 {
     return(cloudinary.DeleteResources(new DelResParams {
         All = true
     }));
 }
Ejemplo n.º 17
0
 public static DelResResult DeleteResourcesByTag(this Cloudinary cloudinary, string tag, bool keepOriginal, string nextCursor)
 {
     return(cloudinary.DeleteResources(new DelResParams {
         Tag = tag, KeepOriginal = keepOriginal, NextCursor = nextCursor
     }));
 }
Ejemplo n.º 18
0
 /// <summary>
 /// A convenience method for deleting an image in the test
 /// </summary>
 /// <param name="id">The ID of the image to delete</param>
 /// <returns>The results of the deletion</returns>
 protected DelResResult DeleteTestResource(String id)
 {
     return(m_cloudinary.DeleteResources(id));
 }