Ejemplo n.º 1
0
        public IActionResult Add(Song song)
        {
            Console.WriteLine("This is the add Song method");
            // Fetch the current user
            User user = fetchuser();

            // Check model validations
            if (ModelState.IsValid)
            {
                Console.WriteLine("Validations passed");
                // Add the table and save the changes
                _context.Songs.Add(song);
                _context.SaveChanges();
                // Render the View with the User model
                return(RedirectToAction("Index"));
            }
            // Navbar variables
            ViewBag.user_name = user.name();
            // General Viewbag settings
            ViewBag.dashboard = true;
            // Return the original Index
            SongWrapper songwrapper = new SongWrapper(_context.PopulateSongsAllOrderbyCreatedAt(), song);

            // Return the view of index with list of auctions attached
            return(View("Index", songwrapper));
        }