Esempio n. 1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //context.Add();
            await context.SaveChangesAsync();

            return(RedirectToPage("/Index"));
        }
Esempio n. 2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Random        = new Random();
            Message.Color = ColorPalette[Random.Next(0, ColorPalette.Length)];
            Message.Date  = DateTime.Now;
            _context.Message.Add(Message);
            await _context.SaveChangesAsync();

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