public async Task <ActionResult <MachineTypeDTO> > GetMachineType(Guid id) { try { MachineType machineType = await _serviceMachineType.getMachineType(id); return(machineType.toDTO()); } catch (KeyNotFoundException) { return(NotFound(String.Format("The MachineType with id: {0} was not found!", id))); } //catch(SqlException){} }
public async Task <ActionResult <MachineTypeDTO> > PostMachineType([FromBody] MachineTypeDTO item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { MachineType machine = await _serviceMachineType.postMachineType(item); return(CreatedAtAction(nameof(PostMachineType), machine.toDTO())); } catch (KeyNotFoundException ex) { return(NotFound(ex.Message)); } }