Exemple #1
0
        public ActionResult <MachineDTO> GetMachineByName(String id)
        {
            var        machine = _IMachineRepository.SelectByName(id);
            MachineDTO p       = MachineDTO.generateDto(machine);

            return(Ok(p));
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        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);
        }