Пример #1
0
 private void Course_Init()
 {
     _course = new CoursePoco()
     {
         Name = Truncate(Faker.Lorem.Sentence(), 150)
     };
 }
Пример #2
0
 public static Course MapFromCoursePoco(CoursePoco poco)
 {
     return(new Course()
     {
         Id = poco.Id,
         Name = poco.Name,
     });
 }
Пример #3
0
        public override Task <Empty> UpdateCourse(Course course, ServerCallContext context)
        {
            CoursePoco poco = ProtoMapper.MapToCoursePoco(course);

            _service.UpdateCourse(poco);

            return(Task.FromResult(new Empty()));
        }
Пример #4
0
        public void DeleteCourse(int id)
        {
            CoursePoco poco = _context.Courses.FirstOrDefault(e => e.Id == id);

            if (poco != null)
            {
                _context.Courses.Remove(poco);
                _context.SaveChanges();
            }
        }
Пример #5
0
        public override Task <CourseKey> AddCourse(Course course, ServerCallContext context)
        {
            CoursePoco poco = ProtoMapper.MapToCoursePoco(course);
            int        id   = _service.AddCourse(poco);

            return(Task.FromResult(new CourseKey()
            {
                Id = id
            }));
        }
        public override Task <CourseReply> GetCourse(CourseIDRequest request, ServerCallContext context)
        {
            CoursePoco  CoursePoco  = _logic.GetSingle(request.CourseID);
            CourseReply CourseReply = new CourseReply()
            {
                CourseID   = CoursePoco.CourseID,
                CourseName = CoursePoco.CourseName
            };

            return(Task.FromResult(CourseReply));
        }
        public override Task <Empty> AddCourse(CourseReply request, ServerCallContext context)
        {
            CoursePoco CoursePoco = new CoursePoco()
            {
                CourseID   = request.CourseID,
                CourseName = request.CourseName
            };

            _logic.Add(CoursePoco);

            return(Task.FromResult(new Empty()));
        }
Пример #8
0
        public IActionResult Read(int Id)
        {
            CoursePoco res = context.Courses.FirstOrDefault(a => a.Id == Id);

            if (res != null)
            {
                return(Ok(res));
            }
            else
            {
                return(NotFound());
            }
        }
        public IActionResult Create([FromBody] EnrollmentPoco item)
        {
            //this is to validate the exist
            StudentPoco student = context.Students.FirstOrDefault <StudentPoco>(a => a.Id == item.StudentId);
            CoursePoco  course  = context.Courses.FirstOrDefault <CoursePoco>(a => a.Id == item.CourseId);

            if (student != null && course != null)
            {
                context.Enrollments.Add(item);
                context.SaveChanges();
                return(Ok());
            }
            else //either Student or Course not found, Can't create
            {
                return(NotFound());
            }
        }
Пример #10
0
 public void UpdateCourse(CoursePoco Course)
 {
     _context.Courses.Update(Course);
     _context.SaveChanges();
 }
Пример #11
0
 public int AddCourse(CoursePoco Course)
 {
     _context.Courses.Add(Course);
     _context.SaveChanges();
     return(Course.Id);
 }
Пример #12
0
        public CoursePoco GetCourse(int id)
        {
            CoursePoco poco = _context.Courses.FirstOrDefault(e => e.Id == id);

            return(poco);
        }
        public void Remove(int id)
        {
            CoursePoco course = _eFGenericRepository.GetSingle(student => student.CourseID == id);

            _eFGenericRepository.Remove(course);
        }
 public void Add(CoursePoco student)
 {
     _eFGenericRepository.Add(student);
 }
Пример #15
0
 public IActionResult Delete([FromBody] CoursePoco poco)
 {
     _context.Courses.Remove(poco);
     _context.SaveChanges();
     return(Ok());
 }
Пример #16
0
 public IActionResult Create([FromBody] CoursePoco poco)
 {
     _context.Courses.Add(poco);
     _context.SaveChanges();
     return(Ok());
 }
Пример #17
0
 public IActionResult PostCoursePoco(CoursePoco coursePoco)
 {
     _context.courses.Add(coursePoco);
     _context.SaveChangesAsync();
     return(Ok());
 }
Пример #18
0
 public IActionResult Create([FromBody] CoursePoco item)
 {
     context.Courses.Add(item);
     context.SaveChanges();
     return(Ok());
 }
Пример #19
0
 public IActionResult Post([FromBody] CoursePoco course)
 {
     _courseLogic.Add(course);
     return(Ok());
 }