private void Course_Init() { _course = new CoursePoco() { Name = Truncate(Faker.Lorem.Sentence(), 150) }; }
public static Course MapFromCoursePoco(CoursePoco poco) { return(new Course() { Id = poco.Id, Name = poco.Name, }); }
public override Task <Empty> UpdateCourse(Course course, ServerCallContext context) { CoursePoco poco = ProtoMapper.MapToCoursePoco(course); _service.UpdateCourse(poco); return(Task.FromResult(new Empty())); }
public void DeleteCourse(int id) { CoursePoco poco = _context.Courses.FirstOrDefault(e => e.Id == id); if (poco != null) { _context.Courses.Remove(poco); _context.SaveChanges(); } }
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())); }
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()); } }
public void UpdateCourse(CoursePoco Course) { _context.Courses.Update(Course); _context.SaveChanges(); }
public int AddCourse(CoursePoco Course) { _context.Courses.Add(Course); _context.SaveChanges(); return(Course.Id); }
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); }
public IActionResult Delete([FromBody] CoursePoco poco) { _context.Courses.Remove(poco); _context.SaveChanges(); return(Ok()); }
public IActionResult Create([FromBody] CoursePoco poco) { _context.Courses.Add(poco); _context.SaveChanges(); return(Ok()); }
public IActionResult PostCoursePoco(CoursePoco coursePoco) { _context.courses.Add(coursePoco); _context.SaveChangesAsync(); return(Ok()); }
public IActionResult Create([FromBody] CoursePoco item) { context.Courses.Add(item); context.SaveChanges(); return(Ok()); }
public IActionResult Post([FromBody] CoursePoco course) { _courseLogic.Add(course); return(Ok()); }