public void Execute(IEditOdsInstanceRegistrationForUserModel model)
        {
            using (var database = AdminAppIdentityDbContext.Create())
            {
                var preexistingAssociations = database.UserOdsInstanceRegistrations.Where(x => x.UserId == model.UserId).ToList();

                var selectedOdsInstanceRegistrationIds =
                    model.OdsInstanceRegistrations.Where(x => x.Selected).Select(x => x.OdsInstanceRegistrationId).ToList();

                var recordsToAdd = NewAssignments(model.UserId, selectedOdsInstanceRegistrationIds, preexistingAssociations);

                if (recordsToAdd.Any())
                {
                    database.UserOdsInstanceRegistrations.AddRange(recordsToAdd);
                }

                var recordsToRemove = AssignmentsToRemove(selectedOdsInstanceRegistrationIds, preexistingAssociations);

                if (recordsToRemove.Any())
                {
                    database.UserOdsInstanceRegistrations.RemoveRange(recordsToRemove);
                }

                database.SaveChanges();
            }
        }
        public void Execute(IEditOdsInstanceRegistrationForUserModel model)
        {
            var preexistingAssociations = _identity.UserOdsInstanceRegistrations.Where(x => x.UserId == model.UserId).ToList();

            var selectedOdsInstanceRegistrationIds =
                model.OdsInstanceRegistrations.Where(x => x.Selected).Select(x => x.OdsInstanceRegistrationId).ToList();

            var recordsToAdd = NewAssignments(model.UserId, selectedOdsInstanceRegistrationIds, preexistingAssociations);

            if (recordsToAdd.Any())
            {
                _identity.UserOdsInstanceRegistrations.AddRange(recordsToAdd);
            }

            var recordsToRemove = AssignmentsToRemove(selectedOdsInstanceRegistrationIds, preexistingAssociations);

            if (recordsToRemove.Any())
            {
                _identity.UserOdsInstanceRegistrations.RemoveRange(recordsToRemove);
            }

            _identity.SaveChanges();
        }