public ActionResult <MachineDTO> GetMachineByName(String id) { var machine = _IMachineRepository.SelectByName(id); MachineDTO p = MachineDTO.generateDto(machine); return(Ok(p)); }
public IActionResult changeMachineTypeOfaMachine([FromRoute] String machineName, [FromRoute] String machineTypeName) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var machineDB = _IMachineRepository.SelectByName(machineName); if (machineDB != null) { var machineTypeDB = _IMachineTypeRepository.SelectByName(machineTypeName); if (machineTypeDB != null) { machineDB.machineType = machineTypeDB; bool update = _IMachineRepository.Update(machineDB); if (update) { MachineDTO machineDTO = MachineDTO.generateDto(machineDB); return(Ok(machineDTO)); } } } return(NotFound()); }
public List <MachineDTO> GetAllMachine() { var q = _IMachineRepository.SelectAll().ToList(); List <MachineDTO> list = new List <MachineDTO>(); foreach (Machine p in q) { list.Add(MachineDTO.generateDto(p)); } return(list); }