Exemple #1
0
        public async Task <IHttpActionResult> Edit(CourseInstructorRequestDTO courseInstructorDTO, int id)//se devuelve un modelo
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (courseInstructorDTO.ID != id)
            {
                return(BadRequest());
            }

            var flag = await courseInstructorService.GetById(id);

            if (flag == null)
            {
                return(NotFound());
            }

            try
            {
                var courseInstructor = _mapper.Map <CourseInstructor>(courseInstructorDTO);
                courseInstructor = await courseInstructorService.Update(courseInstructor);

                return(Ok(courseInstructor));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #2
0
        public async Task <IHttpActionResult> Insert(CourseInstructorRequestDTO courseInstructorDTO)//se devuelve un modelo
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var courseInstructor = _mapper.Map <CourseInstructor>(courseInstructorDTO);
                courseInstructor = await courseInstructorService.Insert(courseInstructor);

                return(Ok(courseInstructor));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }