public async Task <int> Update(KHEditRequest request) { var maKH = await _context.KhachHangs.FindAsync(request.MaKH); var khachHang = await _context.KhachHangs.FirstOrDefaultAsync(x => x.MaKH == request.MaKH); if (khachHang == null) { throw new EkGisException($"Khong tim thay khach hang: {request.MaKH}"); } khachHang.TenKH = request.TenKH; khachHang.DiaChi = request.DiaChi; khachHang.Email = request.Email; khachHang.NgaySinh = request.NgaySinh; khachHang.SDT = request.SDT; return(await _context.SaveChangesAsync()); }
public async Task <IActionResult> Update(KHEditRequest request) { var result = await _khachHangService.Update(request); return(Ok(result)); }