public async Task <IActionResult> PutChitietdonhang([FromRoute] string MaDH, string MaSP, [FromBody] Chitietdonhang chitietdonhang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (MaDH != chitietdonhang.MaDh || MaSP != chitietdonhang.MaSp)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChitietdonhangExists(MaDH) || !ChitietdonhangExists(MaSP))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutDonhang([FromRoute] string id, [FromBody] Donhang donhang)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != donhang.MaDh)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }