Answer the question
In order to leave comments, you need to log in
Recursively removing subtasks?
There is such a model
public class TaskModel
{
public int Id { get; set; }
public string Title { get; set; }
public int ParentId { get; set; }
}
[HttpDelete]
public ActionResult RemoveTask([FromBody] TaskModel taskData)
{
// var tasksIds = GetChildrenIds(taskData.id);
// Db::rawQuery($"DELETE FROM Tasks WHERE Id in {tasksIds}");
// Db.SaveChanges();
return Json(Db.Tasks);
}
private IEnumerable<int> GetChildrenIds(int parentId)
{
return Db.Tasks
.Where(task => task.Id == parentId)
.Select(task => task.Id);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question