Beispiel #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Employee = await _context.Employees
                       .Include(e => e.Department)
                       .Include(e => e.Designation).FirstOrDefaultAsync(m => m.ID == id);

            if (Employee == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Employee = await _context.Employees.FindAsync(id);

            if (Employee != null)
            {
                _context.Employees.Remove(Employee);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Employee = await _context.Employees
                       .Include(e => e.Department)
                       .Include(e => e.Designation).FirstOrDefaultAsync(m => m.ID == id);

            if (Employee == null)
            {
                return(NotFound());
            }
            ViewData["DepartmentID"]  = new SelectList(_context.Departments, "ID", "Name");
            ViewData["DesignationID"] = new SelectList(_context.Designations, "ID", "Name");
            return(Page());
        }