public IActionResult Delete([FromForm] ContestViewModel contest) { //delete the user assigned to this contest from user contest var listOfParticipant = _userContestRepository.GetAll().Where(part => part.ContestId == contest.ContestId).ToList(); foreach (var item in listOfParticipant) { _userContestRepository.Delete(item); } //delete submission var listOfSubmission = _submisionContestRepository.GetAll().Where(subm => subm.ContestId == contest.ContestId).ToList(); foreach (var item in listOfSubmission) { _submisionContestRepository.Delete(item); } //delete problem assigned to a contest var listOfProblems = _problemContestRepository.GetAll().Where(prob => prob.ContestId == contest.ContestId).ToList(); foreach (var item in listOfProblems) { _problemContestRepository.Delete(item); } _contestRepository.Delete(contest.ContestId); _contestRepository.Save(); return(RedirectToAction(nameof(Index))); }
public void Delete(Contest contest) { if (contest.Id == 0) { throw new IdentifierUndefinedException(); } _contestRepository.Delete(contest); }
public HttpResponseMessage Delete(int id, HttpRequestMessage <int> request) { if (id != 0) { contestRepository.Delete(id); return(new HttpResponseMessage { StatusCode = HttpStatusCode.OK }); } return(new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound }); }
public void Delete(int Id) { contestRepository.Delete(Id); }