public async Task <SaveAttendenceResponse> DeleteAsync(int id) { var existingAttendence = await _attendenceRepository.FindByIdAsync(id); await _unitOfWork.CompleteAsync(); if (existingAttendence == null) { return(new SaveAttendenceResponse("Attendence not found.")); } try { _attendenceRepository.Remove(existingAttendence); await _unitOfWork.CompleteAsync(); return(new SaveAttendenceResponse("Data Delete")); } catch (Exception ex) { // Do some logging stuff return(new SaveAttendenceResponse($"An error occurred when deleting the attendence: {ex.Message}")); } }
public void DeleteClass(int id) { Attendence item = repository.Get(id); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } repository.Remove(id); repository.Save(); }