Example #1
0
        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();
            }
        }
Example #2
0
        public async Task <UserOption> GetUserOptions()
        {
            UserOption userOption = await context.UserOptions.SingleOrDefaultAsync();

            if (userOption == null)
            {
                userOption = new UserOption();
            }

            return(userOption);
        }
Example #3
0
        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();
        }