internal List <TOCDTO> getTOCList(int gameID) { List <TOC> TOCList = null; List <TOCDTO> tocDTOs = null; rulesencyclopediaDBEntities1 context = null; try { context = new rulesencyclopediaDBEntities1(); { TOCList = context.TOC.Where(element => element.Games == gameID).ToList(); tocDTOs = new List <TOCDTO>(); foreach (TOC toc in TOCList) { TOCDTO tocDTO = (TOCDTO)DTOConverter.Converter(new TOCDTO(), toc); tocDTOs.Add(tocDTO); } } } catch (EntityException ex) { exHandler.exceptionHandlerEntity(ex, "something happened while fetching the toclist"); } finally { context.Dispose(); } return(tocDTOs); }
public HttpResponseMessage Get(int Id) { HttpResponseMessage response = new HttpResponseMessage(); TOCDTO toc = dao.getTOC(Id); if (toc != null) { response = Request.CreateResponse(HttpStatusCode.OK, toc); } else { response = Request.CreateResponse(HttpStatusCode.NotFound, "Toc not found"); } return(response); }
internal TOCDTO getTOC(int ID) { TOC toc = null; rulesencyclopediaDBEntities1 context = null; try { context = new rulesencyclopediaDBEntities1(); { toc = context.TOC.Single(element => element.Id == ID); } } catch (EntityException ex) { exHandler.exceptionHandlerEntity(ex, "something went wrong when getting toc"); } finally { context.Dispose(); } TOCDTO tocDTO = (TOCDTO)DTOConverter.Converter(new TOCDTO(), toc); return(tocDTO); }