예제 #1
0
        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)));
        }
예제 #2
0
        public void Delete(Contest contest)
        {
            if (contest.Id == 0)
            {
                throw new IdentifierUndefinedException();
            }

            _contestRepository.Delete(contest);
        }
예제 #3
0
        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
            });
        }
예제 #4
0
 public void Delete(int Id)
 {
     contestRepository.Delete(Id);
 }