コード例 #1
0
        public static void GetUserTeamPickAutomaticSubJson(int userTeamId, int gameweekId, UserTeamPickAutomaticSubs userTeamPickAutomaticSubsInsert, UserTeamPickData userTeamPickData, SqlConnection db)
        {
            try
            {
                //Logger.Out("GetUserTeamPickAutomaticSubJson: Gameweek " + Convert.ToString(gameweekId) + " - starting");

                //Load UserTeamPickAutomaticSub data
                UserTeamPickAutomaticSubRepository userTeamPickAutomaticSubRepository = new UserTeamPickAutomaticSubRepository();

                //List<int> UserTeamPickAutomaticSubIds = userTeamPickAutomaticSubRepository.GetAllUserTeamPickAutomaticSubIdsForUserTeamIdAndGameweekId(userTeamId, gameweekId, db);

                foreach (UserTeamPickAutomaticSub userTeamPickAutomaticSub in userTeamPickData.automatic_subs)
                {
                    //needed if want to assign value from parent to add into db table
                    //if (!UserTeamPickAutomaticSubIds.Contains(userTeamPickAutomaticSub.element_in) && !userTeamPickAutomaticSubsInsert.Contains(userTeamPickAutomaticSub))
                    if (!userTeamPickAutomaticSubsInsert.Contains(userTeamPickAutomaticSub))
                    {
                        userTeamPickAutomaticSubsInsert.Add(userTeamPickAutomaticSub);
                    }
                    //else
                    //{
                    //    userTeamPickAutomaticSubRepository.UpdateUserTeamPickAutomaticSub(userTeamPickAutomaticSub);
                    //}
                }
                //Logger.Out("GetUserTeamPickAutomaticSubJson: Gameweek " + Convert.ToString(gameweekId) + " - completed");
            }
            catch (Exception ex)
            {
                Logger.Error("GetUserTeamPickAutomaticSubJson data exception (UserTeamId: " + userTeamId.ToString() + "): " + ex.Message);
                //throw new Exception("GetUserTeamPickAutomaticSubJson data exception (UserTeamId: " + userTeamId.ToString() + "): " + ex.Message);
                //GetUserTeamPickAutomaticSubJson(userTeamId, gameweekId, userTeamPickAutomaticSubsInsert, userTeamPickData, db);
            }
        }
        public static void WriteUserTeamPickAutomaticSubsToDB(int pageId, UserTeamPickAutomaticSubs userTeamPickAutomaticSubsInsert, SqlConnection db)
        {
            try
            {
                UserTeamPickAutomaticSubRepository userTeamPickAutomaticSubRepository = new UserTeamPickAutomaticSubRepository();

                //Write UserTeamPickAutomaticSub to the db
                Globals.UserTeamPickAutomaticSubsRowsInserted = userTeamPickAutomaticSubRepository.InsertUserTeamPickAutomaticSubs(userTeamPickAutomaticSubsInsert, db);
                Logger.Out("UserTeamPickAutomaticSub bulk insert complete (PageId: " + Convert.ToString(pageId) + ")");

                userTeamPickAutomaticSubsInsert.Clear();
            }
            catch (Exception ex)
            {
                Logger.Error("Program WriteUserTeamPickAutomaticSubsToDB error: " + ex.Message);
            }
        }