Пример #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Department = await _context.Department.FirstOrDefaultAsync(m => m.DepartmentID == id);

            if (Department == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #2
0
        public async Task <IActionResult> OnDeleteDelete([FromBody] CicotiWebApp.Models.Department obj)
        {
            if (obj != null && HttpContext.User.IsInRole("Admin"))
            {
                try
                {
                    _context.Department.Remove(obj);
                    await _context.SaveChangesAsync();

                    return(new JsonResult("Department removed successfully"));
                }
                catch (DbUpdateException d)
                {
                    return(new JsonResult("Department not removed." + d.InnerException.Message));
                }
            }
            else
            {
                return(new JsonResult("Department not removed."));
            }
        }