Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void CreateImageTranslationUsingExistingFileFluentAPI(CultureInfo culture, Guid masterImageId, string title, CultureInfo sourceCulture)
- {
- // Ensure we are working in the correct culture.
- using (new CultureRegion(culture))
- {
- var count = 0;
- App.WorkWith().Images().Where(i => i.Id == masterImageId).Count(out count);
- if (count > 0)
- {
- App.WorkWith().Image(masterImageId).CheckOut().CopyUploadedContent(sourceCulture).Do(image =>
- {
- image.Title = title;
- image.LastModified = DateTime.UtcNow;
- image.UrlName = Regex.Replace(title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
- }).CheckIn().SaveChanges();
- // Publish the image.
- var bag = new Dictionary<string, string>();
- bag.Add("ContentType", typeof(Image).FullName);
- WorkflowManager.MessageWorkflow(masterImageId, typeof(Image), null, "Publish", false, bag);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment