When I press a button, jQuery uses ajax to delete an item, but it is possible for me to make another function that can "undo" the deletion that just took place?
My delete controller
[HttpPost]
public void DeleteProject(int Id)
{
var Item = from a in db.Project
where a.ProjectId.Equals(Id)
select a;
Project SelectedProject = Item.FirstOrDefault();
ICollection<ProjectProfile> Profiles = SelectedProject.ProjectProfile;
ICollection<Member> Members = SelectedProject.Member;
db.Member.RemoveRange(Members);
db.ProjectProfile.RemoveRange(Profiles);
db.Project.Remove(SelectedProject);
db.SaveChanges();
RedirectToAction("Index", "Projects");
}
答案 0 :(得分:1)
有一些方法可以做到这一点。总的来说,它提供一个明确的解决方案有点过于广泛,但这里有一些想法:
SaveChanges()
。IsDeleted
位,并使用该位表示该记录已被删除,可以随意翻转为&#34;取消删除&#34;。