public ActionResult Clear()
        {
            // delete all tipper data
            using (var ctxt = new TippSpielContext())
            {
                foreach (var tipp in ctxt.TippMatchList)
                {
                    ctxt.Entry(tipp).State = EntityState.Deleted;
                }

                ctxt.SaveChanges();
            }

            // delete all users
            var users = GetUserList();

            foreach (var user in users)
            {
                var username = user.username;

                try
                {
                    if (WebSecurity.UserExists(username) == true)
                    {
                        Membership.DeleteUser(username);
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    log.ErrorFormat("User {0} not created: {1}", user.username, e.Message);
                }
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult CleanupDuplicates()
        {
            var matches = _matchDataRepository.GetAllMatches();

            var list2deleted = new List <int>();

            foreach (var m in matches)
            {
                List <string> users = null;
                using (var ctxt = new TippSpielContext())
                {
                    users = (from t in ctxt.TippMatchList select t.User).Distinct().ToList();
                }

                foreach (var username in users)
                {
                    using (var ctxt = new TippSpielContext())
                    {
                        var filter = (from t in ctxt.TippMatchList
                                      where t.MatchId == m.MatchId &&
                                      t.User == username
                                      select t);

                        int count = filter.Count();

                        if (count > 1)
                        {
                            list2deleted.Add(filter.First().Id);
                        }
                    }
                }
            }

            using (var ctxt = new TippSpielContext())
            {
                foreach (var e in list2deleted)
                {
                    var match = (from m in ctxt.TippMatchList
                                 where m.Id == e
                                 select m)
                                .First();

                    ctxt.Entry(match).State = System.Data.EntityState.Deleted;
                }

                ctxt.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteTipps()
        {
            // delete all tipper data
            using (var ctxt = new TippSpielContext())
            {
                foreach (var tipp in ctxt.TippMatchList)
                {
                    ctxt.Entry(tipp).State = System.Data.EntityState.Deleted;
                }

                ctxt.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }