public ActionResult DeleteTestResult(int testResultId) { var testResult = testResultService.GetById(testResultId); int userId = userService.GetOneByPredicate(u => u.UserName == User.Identity.Name).Id; var profileId = profileService.GetOneByPredicate(p => p.UserId == userId).Id; testResultService.Delete(testResult); return(RedirectToAction("ShowPassedTests", "Test", new { profileId = profileId })); }
public async Task <IHttpActionResult> DeleteById(int id) { if (id <= 0) { return(BadRequest("Incorrect result id.")); } try { TestResultDTO resultDTO = await _resultService.Delete(id); TestResultModel returnedResult = _mapper.Map <TestResultDTO, TestResultModel>(resultDTO); return(Ok(returnedResult)); } catch (EntityNotFoundException) { return(NotFound()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }