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 void EnsureProductGetSetWorks() { //Arrange Name na = new Name("Teste1"); OperationsMDP opmdp = new OperationsMDP("Tool", "name", 30, 1); DateTime dt = new DateTime(); List <OperationsMDP> lista = new List <OperationsMDP>(); lista.Add(opmdp); List <OperationsMDP> lista2 = new List <OperationsMDP>(); lista2.Add(opmdp); ManufacturingPlan mp = new ManufacturingPlan(dt, lista); ManufacturingPlan mp2 = new ManufacturingPlan(dt, lista); var mockito = new Mock <Product>(); Product p = new Product(na, mp); //Assert Assert.Equal("Teste1", p.Name.name); Assert.Equal("Tool", p.ManufacturingPlan.Operations[0].ToolDesc); Assert.Equal("name", p.ManufacturingPlan.Operations[0].Name); Assert.Equal(30, p.ManufacturingPlan.Operations[0].Duration); Assert.Equal(1, p.ManufacturingPlan.Operations[0].operationTypeId); Assert.Equal(lista2, p.ManufacturingPlan.Operations); //Assert.Equal(mp2, p.ManufacturingPlan); }
public bootstrap(MasterContext context) { _context = context; if (_context.Operations.Count() == 0) { OperationsMDP op = new OperationsMDP("desc1", "name1", 10, 1); OperationsMDP op2 = new OperationsMDP("desc2", "name2", 150, 2); _context.Operations.Add(op); _context.Operations.Add(op2); _context.SaveChanges(); } if (_context.ManufacturingPlans.Count() == 0) { List <OperationsMDP> lista1 = new List <OperationsMDP>(); List <OperationsMDP> lista2 = new List <OperationsMDP>(); lista1.Add(_context.Operations.Find(1)); lista2.Add(_context.Operations.Find(2)); _context.ManufacturingPlans.Add(new ManufacturingPlan(DateTime.Today, lista1)); _context.ManufacturingPlans.Add(new ManufacturingPlan(DateTime.Today, lista2)); _context.SaveChanges(); } if (_context.Products.Count() == 0) { _context.Products.Add(new Product(new Name("Product1"), _context.ManufacturingPlans.Find(1))); _context.Products.Add(new Product(new Name("Product2"), _context.ManufacturingPlans.Find(2))); _context.SaveChanges(); } }
public void EnsureManufacturingPlanGetSetWorks() { //Arrange OperationsMDP opmdp = new OperationsMDP("Tool", "name", 30, 1); DateTime dt = new DateTime(); List <OperationsMDP> lista = new List <OperationsMDP>(); lista.Add(opmdp); List <OperationsMDP> lista2 = new List <OperationsMDP>(); lista2.Add(opmdp); ManufacturingPlan mp = new ManufacturingPlan(dt, lista); //Assert Assert.Equal("Tool", mp.Operations[0].ToolDesc); Assert.Equal("name", mp.Operations[0].Name); Assert.Equal(30, mp.Operations[0].Duration); Assert.Equal(1, mp.Operations[0].operationTypeId); Assert.Equal(lista2, mp.Operations); }
public bool Insert(OperationsMDP op) { if (op != null) { _context.Operations.Add(op); _context.SaveChanges(); } return(true); }
public bool Update(OperationsMDP op) { _context.Entry(op).State = EntityState.Modified; try { _context.SaveChanges(); return(true); } catch (DbUpdateConcurrencyException) { if (op.Id.Equals(-1)) { throw new Exception("No operaction with that id"); } else { throw; } } }
public ActionResult PutOperations(OperationsMDP op) { return(Ok(_IOperationsRepository.Update(op))); }