public async Task <JsonResult> Delete(int id) { ServiceProvider serviceProvider = new ServiceProvider(); var model = serviceProvider.GetByID(id); if (model.HasChild) { var list = serviceProvider.GetNodeOfParent(model.ID); if (list.Count == 0) { var result = await serviceProvider.DeleteAsync(id); return(Json(new AccessEntityResult { Status = result, Data = id, Message = "" })); } else { return(Json(new AccessEntityResult { Status = AccessEntityStatusCode.HasChild, Data = id, Message = "" })); } } else { var result = await serviceProvider.DeleteAsync(id); return(Json(new AccessEntityResult { Status = result, Data = id, Message = "" })); } }