//public bool Delete(long PlayerID, ref string Msg, Controller ctrl)
        //{
        //    bool status = true;
        //    try
        //    {
        //        //TODO: Get Current Object from DB
        //        var ItemToDelete = db.Players.FirstOrDefault(m => m.PlayerID == PlayerID);
        //        if (ItemToDelete != null)
        //        {
        //            var ForAudiLog = Map(ItemToDelete);
        //            //TODO: Check if it is not null, then Remove from DB
        //            db.DeletePlayer(PlayerID);

        //            //Add To Log
        //            AuditLog(ctrl, AuditAction.Delete, null, ForAudiLog);

        //            /***MailChimp***/
        //            //Whenever new Player Updated into DB then Update its record in MailChimp
        //            MailChimpRepository mcRepo = new MailChimpRepository();
        //            mcRepo.UnSubscribe(ForAudiLog.EmailAddress);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Msg = ErrorHandling.HandleException(ex);
        //        status = false;
        //    }

        //    return status;
        //}

        public bool Delete_Archive(long PlayerID, ref string Msg, Controller ctrl)
        {
            bool status = true;

            try
            {
                //TODO: Get Current Object from DB
                var ItemToDelete = db.Players.FirstOrDefault(m => m.PlayerID == PlayerID);
                if (ItemToDelete != null)
                {
                    var ForAudiLog = Map(ItemToDelete);
                    //TODO: Check if it is not null, then Remove from DB
                    //db.DeletePlayer_MoveToArchive(PlayerID);

                    //Add To Log
                    AuditLog(ctrl, AuditAction.Delete, null, ForAudiLog, "and Moved to Players Archive");

                    /***MailChimp***/
                    //Whenever new Player Updated into DB then Update its record in MailChimp
                    MailChimpRepository mcRepo = new MailChimpRepository();
                    mcRepo.UnSubscribe(ForAudiLog.EmailAddress);
                }
            }
            catch (Exception ex)
            {
                Msg    = ErrorHandling.HandleException(ex);
                status = false;
            }

            return(status);
        }
        public long CreateOrUpdate(ref PlayersExt model, ref string Msg, ref bool status, Controller ctrl, bool AddTo_NoTeamPlayers = false, long?RegPlayerLeagueID = null)
        {
            long PlayerID = model.PlayerID;

            try
            {
                if (model.PlayerID == 0)
                {
                    model.AdvertisementOther = (model.AdvertisementID == 15);
                    //Create New Referral Code for this New Player

                    model.ReferralCode = SecurityUtils.GenerateUniqueReferralCode();

                    //TODO: Map to DB Object
                    model.RegistrationDate = DateTime.Now;
                    var dbmodel = Map(model);

                    //TODO: Save DB Changes and Set the Return Primary Key ID
                    db.Players.Add(dbmodel);
                    db.SaveChanges();

                    /*There's a Insert Trigger on Player's Table which do the following when new Player Added
                     *
                     * 1. Insert Player into PlayerWeightWeeks table with Just Player ID
                     * 2. Check if there's any Facebook Lead player with same Email Address, If Exists then delete the record
                     * 3. Check if the Player with Same Email Address Already Exists in Player's Archive then Delete the Record from Player Archive
                     */


                    PlayerID = dbmodel.PlayerID;

                    /**Get how many players Teamed+NonTeamed are singed up for this league**/
                    //NAGsRepository nagRepo = new NAGsRepository();
                    //nagRepo.TriggerNAGForXPlayers(RegPlayerLeagueID.Value, ctrl, ref Msg, ref status);

                    Msg = "New Player Record Created Successfully";

                    //TOD: Add to Audit Log
                    //  var playerExt = ReadOne(dbmodel.PlayerID);
                    //AuditLog(ctrl, AuditAction.Create, playerExt, null);

                    /***MailChimp***/

                    //Whenever new Player Added into DB then add it to MailChimp
                    // MailChimpRepository mcRepo = new MailChimpRepository();
//mcRepo.Subscribe(playerExt);
                }
                else
                {
                    //Update Existing Record
                    var dbmodel = db.Players.FirstOrDefault(p => p.PlayerID == PlayerID);


                    var ForAuditLog = Map(dbmodel);


                    //TODO: Map to DB Object
                    MapUpdate(ref dbmodel, model);
                    //TODO: Update DB Changes
                    db.SaveChanges();
                    PlayerID = dbmodel.PlayerID;



                    Msg = "Player Record Updated Successfully";
                    //TOD: Add to Audit Log
                    var playerExt = ReadOne(dbmodel.PlayerID);
                    AuditLog(ctrl, AuditAction.Update, ForAuditLog, playerExt);

#if Debug == false
                    /***MailChimp***/
                    //Whenever new Player Updated into DB then Update its record in MailChimp
                    MailChimpRepository mcRepo = new MailChimpRepository();
                    mcRepo.UpdateSubscriber(playerExt);
#endif
                }
            }
            catch (Exception ex)
            {
                Msg    = ErrorHandling.HandleException(ex);
                status = false;
            }

            return(PlayerID);
        }