Esempio n. 1
0
        public int Add(PlaylistModel playlist)
        {
            var item = playlist.ToEntity();
            var added = _playListRepository.Insert(item);

            if (!String.IsNullOrEmpty(playlist.Tags))
            {
                _playlistTagService.SaveMapping(playlist.Tags, added.Id);
            }
            if (playlist.Files.Count > 0 & playlist.Files[0] != null)
            {
                _playlistFileService.AddMapping(playlist.Files, added.Id);
            }
            return added.Id;
        }
Esempio n. 2
0
        public void Update(PlaylistModel playlist)
        {
            var entity = playlist.ToEntity();

            _playListRepository.Update(entity);

            if (!String.IsNullOrEmpty(playlist.Tags))
            {
                _playlistTagService.SaveMapping(playlist.Tags, entity.Id);
            }
            if (playlist.Files.Count > 0 & playlist.Files[0] != null)
            {
                _playlistFileService.AddMapping(playlist.Files, playlist.Id);
            }
        }
        public ActionResult Edit(PlaylistModel model)
        {
            if (model != null & ModelState.IsValid)
            {
                if (model.Id == 0)
                {
                    model.CreatedBy = _userService.GetCurrentUserId();
                    _playlistService.Add(model);
                }
                else
                {
                    _playlistService.Update(model);
                }
                return RedirectToAction("ListAdmin", "Playlist");
            }

            return View(model);
        }