// GET: api/SanPhams public IHttpActionResult GetSanPhams() { var sanPham = db.SanPhams; var sanPhamList = new List <SanPhamViewModel>(); if (sanPham != null) { sanPham.ToList().ForEach(v => { var tmp = new SanPhamViewModel() { MaSanPham = v.MaSanPham, TenSanPham = v.TenSanPham, KichCo = v.KichCo, DonGia = v.DonGia, HinhAnh = ImageTask.GetImage(v.HinhAnh), MaChuDe = v.MaChuDe }; sanPhamList.Add(tmp); }); return(Ok(sanPhamList.ToList())); } else { return(BadRequest()); } }
public IHttpActionResult GetNhanVien(int id) { var nhanVienList = db.NhanViens.SingleOrDefault(v => v.MaNhanVien == id); if (nhanVienList == null) { return(NotFound()); } string tmp = ""; if (nhanVienList.HinhAnh != "") { tmp = ImageTask.GetImage(nhanVienList.HinhAnh); nhanVienList.HinhAnh = tmp; } var nhanVienEntity = new NhanVienViewModel() { MaNhanVien = nhanVienList.MaNhanVien, TenNhanVien = nhanVienList.TenNhanVien, GioiTinh = nhanVienList.GioiTinh, NgaySinh = nhanVienList.NgaySinh, DiaChi = nhanVienList.DiaChi, SDT = nhanVienList.SDT, Email = nhanVienList.Email, NgayBatDau = nhanVienList.NgayBatDau, HinhAnh = tmp }; return(Ok(nhanVienEntity)); }
// GET: api/NhanViens public IHttpActionResult GetNhanViens() { var nhanVienList = db.NhanViens; var nhanVienEntity = new List <NhanVienViewModel>(); nhanVienList.ToList().ForEach(v => { string tmp = ""; if (v.HinhAnh != "") { tmp = ImageTask.GetImage(v.HinhAnh); v.HinhAnh = tmp; } nhanVienEntity.Add(new NhanVienViewModel { MaNhanVien = v.MaNhanVien, TenNhanVien = v.TenNhanVien, GioiTinh = v.GioiTinh, NgaySinh = v.NgaySinh, DiaChi = v.DiaChi, SDT = v.SDT, Email = v.Email, NgayBatDau = v.NgayBatDau, HinhAnh = tmp }); }); return(Ok(nhanVienEntity.ToList())); }
// GET: api/KhachHangs public IHttpActionResult GetKhachHangs() { var khachHangList = db.KhachHangs; var khachHangEntity = new List <KhachHangViewModel>(); khachHangList.ToList().ForEach(v => { string tmp = ""; if (v.HinhAnh != "") { tmp = ImageTask.GetImage(v.HinhAnh); v.HinhAnh = tmp; } khachHangEntity.Add(new KhachHangViewModel { MaKhachHang = v.MaKhachHang, TenKhachHang = v.TenKhachHang, GioiTinh = v.GioiTinh, NgaySinh = v.NgaySinh, DiaChi = v.DiaChi, SDT = v.SDT, Email = v.Email, HinhAnh = v.HinhAnh }); }); if (khachHangList != null) { return(Ok(khachHangList)); } else { return(BadRequest()); } //MaKhachHang = v.MaKhachHang, // TenKhachHang = v.TenKhachHang, // GioiTinh = v.GioiTinh, // NgaySinh = v.NgaySinh, // DiaChi = v.DiaChi, // SDT = v.SDT, // Email = v.Email, // HinhAnh = v.HinhAnh }
public IHttpActionResult GetSanPhams(int id) { var sanPham = db.SanPhams.SingleOrDefault(v => v.MaSanPham == id); if (sanPham == null) { return(NotFound()); } else { var sanPhamViewModel = new SanPhamViewModel() { MaSanPham = sanPham.MaSanPham, TenSanPham = sanPham.TenSanPham, KichCo = sanPham.KichCo, DonGia = sanPham.DonGia, HinhAnh = ImageTask.GetImage(sanPham.HinhAnh), MaChuDe = sanPham.MaChuDe }; return(Ok(sanPhamViewModel)); } }
public IHttpActionResult GetKhachHang(int id) { //var khachHangList = db.KhachHangs.Where(v => v.MaKhachHang == id).Select(v => new KhachHangViewModel { MaKhachHang = v.MaKhachHang, TenKhachHang = v.TenKhachHang, GioiTinh = v.GioiTinh, NgaySinh = v.NgaySinh, DiaChi = v.DiaChi, SDT = v.SDT, Email = v.Email, HinhAnh = v.HinhAnh }); //if (khachHangList == null) //{ // return NotFound(); //} var khachHangList = db.KhachHangs.SingleOrDefault(v => v.MaKhachHang == id); if (khachHangList == null) { return(NotFound()); } string tmp = ""; if (khachHangList.HinhAnh != "") { tmp = ImageTask.GetImage(khachHangList.HinhAnh); khachHangList.HinhAnh = tmp; } var khachHangEntity = new KhachHangViewModel() { MaKhachHang = khachHangList.MaKhachHang, TenKhachHang = khachHangList.TenKhachHang, GioiTinh = khachHangList.GioiTinh, NgaySinh = khachHangList.NgaySinh, DiaChi = khachHangList.DiaChi, SDT = khachHangList.SDT, Email = khachHangList.Email, HinhAnh = khachHangList.HinhAnh }; return(Ok(khachHangEntity)); }