예제 #1
0
        public async Task <IActionResult> PutMathang(string id, Mathang mathang)
        {
            if (id != mathang.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutNhacungcap(string id, Nhacungcap nhacungcap)
        {
            if (id != nhacungcap.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutKhachhang(string id, Khachhang khachhang)
        {
            if (id != khachhang.Id)
            {
                return(BadRequest());
            }

            _context.Entry(khachhang).State = EntityState.Modified;
            var khachhangs = from user in _context.Khachhangs
                             select user;

            foreach (var x in khachhangs)
            {
                if (x.Sdt.Equals(khachhang.Sdt) && x.Id != khachhang.Id)
                {
                    return(Conflict());
                }
            }
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KhachhangExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }