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");
}
There's a few way you could do this. Overall, it's a bit too broad to offer a clear-cut solution, but here's some ideas:
SaveChanges()
.IsDeleted
bit to your table and use that to signify that the record has been deleted which can be flipped at will to "un-delete".If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With