public IActionResult Create() { PlayListCreateViewModel model = new PlayListCreateViewModel(); var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId); model.UserName = _currentMediaUser.UserName; return(View(model)); }
public IActionResult Create(PlayListCreateViewModel model) { var currentUserId = this._signInManager.UserManager.GetUserId(HttpContext.User); _currentMediaUser = _mediaService.GetAllMediaUsers().First(p => p.Id == currentUserId); var newPlayList = new PlayList() { Name = model.Name, MediaList = new List <Media>(), MediaUser = _currentMediaUser, MediaUserId = currentUserId }; _currentMediaUser.Playlists.Add(newPlayList); _mediaService.SaveChanges(); return(RedirectToAction("Index")); }