예제 #1
0
        public void RemoveAccount(int?id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("Null argument");
            }
            Account account = db.accounts.Find(id);

            RemovePersonData(id);

            RemoveUserSecurity(id);

            foreach (AccountSurvey accountSurvey in account.AccountSurvey)
            {
                AccountSurveyRepository asr = new AccountSurveyRepository();
                asr.RemoveAccountSurvey(accountSurvey.AccountSurveyID);
            }

            foreach (FollowedUsers followedUsers in db.followedUsers)
            {
                if (followedUsers.FollowedUsersID == id)
                {
                    RemoveFollowedUsers(id);
                }
            }



            db.accounts.Remove(account);
            db.SaveChanges();
        }
        public void RemoveSurvey(int?id)
        {
            if (id == null)
            {
                throw new ArgumentNullException("Null argument");
            }
            Survey survey = db.surveys.Find(id);

            foreach (Question question in db.questions)
            {
                if (question.QuestionID == id)
                {
                    RemoveQuestion(id);
                }
            }

            foreach (AccountSurvey accountSurvey in survey.AccountSurvey)
            {
                AccountSurveyRepository asr = new AccountSurveyRepository();
                asr.RemoveAccountSurvey(accountSurvey.AccountSurveyID);
            }

            db.surveys.Remove(survey);
            db.SaveChanges();
        }