Пример #1
0
        public ActionResult <OperationsDTO> PostOperation(OperationsDTO opDTO)
        {
            OperationsMDP op = new OperationsMDP(opDTO.ToolDesc, opDTO.Name, opDTO.Duration, opDTO.OperationsTypeId);

            _IOperationsRepository.Insert(op);
            return(CreatedAtAction(nameof(GetAllOperations), new { id = op.Id }, op));
        }
        public ActionResult <OperationsDTO> GetOperationsByID(int id)
        {
            var           operations = _IOperationsRepository.Select(id);
            OperationsDTO p          = OperationsDTO.generateDto(operations);

            return(Ok(p));
        }
        public ActionResult <OperationsDTO> PostOperation(OperationsDTO opDTO)
        {
            var        opType = _IOperationsTypeRepository.Select(opDTO.OperationsTypeId);
            Operations op     = new Operations(new Designation(opDTO.Name), new Details(opDTO.ToolDesc), new Duration(opDTO.Duration), opType);

            _IOperationsRepository.Insert(op);

            return(CreatedAtAction(nameof(GetAllOperations), new { id = op.Id }, op));
        }
        public List <OperationsDTO> GetOperationsByMachineTypeByName([FromRoute] String id)
        {
            var machineType            = _IMachineTypeRepository.SelectByName(id);
            List <OperationsDTO> lista = new List <OperationsDTO>();

            foreach (Operations op in machineType.operations)
            {
                lista.Add(OperationsDTO.generateDto(_IOperationsRepository.Select(op.Id)));
            }
            return(lista);
        }
        public List <OperationsDTO> GetAllOperations()
        {
            var q = _IOperationsRepository.SelectAll().ToList();
            List <OperationsDTO> list = new List <OperationsDTO>();

            foreach (Operations p in q)
            {
                list.Add(OperationsDTO.generateDto(p));
            }
            return(list);
        }
Пример #6
0
        public void CreateRecord(EntitiesDTO entity, OperationsDTO operation, string userId, int entityId, bool success)
        {
            var record = new RecordDTO
            {
                UserId       = userId,
                Entity       = entity,
                Operation    = operation,
                Successfully = success,
                EntityId     = entityId,
                DateTime     = DateTime.Now
            };

            CreateRecord(record);
        }
Пример #7
0
        public void EnsureOperationsGetSetAndDTOWorks()
        {
            List <Operations> ops = new List <Operations>();
            Operations        op1 = new Operations {
                designation = new Designation {
                    designation = "Op1"
                }, ToolDetails = new Details {
                    Det = "teste2"
                }, Dur = new Duration {
                    dur = 232
                }
            };
            Operations op2 = new Operations {
                designation = new Designation {
                    designation = "Op1"
                }, ToolDetails = new Details {
                    Det = "teste2"
                }, Dur = new Duration {
                    dur = 232
                }
            };
            Operations op3 = new Operations {
                designation = new Designation {
                    designation = "Op3"
                }, ToolDetails = new Details {
                    Det = "teste233"
                }, Dur = new Duration {
                    dur = 2323333
                }
            };


            OperationsDTO operationsDTO = new OperationsDTO(

                1,
                op1.ToolDetails.Det,
                op1.designation.designation,
                op1.Dur.dur,
                2
                );


            Assert.Equal(op1.designation.designation, operationsDTO.Name);
            Assert.Equal(op1.Dur.dur, operationsDTO.Duration);
            Assert.Equal(op1.designation.designation, op1.designation.designation);
        }
Пример #8
0
        public async Task <ActionResult <MachineTypeDTO> > UpdateMachineTypeOperations(Guid id, [FromBody] OperationsDTO operationsDTO)
        {
            try
            {
                await _serviceMachineType.UpdateMachineTypeOperation(id, operationsDTO.Operations);

                return(Ok());
            }
            catch (KeyNotFoundException e)
            {
                return(NotFound(e.Message));
            }
        }