示例#1
0
        public ResultModel UpdateCourse(int id, CourseInstructor _CourseInstructor)
        {
            var result = new ResultModel();

            if (id != _CourseInstructor.CourseId)
            {
                result.Message   = BadRequest().ToString();
                result.IsSuccess = false;
                return(result);
            }

            db.Entry(_CourseInstructor).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TodoItemExists(id))
                {
                    result.Message   = NotFound().ToString();
                    result.IsSuccess = false;
                    return(result);
                }
                else
                {
                    throw;
                }
            }

            result.IsSuccess = true;
            return(result);
        }
示例#2
0
        public ResultModel AddCourse(CourseInstructor _CourseInstructor)
        {
            var result = new ResultModel();

            db.CourseInstructor.Add(new CourseInstructor {
                CourseId = _CourseInstructor.CourseId, InstructorId = _CourseInstructor.InstructorId
            });

            db.SaveChanges();

            result.Data      = _CourseInstructor.CourseId;
            result.IsSuccess = true;

            return(result);
        }