public IActionResult DeleteFaculty(int id) { var facultyFromDb = _facultyRepo.GetFisrtOrDefault(c => c.Id == id); if (facultyFromDb != null) { _facultyRepo.Remove(facultyFromDb); _facultyRepo.Save(); return(Json(new { status = true, message = "Deleted Suucessfully" })); } else { return(Json(new { status = false, message = "Unable to delete" })); } }
public IActionResult OnPost() { if (!ModelState.IsValid) { return(Page()); } else { if (CreateObj.Id != 0) { _facultyRepo.Update(CreateObj); } else { _facultyRepo.Add(CreateObj); } _facultyRepo.Save(); return(RedirectToPage("./Index")); } }