public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here var result = GradeService.Delete(id); //var result = list.Where(e => e.GradeId == id).FirstOrDefault(); if (result == null) { return(RedirectToAction("Index", new { ErrorMsg = "班级不存在" })); } //list.Remove(result); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult <object> Delete([FromBody] Model.DeleteID deleteID) { try { Init(); if (!ModelState.IsValid) { Response.StatusCode = 400; return("Grade does not exist"); } else { if (deleteID.id == null) { Response.StatusCode = 400; return("Grade does not exist"); } StringBuilder sbError = new StringBuilder(""); var isDeleted = _gradeService.Delete(deleteID.id, ref sbError); if (!isDeleted) { Response.StatusCode = 400; return("Grade Delete failed"); } else { Response.StatusCode = 200; return((string)"Grade Deleted Successfully"); } } } catch (Exception er) { return(Error(er)); } }