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)); }
// This handles the index logic private dynamic index() { User user = fetchuser(); if (user == null) { // Check to make sure user is logged in return(user_login()); } // Navbar ViewBag ViewBag.user_name = user.name(); //ViewBag.user_wallet = user.Money; ViewBag.userid = user.Id; // General Viewbag settings ViewBag.dashboard = true; SongWrapper songwrapper = new SongWrapper(_context.PopulateSongsAllOrderbyCreatedAt(), new Song()); // Return the view of index with list of auctions attached return(View(songwrapper)); }
public async Task LoadAsync(int?songId) { var song = songId.HasValue ? await _songRepository.GetByIdAsync(songId.Value) : CreateNewSong(); Song = new SongWrapper(song); Song.PropertyChanged += (s, e) => { if (!HasChanges) { HasChanges = _songRepository.HasChanges(); } if (e.PropertyName == nameof(Song.HasErrors)) { ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); } }; ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); if (Song.Id == 0) { Song.Name = ""; } }