Exemple #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);
        }