Ejemplo n.º 1
0
        public void UpdateCourse(CourseInputUpdate model, int userId)
        {
            var course = _context.Course.SingleOrDefault(p => p.Id == model.Id);

            if (course != null)
            {
                course.Code        = model.Code;
                course.Description = model.Description;
                course.Level       = model.Level;
                course.TimeStar    = model.TimeStar;
                course.TimeEnd     = model.TimeEnd;
                course.MaxStudent  = model.MaxStudent;
                _context.SaveChanges();
            }
        }
        public void Update(CourseInputUpdate model, int teacherId)
        {
            var course = _context.Course.SingleOrDefault(p => p.Id == model.Id);

            if (course != null)
            {
                course.Code         = model.Code;
                course.Name         = model.Name;
                course.Description  = model.Description;
                course.Level        = model.Level;
                course.BeginDate    = model.BeginDate;
                course.EndDate      = model.EndDate;
                course.RegisterDate = model.RegisterDate;
                course.MaxPeople    = model.MaxPeople;
                _context.SaveChanges();
                var courseTeacher = _context.CourseTeacher.SingleOrDefault(p => p.TeacherId == teacherId && p.CourseId == course.Id);
                if (courseTeacher != null)
                {
                    courseTeacher.TeacherId = teacherId;
                    _context.SaveChanges();
                }
            }
        }
 public void Update([FromBody] CourseInputUpdate model, int teacherId)
 {
     _CourseService.Update(model, teacherId);
 }