public async Task <IActionResult> DeleteStudent(StudentModifyInputModel inputModel, string onSubmitAction) { if (onSubmitAction.IsNullOrEmpty() || onSubmitAction == "Cancel") { return(RedirectToAction(nameof(Index))); } try { await _studentsService.DeleteAsync(inputModel.Id); return(RedirectToAction(nameof(Index))); } catch (Exception e) { _logger.LogError(e, $"An exception occured during student DELETE operation for student with id {inputModel.Id}. Ex: {e.Message}"); return(RedirectToAction("Error", "Home")); } }
public async Task <IActionResult> DeleteStudentAsync(Guid id) { var st = await _studentsService.GetByIdAsync(id); if (st == null) { return(BadRequest("Student with id " + id + " doesn't exist")); } try { await _studentsService.DeleteAsync(st); return(Ok("Student with id " + id + " deleted")); } catch { return(this.ServerError("Failed to delete student")); } }
public async Task <ActionResult> Delete(string id) { await _service.DeleteAsync(id); return(RedirectToAction("Index")); }