public void SetFavoriteTeam(string userId, int selectedTeamId)
 {
     var accountFacade = new AccountFacade();
     var favoriteRequest = new SetFavoriteTeamRequest();
     favoriteRequest.UserId = userId;
     favoriteRequest.SelectedTeamId = selectedTeamId;
     accountFacade.SetFavoriteTeam(favoriteRequest);
 }
        public void SetFavoriteTeam(SetFavoriteTeamRequest request)
        {
            const int IgnoreRange = 0;
            var isArgumentValid = request != null 
                && !string.IsNullOrEmpty(request.UserId) 
                && request.SelectedTeamId > IgnoreRange;
            if (!isArgumentValid) return;

            var accountDac = FacadeRepository.Instance.AccountDataAccess;
            var selectedAccount = accountDac.GetAccountBySecrectCode(request.UserId);
            if (selectedAccount == null) return;

            var isSelectedTeamAvailable = accountDac.GetAllLeagues().Any(it => it.TeamId == request.SelectedTeamId);
            if (!isSelectedTeamAvailable) return;

            accountDac.SetFavoriteTeam(request);
        }
        public void SetFavoriteTeam(SetFavoriteTeamRequest request)
        {
            using (var dctx = new DailySoccer.DAC.EF.DailySoccerModelContainer())
            {
                var selectedAccount = dctx.Accounts.FirstOrDefault(it => it.GuestAccounts
                .Any(guestAccount => guestAccount.SecretCode.Equals(request.UserId, StringComparison.CurrentCultureIgnoreCase)));
                if (selectedAccount == null) return;

                var selectedTeam = dctx.FavoriteTeams.FirstOrDefault(it => it.Id == request.SelectedTeamId);
                if (selectedTeam == null) return;

                selectedAccount.FavoriteTeam = selectedTeam;
                dctx.SaveChanges();
            }
        }