//ToanTXSE
        //Get playlist List by location ID
        public static List <Models.PlaylistDetailVM> GetPlaylistIdByBrandIdAndStatus()
        {
            IPlaylistService     playlistService     = DependencyUtils.Resolve <IPlaylistService>();
            IPlaylistItemService playlistItemService = DependencyUtils.Resolve <IPlaylistItemService>();
            IBrandService        brandService        = DependencyUtils.Resolve <IBrandService>();
            var mapper           = DependencyUtils.Resolve <IMapper>();
            var user             = Helper.GetCurrentUser();
            var playlistList     = playlistService.GetPlaylistIdByBrandId(user.BrandID);
            var playlistDetailVM = new List <Models.PlaylistDetailVM>();

            foreach (var item in playlistList)
            {
                if (item.isPublic == true)
                {
                    var m = new Models.PlaylistDetailVM
                    {
                        Title        = item.Title,
                        Description  = item.Description,
                        Id           = item.PlaylistID,
                        isPublic     = (bool)item.isPublic,
                        Duration     = playlistItemService.GetTotalDuration(item.PlaylistID),
                        VisualTypeID = item.VisualTypeID ?? 1,
                    };
                    playlistDetailVM.Add(m);
                }
            }
            //playlistDetailVM = playlistList.Select(mapper.Map<Playlist, Models.PlaylistDetailVM>).ToList();
            return(playlistDetailVM);
        }
 public JsonResult CheckMediaIdIsUsed(int id)
 {
     try
     {
         //Get device by screen Id
         IPlaylistItemService playlistItemService = DependencyUtils.Resolve <IPlaylistItemService>();
         IPlaylistService     playlistService     = DependencyUtils.Resolve <IPlaylistService>();
         var playlistItem    = playlistItemService.Get().ToList();
         var playlist        = playlistService.Get().ToList();
         var playlistItemVMs = new List <Models.PlaylistItemVM>();
         var playlistVMs     = new List <Models.PlaylistDetailVM>();
         //check mediaSrcId have in playlistItem
         foreach (var item in playlistItem)
         {
             if (item.MediaSrcID == id)
             {
                 var b = new Models.PlaylistItemVM
                 {
                     playlistId = item.PlaylistID,
                 };
                 playlistItemVMs.Add(b);
             }
         }
         // if playlistItemVMs != null, get Playlist Title by playlistID
         if (playlistItemVMs.Count != 0)
         {
             foreach (var item in playlistItemVMs)
             {
                 foreach (var itemPlaylist in playlist)
                 {
                     if (item.playlistId == itemPlaylist.PlaylistID)
                     {
                         var b = new Models.PlaylistDetailVM
                         {
                             Title = itemPlaylist.Title,
                         };
                         playlistVMs.Add(b);
                     }
                 }
             }
         }
         return(Json(new
         {
             isUsing = playlistItemVMs.Count != 0,
             playlistVMlist = playlistVMs,
         }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 // GET: Playlist/Form/:id
 public ActionResult Form(int?id, string imageId)
 {
     Models.PlaylistDetailVM model = null;
     if (id != null)
     {
         var playlist = this.playlistService.Get(id);
         if (playlist != null)
         {
             model = new Models.PlaylistDetailVM
             {
                 Title       = playlist.Title,
                 Description = playlist.Description,
                 Id          = playlist.PlaylistID,
                 isPublic    = (bool)playlist.isPublic,
             };
         }
     }
     ViewBag.visualTypeList = GetVisualTypes();
     ViewBag.mediaSrcList   = MediaSrcController.GetMediaSrcListByBrandIdAndStatus();
     ViewBag.itemList       = GetMediaSrcListByPlaylistId(id ?? default(int));
     return(View("Form", model));
 }