diff --git a/Modules/BetterCms.Module.Viddler/BetterCms.Module.Viddler.csproj b/Modules/BetterCms.Module.Viddler/BetterCms.Module.Viddler.csproj
index 6f80b5c6d..7fc45b23d 100644
--- a/Modules/BetterCms.Module.Viddler/BetterCms.Module.Viddler.csproj
+++ b/Modules/BetterCms.Module.Viddler/BetterCms.Module.Viddler.csproj
@@ -119,6 +119,8 @@
+
+
diff --git a/Modules/BetterCms.Module.Viddler/Command/SaveVideo/SaveVideoCommand.cs b/Modules/BetterCms.Module.Viddler/Command/SaveVideo/SaveVideoCommand.cs
new file mode 100644
index 000000000..bf9eb6577
--- /dev/null
+++ b/Modules/BetterCms.Module.Viddler/Command/SaveVideo/SaveVideoCommand.cs
@@ -0,0 +1,46 @@
+using System;
+
+using BetterCms.Core.Mvc.Commands;
+using BetterCms.Module.MediaManager.Models;
+using BetterCms.Module.Root.Mvc;
+using BetterCms.Module.Viddler.Models;
+using BetterCms.Module.Viddler.Services;
+
+namespace BetterCms.Module.Viddler.Command.Videos.SaveVideos
+{
+ internal class SaveVideoCommand : CommandBase, ICommand
+ {
+ private readonly IViddlerService viddlerService;
+
+ public SaveVideoCommand(IViddlerService viddlerService)
+ {
+ this.viddlerService = viddlerService;
+ }
+
+ public Video Execute(SaveVideoRequest request)
+ {
+ var sesionId = viddlerService.GetSessionId();
+ var data = viddlerService.GetVideoDetails(sesionId, request.VideoId);
+ var video = new Video
+ {
+ OriginalFileName = data.Title,
+ OriginalFileExtension = string.Empty,
+ FileUri = new Uri(viddlerService.GetPlayerUrl(data.Id)),
+ PublicUrl = viddlerService.GetVideoUrl(data.Id),
+ Size = data.Length,
+ IsTemporary = true,
+ IsUploaded = data.IsReady,
+ Title = data.Title,
+ Type = MediaType.Video,
+ ContentType = MediaContentType.File,
+ PublishedOn = DateTime.Now,
+ Description = data.Description,
+ VideoId = data.Id,
+ ThumbnailUrl = data.ThumbnailUrl,
+ };
+ Repository.Save(video);
+ UnitOfWork.Commit();
+ return video;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Modules/BetterCms.Module.Viddler/Command/SaveVideo/SaveVideoRequest.cs b/Modules/BetterCms.Module.Viddler/Command/SaveVideo/SaveVideoRequest.cs
new file mode 100644
index 000000000..be52636e6
--- /dev/null
+++ b/Modules/BetterCms.Module.Viddler/Command/SaveVideo/SaveVideoRequest.cs
@@ -0,0 +1,7 @@
+namespace BetterCms.Module.Viddler.Command.Videos.SaveVideos
+{
+ public class SaveVideoRequest
+ {
+ public string VideoId { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Modules/BetterCms.Module.Viddler/Command/SaveVideos/SaveVideosCommand.cs b/Modules/BetterCms.Module.Viddler/Command/SaveVideos/SaveVideosCommand.cs
index 93073a499..1c1803093 100644
--- a/Modules/BetterCms.Module.Viddler/Command/SaveVideos/SaveVideosCommand.cs
+++ b/Modules/BetterCms.Module.Viddler/Command/SaveVideos/SaveVideosCommand.cs
@@ -4,78 +4,96 @@
using BetterCms.Core.Mvc.Commands;
using BetterCms.Module.MediaManager.Models;
+using BetterCms.Module.MediaManager.Models.Extensions;
using BetterCms.Module.MediaManager.ViewModels.MediaManager;
using BetterCms.Module.Root.Mvc;
-using BetterCms.Module.Viddler.Services;
+using BetterCms.Module.Viddler.Models;
namespace BetterCms.Module.Viddler.Command.Videos.SaveVideos
{
internal class SaveVideosCommand : CommandBase, ICommand
{
- private readonly IViddlerService viddlerService;
-
- public SaveVideosCommand(IViddlerService viddlerService)
- {
- this.viddlerService = viddlerService;
- }
-
public SaveVideosResponse Execute(SaveVideosRequest request)
{
- var response = new SaveVideosResponse() { SelectedFolderId = request.FolderId };
- MediaFolder folder = null;
- if (!request.FolderId.HasDefaultValue())
+ var response = new SaveVideosResponse { SelectedFolderId = request.SelectedFolderId ?? Guid.Empty, ReuploadMediaId = request.ReuploadMediaId };
+
+ if (request.UploadedFiles != null && request.UploadedFiles.Count > 0)
{
- folder = Repository.AsProxy(request.FolderId);
- if (folder.IsDeleted)
+ MediaFolder folder = null;
+
+ if (request.SelectedFolderId != null && request.SelectedFolderId.Value != Guid.Empty)
{
- response.FolderIsDeleted = true;
- return response;
+ folder = Repository.AsProxy(request.SelectedFolderId.Value);
+ if (folder.IsDeleted)
+ {
+ response.FolderIsDeleted = true;
+ return response;
+ }
}
- }
- List medias = new List();
- UnitOfWork.BeginTransaction();
+ UnitOfWork.BeginTransaction();
- // TODO: implement.
+ var files = new List