More in this section

Forums / Bugs & Issues / Image Draft / Publish and Deleting

Image Draft / Publish and Deleting

8 posts, 0 answered
  1. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    23 Feb 2011
    Link to this post
    In the documentation it says that savechanges process all the items marked for deletion, but I see that they are still in draft mode.
    Also, when uploading an image and using .CheckOut().UploadContent(uploadedFile.InputStream, uploadedFile.GetExtension()).CheckInAndPublish().SaveChanges(); the image says it is in Draft, but the Icon has the check mark like it is published... which one is it? See the attached image.

    Note that the method only marks the items for deletion, while SaveChanges() runs the transactions and processes all marked items. Having that said, you may delete multiple images, before running theSaveChanges() method

    http://www.sitefinity.com/40/help/developer-manual/modules-built-in-modules-api-media-modules-images-managing-images-deleting-images.html
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    28 Feb 2011
    Link to this post
    Hi Kristian,

    Can you try to use CheckInAndPublish only.

    CheckIn() - Makes the changes in the temp by copying it to the draft. The item is no longer locked and the temp is deleted.

    Publish() - Publish the content item by making the item visible on the frontend

    Greetings,
    Ivan Dimitrov
    the Telerik team
  3. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    28 Feb 2011
    Link to this post
    I am using CheckInAndPublish Here is my code

    Upload Image
    using (var sf = App.Prepare().SetTransactionName("UploadImageTransaction").WorkWith())
    {
            try
                    {
                       
                        sf.Albums().GetManager().Provider.SuppressSecurityChecks = true;
     
                        sf.Album(albumToLoc.Id).CreateImage().Do(item =>
                        {
                            // Upload the image with the appropriate info.
                            item.Title = imageTitle;
                            item.Description = imageDescription;
                        }).CheckOut().UploadContent(uploadedFile.InputStream, uploadedFile.GetExtension()).CheckInAndPublish().SaveChanges();
     
     
                       
                        sf.Albums().GetManager().Provider.SuppressSecurityChecks = false;
                    }
            catch (Exception fex)
                    {
                       
                        sf.Albums().GetManager().Provider.SuppressSecurityChecks = false;
                    }
    }

    Delete image
    // Delete the image based on its Id.
                LibrariesManager libManager = LibrariesManager.GetManager();
                Telerik.Sitefinity.Libraries.Model.Image imageToDelete = libManager.GetImages()
                                            .Where(img => img.Id == imageId)
                                            .Single();
     
                libManager.Provider.SuppressSecurityChecks = true;
                libManager.DeleteImage(imageToDelete);
     
                 
     
                 
                libManager.SaveChanges();
                libManager.Provider.SuppressSecurityChecks = false;
  4. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    03 Mar 2011
    Link to this post
    Is there any update on this?
  5. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    14 Mar 2011
    Link to this post
    Hi Kristian,

    The problem is that you are getting a Single item. This will not necessary delete the master version the item. try using the delete method without getting single item. Generraly an item will have 3 states - draft, live and master.

    Regards,
    Radoslav Georgiev
    the Telerik team
  6. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    14 Mar 2011
    Link to this post
    Ok I tried a couple other ways and I haven't managed to get it to work. If I don't use Single() or SingleOrDefault() I get an error, I can't leave it blank...

    I even tried using the fluent API as well and get the same result
    App.WorkWith()
                   .Images()
                   .Where(i => i.Id == imageId)
                   .Delete()
                   .SaveChanges();
  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Mar 2011
    Link to this post
    Hello Kristian,

    Can you try this:
    App.WorkWith().Image(imageId).Delete();


    Best wishes,
    Radoslav Georgiev
    the Telerik team
  8. Kristian
    Kristian avatar
    214 posts
    Registered:
    03 Jun 2010
    17 Mar 2011
    Link to this post
    This hasn't worked for me, I have opened a ticket with my attached control.
8 posts, 0 answered