Guest User

Untitled

a guest
Mar 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. public static void CreateImageTranslationUsingExistingFileFluentAPI(CultureInfo culture, Guid masterImageId, string title, CultureInfo sourceCulture)
  2. {
  3. // Ensure we are working in the correct culture.
  4. using (new CultureRegion(culture))
  5. {
  6. var count = 0;
  7.  
  8. App.WorkWith().Images().Where(i => i.Id == masterImageId).Count(out count);
  9.  
  10. if (count > 0)
  11. {
  12. App.WorkWith().Image(masterImageId).CheckOut().CopyUploadedContent(sourceCulture).Do(image =>
  13. {
  14. image.Title = title;
  15. image.LastModified = DateTime.UtcNow;
  16. image.UrlName = Regex.Replace(title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
  17. }).CheckIn().SaveChanges();
  18.  
  19. // Publish the image.
  20. var bag = new Dictionary<string, string>();
  21. bag.Add("ContentType", typeof(Image).FullName);
  22. WorkflowManager.MessageWorkflow(masterImageId, typeof(Image), null, "Publish", false, bag);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment