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

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

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

            return(RedirectToPage("./Index"));
        }
Esempio n. 2
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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


            try
            {
                await _context.SaveChangesAsync();
            }


            catch (DbUpdateConcurrencyException)
            {
                if (!DisciplinaExists(Disciplina.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            catch (DbUpdateException se)
            {
                if (se.InnerException.Message.Contains("IX_Disciplina_Nume"))
                {
                    this.ModelState.AddModelError("", "Numele disciplinei trebuie sa fie unic");
                    return(await OnGetAsync(Disciplina.ID));
                }
                throw;
            }

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