예제 #1
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task<IActionResult> OnPostAsync(int id)
        {
            if (!ModelState.IsValid)
            {
                return Page();
            }

            InfoAuto.DataUltimaModifica = DateTime.Now;

            var infoDaAggiornare = await _context.InfoAutomobili.FindAsync(id);
            infoDaAggiornare.DataUltimaModifica = DateTime.Now;

            _context.Entry(infoDaAggiornare).CurrentValues.SetValues(InfoAuto);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InfoAutoExists(InfoAuto.ID))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return RedirectToPage("./Index");
        }
예제 #2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(int id)
        {
            if (!ModelState.IsValid)
            {
                PopulateDropDownLists(_context, Socio.TipologiaSocioID, Socio.DatiAutoID);
                return(Page());
            }

            var socioDaAggiornare = await _context.Soci.FindAsync(id);

            socioDaAggiornare.DataUltimaModifica = DateTime.Now;

            _context.Entry(socioDaAggiornare).CurrentValues.SetValues(Socio);

            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
예제 #3
0
 protected void Aggiungi(T model)
 {
     _context.Entry(model).State = Microsoft.EntityFrameworkCore.EntityState.Added;
 }