示例#1
0
        public async Task <IActionResult> DeleteCustomer(int employeeId)
        {
            // Check for Existence
            Employee employee = empContext.GetEmployee(employeeId);

            if (employee == null)
            {
                return(NotFound("Employee Not Found"));
            }

            if (await empContext.DeleteEmployeeAsync(employee) == true)
            {
                return(Ok("Employee Deleted"));
            }
            else
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Failed due to some problem at backend."));
            }
        }
示例#2
0
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            int empId = Convert.ToInt32(id);

            var employee = _context.GetEmployee(empId);

            if (employee == null)
            {
                return(NotFound());
            }
            else
            {
                await _context.DeleteEmployeeAsync(employee);
            }

            return(RedirectToAction(nameof(Index)));
        }