public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                _logger.LogError("Error occured while watching detailed at a Motorcycle");
                return(NotFound());
            }

            Motorrad = await _context.Motorrad.FirstOrDefaultAsync(m => m.ID == id);

            if (Motorrad == null)
            {
                _logger.LogError("Error occured while watching detailed at a Motorcycle");
                return(NotFound());
            }

            if (User.Identity.Name == null)
            {
                _logger.LogInformation("Not Logged or Registrated user looked at detailed Motorcycle {0}", Motorrad.ID);
            }
            else
            {
                _logger.LogInformation("{0} looked at detailed Motorcycle {1}", User.Identity.Name, Motorrad.ID);
            }

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                _logger.LogError("Motorcycle is not found and can be deleted");
                return(NotFound());
            }

            Motorrad = await _context.Motorrad.FirstOrDefaultAsync(m => m.ID == id);

            if (Motorrad == null)
            {
                _logger.LogError("Motorcycle is not found and can be deleted");
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                _logger.LogError("Motorcycle is not found and can be deleted");
                return(NotFound());
            }

            Motorrad = await _context.Motorrad.FindAsync(id);

            if (Motorrad != null)
            {
                _context.Motorrad.Remove(Motorrad);
                await _context.SaveChangesAsync();

                _logger.LogDebug("Motorcycle is Deleted by User {0}", User.Identity.Name);
            }

            return(RedirectToPage("./Index"));
        }
예제 #4
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                _logger.LogError("Error Fahrzeug not found");
                return(NotFound());
            }

            Motorrad = await _context.Motorrad.FirstOrDefaultAsync(m => m.ID == id);

            if (Motorrad == null)
            {
                _logger.LogError("Error Fahrzeug not found");
                return(NotFound());
            }

            _logger.LogInformation("User {0} is changing Motorcycle {1}", User.Identity.Name, Motorrad.ID);

            return(Page());
        }