public async Task <IActionResult> PutLoaiHang([FromRoute] int id, [FromBody] LoaiHang loaiHang) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != loaiHang.IdLoaiHang) { return(BadRequest()); } _context.Entry(loaiHang).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiHangExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutDonDatHang([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DonDatHang donDatHang = _context.DonDatHang.Find(id); donDatHang.TrangThaiDonDatHang = 3; if (id != donDatHang.IdDonDatHang) { return(BadRequest()); } _context.Entry(donDatHang).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DonDatHangExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutKhachHang([FromBody] EditKHRequest khach_hang) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (khach_hang == null) { return(BadRequest()); } KhachHang khachHang = _context.KhachHang.Find(khach_hang.Id); if (checkNullAndEmpty(khach_hang.Address)) { khachHang.DiaChiKhachHang = khach_hang.Address; } if (checkNullAndEmpty(khach_hang.Email)) { khachHang.EmailKhachHang = khach_hang.Email; } if (checkNullAndEmpty(khach_hang.SoDienThoaiKhachHang)) { khachHang.SoDienThoaiKhachHang = khach_hang.SoDienThoaiKhachHang; } if (checkNullAndEmpty(khach_hang.TenKhachHang)) { khachHang.TenKhachHang = khach_hang.TenKhachHang; } if (checkNullAndEmpty(khach_hang.Password)) { khachHang.Password = khach_hang.Password; } if (checkNullAndEmpty(khach_hang.Anh)) { khachHang.Avatar = khach_hang.Anh; } _context.Entry(khachHang).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KhachHangExists(khach_hang.Id)) { return(NotFound()); } else { throw; } } return(Ok(khachHang)); }