public async Task <IActionResult> UpdateSettings(SettingsModel settingsModel) { User user = await userManager.GetUserAsync(User); Settings prevSettings = context.Settings.Find(user.Id); Settings settings = new Settings { UserId = user.Id, HoursPerDay = settingsModel.HoursPerDay, CardsPerDay = settingsModel.CardsPerDay, CardsOrder = Int32.Parse(settingsModel.CardsOrder), DarkTheme = settingsModel.DarkTheme, ShowImages = settingsModel.ShowImages }; if (prevSettings != null) { context.Remove(prevSettings); } await context.AddAsync(settings); await context.SaveChangesAsync(); return(View(nameof(Settings), settingsModel)); }
public async Task <IActionResult> DeleteDeck(long deckId) { var user = await _userManager.GetUserAsync(User); var deck = await _context.Decks.FindAsync(deckId); if (deck.CreatorId == user.Id) { _context.Remove(deck); _context.SaveChanges(); return(RedirectToAction(nameof(ChooseDeck))); } return(BadRequest()); }