public async Task ResetUserOptions(UserOption userOption) { //get the options bool exists = await context.UserOptions.AnyAsync(x => x.UserOptionID == userOption.UserOptionID); if (exists) { context.UserOptions.Remove(userOption); await context.SaveChangesAsync(); } }
public async Task <UserOption> GetUserOptions() { UserOption userOption = await context.UserOptions.SingleOrDefaultAsync(); if (userOption == null) { userOption = new UserOption(); } return(userOption); }
public async Task UpdateUserOptions(UserOption userOption) { UserOption existingUserOption = context.UserOptions.Find(userOption.UserOptionID); if (existingUserOption == null) { context.Add(userOption); } else { context.Entry(existingUserOption).CurrentValues.SetValues(userOption); context.Update(existingUserOption); } await context.SaveChangesAsync(); }