コード例 #1
0
ファイル: HackingEngine.cs プロジェクト: LoZeno/Holonet3
        //Metodi per registrare i tentativi precedenti
        public static void RegistraHackingAccount(long account, long hacker, bool successo)
        {
            using (HolonetEntities context = new HolonetEntities())
            {
                long numeroTentativo = 0;

                var tentativiPrecedenti = (from trials in context.AccountHackings
                                           where trials.NumeroPGAccount == account
                                           where trials.NumeroPGHacker == hacker
                                           select trials.NumeroTentativo);
                if (tentativiPrecedenti.Count() > 0)
                {
                    long ultimoTentativo = tentativiPrecedenti.Max();
                    numeroTentativo = ultimoTentativo + 1;
                }

                AccountHacking tentativoDaRegistrare = new AccountHacking();
                tentativoDaRegistrare.NumeroPGAccount = account;
                tentativoDaRegistrare.NumeroPGHacker = hacker;
                tentativoDaRegistrare.NumeroTentativo = numeroTentativo;
                tentativoDaRegistrare.Riuscito = successo ? 1 : 0;
                tentativoDaRegistrare.DataTentativo = DateTime.Now;

                context.AddToAccountHackings(tentativoDaRegistrare);
                context.SaveChanges();
            }
        }