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

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

            return(RedirectToPage("/Index"));
        }
Exemple #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"));
        }