public LearningDataSeeder(LearningContext ctx)
 {
     _ctx = ctx;
 }
Example #2
0
 public LearningRepository(LearningContext ctx)
 {
     _ctx = ctx;
 }
Example #3
0
 public LearningRepository(LearningContext ctx)
 {
     _ctx = ctx;
 }
Example #4
0
 public UnitOfWork(LearningContext ctx)
 {
     _ctx = new LearningContext();
 }
 public LearningDataSeeder(LearningContext ctx)
 {
     _ctx = ctx;
 }
Example #6
0
 public UnitOfWork(LearningContext ctx)
 {
     _ctx = ctx;
 }
        public HttpResponseMessage GetCoursesBySubject(int subjectid)
        {
            Learning.Data.LearningContext ctx = null;
            Learning.Data.ILearningRepository repo = null;
            IQueryable<Course> query;

            try
            {
                ctx = new Learning.Data.LearningContext();
                repo = new Learning.Data.LearningRepository(ctx);

                query = repo.GetCoursesBySubject(subjectid);
                var coursesList = query.Select(c => c.Name).ToList();
                if (coursesList != null)
                {
                    return Request.CreateResponse(HttpStatusCode.OK, coursesList);
                }
                else
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

            }
            catch (Exception ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
            }
            finally
            {
                ctx.Dispose();
            }
        }