public async Task <ProductionOrderType> addProductionOrderType(ProductionOrderType productionOrderType)
        {
            _context.ProductionOrderTypes.Add(productionOrderType);
            await _context.SaveChangesAsync();

            return(productionOrderType);
        }
        public async Task <IActionResult> Post([FromBody] ProductionOrderType productionOrderType)
        {
            productionOrderType.productionOrderTypeId = 0;
            if (ModelState.IsValid)
            {
                productionOrderType = await _productionOrderTypeService.addProductionOrderType(productionOrderType);

                return(Created($"api/phases/{productionOrderType.productionOrderTypeId}", productionOrderType));
            }
            return(BadRequest(ModelState));
        }
        public async Task <IActionResult> Put(int id, [FromBody] ProductionOrderType productionOrderType)
        {
            if (ModelState.IsValid)
            {
                productionOrderType = await _productionOrderTypeService.updateProductionOrderType(id, productionOrderType);

                if (productionOrderType != null)
                {
                    return(NoContent());
                }
                return(NotFound());
            }
            return(BadRequest(ModelState));
        }
예제 #4
0
        public static string ToStringEnum(this ProductionOrderType pProductionOrderType)
        {
            var name = string.Empty;

            switch (pProductionOrderType)
            {
            case ProductionOrderType.Standard:
                name = Standard;
                break;

            case ProductionOrderType.Special:
                name = Special;
                break;

            case ProductionOrderType.Disassembly:
                name = Disassembly;
                break;

            default:
                break;
            }

            return(name);
        }
예제 #5
0
        public static string GetName(this ProductionOrderType pProductionOrderType)
        {
            var name = string.Empty;

            switch (pProductionOrderType)
            {
            case ProductionOrderType.Standard:
                name = "Padrão";
                break;

            case ProductionOrderType.Special:
                name = "Especial";
                break;

            case ProductionOrderType.Disassembly:
                name = "Desmontagem";
                break;

            default:
                break;
            }

            return(name);
        }
        public async Task <ProductionOrderType> updateProductionOrderType(int productionOrderTypeId, ProductionOrderType productionOrderType)
        {
            var currentType = await _context.ProductionOrderTypes
                              .Where(x => x.productionOrderTypeId == productionOrderTypeId)
                              .Include(x => x.stateConfiguration)
                              .ThenInclude(x => x.states)
                              .AsNoTracking()
                              .FirstOrDefaultAsync();

            if (productionOrderTypeId != productionOrderType.productionOrderTypeId ||
                productionOrderType == null ||
                currentType == null)
            {
                return(null);
            }
            productionOrderType.stateConfiguration = currentType.stateConfiguration;

            _context.ProductionOrderTypes.Update(productionOrderType);
            await _context.SaveChangesAsync();

            return(await getProductionOrderType(productionOrderTypeId));
        }