Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> GetCourseList()
        {
            try
            {
                CourseDAL         dal  = new CourseDAL();
                List <CourseInfo> data = await dal.GetCourseList();

                if (data != null)
                {
                    Logger log = new Logger();
                    log.ErrorLog(new DbEntityValidationException(), "Course", "GetCourse");
                    return(Request.CreateResponse <List <CourseInfo> >(HttpStatusCode.OK, data));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, Constants.ErrorNotFound));
                }
            }
            catch (DbEntityValidationException ex)
            {
                var    controllerName = ControllerContext.RouteData.Values["controller"].ToString();
                var    actionName     = ControllerContext.RouteData.Values["action"].ToString();
                Logger log            = new Logger();
                log.ErrorLog(ex, controllerName, actionName);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, Constants.ErrorSysError));
            }
        }
Ejemplo n.º 2
0
    public List <Course> GetCourseList()
    {
        CourseDAL dal = new CourseDAL();

        return(dal.GetCourseList());
    }