コード例 #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(Motorrad).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                _logger.LogDebug("Changes saved to Fahrzeug ID {0} from User {1}", Motorrad.ID, User.Identity.Name);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MotorradExists(Motorrad.ID))
                {
                    _logger.LogError("Error occured while Editing");
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
コード例 #2
0
        static async Task MainAsync()
        {
            try
            {
                AuthenticationContext context = new AuthenticationContext(new MockAuthenticationTicketRepository());
                context.Attach(new MockPasswordAuthenticationProvider());

                Console.WriteLine((await context.SignInAsync("Clark", "123")).Succeeded);

                Console.WriteLine((await context.SignInAsync("Warning", "123")).Succeeded);

                //Console.WriteLine((await context.SignInAsync("Exception", "123")).Succeeded);


                Console.WriteLine((await context.SignInAsync()).Succeeded);
                context.SignOut();
                Console.WriteLine((await context.SignInAsync()).Succeeded);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error:" + ex.Message);
            }


            Console.WriteLine("End...");
            Console.ReadLine();
        }