예제 #1
0
        public void RemoveProviderUser(int providerID, string providerPortalUsersConnectionString)
        {
            var legacyProviderService = new Data.Services.ProviderService();
            var legacyProvider        = legacyProviderService.GetProvider(providerID);

            if (legacyProvider.PortalUser == null)
            {
                return;
            }

            var legacyPortalUser = legacyProvider.PortalUser;

            using (SqlConnection conn = new SqlConnection(providerPortalUsersConnectionString))
                using (SqlCommand cmd = new SqlCommand()) {
                    cmd.Connection  = conn;
                    cmd.CommandText =
                        "DELETE FROM dbo.UserProfile WHERE UserId = @AspNetID;" +
                        "DELETE FROM dbo.webpages_Membership WHERE UserId = @AspNetID;";
                    cmd.Parameters.AddWithValue("@AspNetID", legacyPortalUser.AspNetUserID);
                    cmd.ExecuteNonQueryToInt();
                }

            var portalUser = _context.ProviderPortalUsers.Find(legacyPortalUser.ID);

            if (portalUser != null)
            {
                _context.ProviderPortalUsers.Remove(portalUser);
                _context.SaveChanges();
            }
        }
예제 #2
0
        public Provider GetProvider(int providerID)
        {
            var providerService = new Data.Services.ProviderService();

            return(providerService.GetProvider(providerID));
        }