[View]
@(Html.EJ().Kanban("Kanban")
.DataSource(ds => ds.URL("GetData").CrudURL("Crud").Adaptor(AdaptorType.UrlAdaptor))
.Columns(col =>
{
[Controller]
//Edit multiple cards for priority drag and drop
public ActionResult Crud(List<Task> changed, List<Task> added, List<Task> deleted)
{
//Performing insert operation
if (added != null && added.Count() > 0)
{
foreach (var temp in added)
{
db.Tasks.Add(temp);
}
}
////Performing update operation
if (changed != null && changed.Count() > 0)
{
foreach (var temp in changed)
{
Task old = db.Tasks.Where(o => o.Id == temp.Id).SingleOrDefault();
if (old != null)
{
db.Entry(old).CurrentValues.SetValues(temp);
}
}
}
//Performing delete operation
if (deleted != null && deleted.Count() > 0)
{
foreach (var temp in deleted)
{
db.Tasks.Remove(db.Tasks.Where(o => o.Id == temp.Id).SingleOrDefault());
}
}
db.SaveChanges();
var data = db.Tasks.ToList();
return Json(data, JsonRequestBehavior.AllowGet);
}
|