public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } _User = await _context.User.FindAsync(id); List <UserAccountTypeAssignment> uata = _context.UserAccountTypeAssignment.Where(u => u.User.UserID == _User.UserID).ToList(); Artist Artist = await _context.Artist.FindAsync(id); if (_User != null) { _context.User.Remove(_User); foreach (var ut in uata) { _context.UserAccountTypeAssignment.Remove(ut); } if (Artist != null) { _context.Artist.Remove(Artist); } await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Song.WordVec = NaturalLanguage.vector.VectorSpace.ToString(_textprocessor.Predict(Song.Lyrics)); _context.Attach(Song).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SongExists(Song.SongID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(User).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(User.UserID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.User.Add(User); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Artist = await _context.Artist.FindAsync(id); if (Artist != null) { _context.Artist.Remove(Artist); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { error = string.Join(" | ", ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage)); return(Page()); } Song.WordVec = NaturalLanguage.vector.VectorSpace.ToString(_textprocessor.PredictText(Song.Lyrics)); _context.Song.Add(Song); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Song = await _context.Song.FindAsync(id); if (Song != null) { string filepath = Path.Combine(Environment.CurrentDirectory, "wwwroot", Song.Filepath.TrimStart('/')); System.IO.File.Delete(filepath); _context.Song.Remove(Song); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task SaveChangesAsync() { await _context.SaveChangesAsync(); }
// To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { Song s = _context.Song.Where(x => x.SongID == Song.SongID).FirstOrDefault(); User user = _context.User.FirstOrDefault(u => u.Username == User.Identity.Name); Artist artist = _context.Artist.FirstOrDefault(a => a.ArtistID == user.UserID); Album a = _context.Album.Where(x => x.Name == Song.Album.Name && x.Artist.ArtistID == user.UserID).FirstOrDefault(); Genre g = _context.Genre.Where(x => x.Name == Song.Genre.Name).FirstOrDefault(); //if (a == null) //{ // Album Album = new Album // { // Name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Song.Album.Name), // Artist = artist // }; // Song.Album = Album; // _context.Album.Add(Album); //} //else //{ // Song.Album = a; //} //if (g == null) //{ // g = new Genre // { // Name = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Song.Genre.Name.ToLower()), // WordVec = Vspace.ConvertToString(_textprocessor.PredictText(Song.Genre.Name)) // }; // _context.Genre.Add(g); //} //Song.Genre = g; //Song.Filepath = ; Song.WordVec = VSpace.ConvertToString( VSpace.Normalize(VSpace.Add(_textprocessor.PredictText(Song.Lyrics), _textprocessor.PredictText(Song.Name)))); _context.Song.Update(s); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SongExists(Song.SongID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }