コード例 #1
0
ファイル: CartController.cs プロジェクト: alexpopescu021/PAW
        public IActionResult Remove([FromRoute] string Id)
        {
            RemoveSongViewModel removeViewModel = new RemoveSongViewModel()
            {
                Id = Id
            };

            return(PartialView("_RemoveSongPartial", removeViewModel));
        }
コード例 #2
0
        public IActionResult Remove(RemoveSongViewModel removeData)
        {
            songService.RemoveSong(removeData.Id);


            return(RedirectToAction("Index"));

            //return PartialView("_RemoveSongPartial", removeData);
        }
コード例 #3
0
        public IActionResult Remove(RemoveSongViewModel removeData)
        {
            var song = songService.GetSongById(removeData.Id);

            context.Wishlist.FirstOrDefault().Songs.Remove(song);

            context.SaveChanges();
            return(RedirectToAction("Index"));

            //return PartialView("_RemoveSongPartial", removeData);
        }
コード例 #4
0
ファイル: CartController.cs プロジェクト: alexpopescu021/PAW
        public IActionResult Remove(RemoveSongViewModel removeData)
        {
            var song = songService.GetSongById(removeData.Id);

            context.Carts.FirstOrDefault().Songs.Remove(song);
            song.NumberInCart = 0;
            context.Carts.FirstOrDefault().total -= song.Price;
            context.SaveChanges();
            return(RedirectToAction("Index"));

            //return PartialView("_RemoveSongPartial", removeData);
        }
コード例 #5
0
        public IActionResult AddToWishlist([FromRoute] string id)
        {
            RemoveSongViewModel removeViewModel = new RemoveSongViewModel()
            {
                Id = id
            };
            var song     = songService.GetSongById(id);
            var wishlist = context.Wishlist.FirstOrDefault();

            wishlist.Songs.Add(song);

            context.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #6
0
ファイル: CartController.cs プロジェクト: alexpopescu021/PAW
        public IActionResult Add([FromRoute] string id)
        {
            RemoveSongViewModel removeViewModel = new RemoveSongViewModel()
            {
                Id = id
            };
            var song = songService.GetSongById(id);
            var cart = context.Carts.FirstOrDefault();


            if (cart.Songs.Any(p => p.Id.ToString() == id))
            {
                song.NumberInCart++;
                context.Carts.FirstOrDefault().total += song.Price;
            }
            context.SaveChanges();

            return(RedirectToAction("Index"));
        }