public async Task <IActionResult> PostLoaihang([FromBody] Loaihang loaihang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Loaihang.Add(loaihang);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (LoaihangExists(loaihang.Maloai))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetLoaihang", new { id = loaihang.Maloai }, loaihang));
        }
        public async Task <IActionResult> PutLoaihang([FromRoute] string id, [FromBody] Loaihang loaihang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != loaihang.Maloai)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }