public IHttpActionResult ContestDetails(int contest_id) { try{ var contest = contest_repository.GetContestById(contest_id); return(Ok(new ContestDetailsData(contest))); } catch (ObjectNotFoundException e) { return(NotFound()); } }
public ContestBO GetContestById(int contestId) { using (var context = new aspnet_learningEntities()) { var repository = new ContestRepository(context); var DALContest = repository.GetContestById(contestId); var contest = DALContest != null ? new ContestBO( DALContest.id, DALContest.name, DALContest.food_item, DALContest.location, DALContest.date ?? new DateTime(), DALContest.contest_participations.Count) : null; return(contest); } }