Exemplo n.º 1
0
 public LearningDataSeeder(LearningContext ctx)
 {
     _ctx = ctx;
 }
Exemplo n.º 2
0
 public LearningRepository(LearningContext ctx)
 {
     _ctx = ctx;
 }
Exemplo n.º 3
0
 public LearningRepository(LearningContext ctx)
 {
     _ctx = ctx;
 }
Exemplo n.º 4
0
 public UnitOfWork(LearningContext ctx)
 {
     _ctx = new LearningContext();
 }
 public LearningDataSeeder(LearningContext ctx)
 {
     _ctx = ctx;
 }
Exemplo n.º 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();
            }
        }