public async Task <IHttpActionResult> Put(OfficeAssignmentDTO officeAssignmentDTO, int id)//objet -> body / primitivo -> url { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (officeAssignmentDTO.InstructorID != id) { return(BadRequest()); } var flag = await officeAssignmentService.GetById(id); if (flag == null) { return(NotFound()); //status code 404 } try { var officeAssignment = mapper.Map <OfficeAssignment>(officeAssignmentDTO); officeAssignment = await officeAssignmentService.Update(officeAssignment); return(Ok(officeAssignmentDTO));//status code 200 } catch (System.Exception ex) { return(InternalServerError(ex));//status code 500 } }
public async Task <IHttpActionResult> Put(OfficeAssignmentDTO OfficeAssignmentDTO, int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (OfficeAssignmentDTO.InstructorID != id) { return(BadRequest()); } var flag = await officeassignmentService.GetById(id); if (flag == null) { return(NotFound()); } try { var officeassignment = mapper.Map <OfficeAssignment>(OfficeAssignmentDTO); officeassignment = await officeassignmentService.Update(officeassignment); return(Ok(officeassignment)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> Put(OfficeAssignmentDTO officeAssignmentDTO, int id) // object - cuerpo pero si es prmitivo por la url { if (!ModelState.IsValid) { return(BadRequest(ModelState)); // status code 400 } if (officeAssignmentDTO.InstructorID != id) { return(BadRequest()); } var flag = await officeAssignmentService.GetById(id); if (flag == null) { return(NotFound()); // status code 404 } try { var officeAssignment = mapper.Map <OfficeAssignment>(officeAssignmentDTO); officeAssignment = await officeAssignmentService.Update(officeAssignment); return(Ok(officeAssignment)); //Sastus code 200 //return Ok(courseDTO); //Sastus code 200 } catch (Exception ex) { return(InternalServerError(ex)); //Status code 500 } }