コード例 #1
0
ファイル: HomeController.cs プロジェクト: Riflly/MusicAPI
        public async Task <IActionResult> UserPlaylistCreate(UserPlaylist userPlaylist)
        {
            // Request.Cookies.
            // PlaylistId = context.TblUserPlaylist.Count() +1,
            if (ModelState.IsValid)
            {
                UserPlaylist playlist = new UserPlaylist
                {
                    PlaylistName = userPlaylist.PlaylistName,
                    PlaylistDesc = userPlaylist.PlaylistDesc,
                    UserId       = userPlaylist.UserId
                };
                //   string id = Request.Cookies["UserName"];

                //playlist.UserId = 1;

                bool result = await repo.CreateUserPlaylist(userPlaylist);

                if (result)
                {
                    //return View("Index");
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "An error occured while creating the UserPlaylist");
                }
            }
            return(View(userPlaylist));
        }