Пример #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Atleta.foreignKeySquadra = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            _context.Attach(Atleta).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AtletaExists(Atleta.id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Пример #2
0
        public async Task <IActionResult> OnGetAsync()
        {
            if (User.Identity.IsAuthenticated && User.FindFirst(ClaimTypes.NameIdentifier).Value == "admin")
            {
                Atleta = await _context.Atleta.ToListAsync();

                if (IsPowerOfTwo((ulong)Atleta.Count()) == false)
                {
                    return(RedirectToPage("./ErrorePotenza2"));
                }

                IListExtensions.Shuffle(Atleta);

                incontri = new List <Incontro>();

                for (int i = 0; i < Atleta.Count(); i += 2)
                {
                    incontri.Add(new Incontro(Atleta[i], Atleta[i + 1]));
                }

                storicoIncontri = new List <Incontro>();

                AvvioTorneo(Atleta.Count());

                _context.Atleta.Where(a => a.id == storicoIncontri[storicoIncontri.Count() - 1].vincitore.id).FirstOrDefault().vittorie++;

                await _context.SaveChangesAsync();

                return(Page());
            }
            else
            {
                return(RedirectToPage("Index"));
            }
        }
Пример #3
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Atleta.foreignKeySquadra = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            _context.Atleta.Add(Atleta);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #4
0
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Atleta = await _context.Atleta.FindAsync(id);

            if (Atleta != null)
            {
                _context.Atleta.Remove(Atleta);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }