public async Task <IActionResult> PutGoodBrandCode([FromRoute] int id, [FromBody] GoodBrandCode goodBrandCode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != goodBrandCode.Id)
            {
                return(BadRequest());
            }

            var getBrand = await _context.GetTransactionInv
                           .Where(w => w.GoodBrandCode == goodBrandCode.GoodBrandcode)
                           .GroupBy(g => new { g.GoodBrandName })
                           .Select(s => new { s.Key.GoodBrandName })
                           .ToListAsync();

            var getSubCodePro = await _context.CodePromotion
                                .Where(w => w.SubId == goodBrandCode.SubId)
                                .GroupBy(g => new { g.SubCodePro })
                                .Select(s => new { s.Key.SubCodePro })
                                .ToListAsync();

            goodBrandCode.GoodBrandName = getBrand[0].GoodBrandName;
            goodBrandCode.SubCodePro    = getSubCodePro[0].SubCodePro;

            _context.Entry(goodBrandCode).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!GoodBrandCodeExists(id.ToString()))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PostGoodBrandCode([FromBody] GoodBrandCode goodBrandCode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var getBrand = await _context.GetTransactionInv
                           .Where(w => w.GoodBrandCode == goodBrandCode.GoodBrandcode)
                           .GroupBy(g => new { g.GoodBrandName })
                           .Select(s => new { s.Key.GoodBrandName })
                           .ToListAsync();

            var getSubCodePro = await _context.CodePromotion
                                .Where(w => w.SubId == goodBrandCode.SubId)
                                .GroupBy(g => new { g.SubCodePro })
                                .Select(s => new { s.Key.SubCodePro })
                                .ToListAsync();

            goodBrandCode.GoodBrandName = getBrand[0].GoodBrandName;
            goodBrandCode.SubCodePro    = getSubCodePro[0].SubCodePro;

            _context.GoodBrandCode.Add(goodBrandCode);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (GoodBrandCodeExists(goodBrandCode.GoodBrandcode))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetGoodBrandCode", new { id = goodBrandCode.GoodBrandcode }, goodBrandCode));
        }