/// <summary> /// Posts the view. /// </summary> private void PostView() { IEnumerable <SanPham> a = sanPhamService.GetAll(); List <SanPhamModel> listModel = a.Select(b => b.ToModel()).ToList(); sanPhanListView.PostView(listModel); }
public HttpResponseMessage GetAll(HttpRequestMessage request) { return(CreateHttpResponse(request, () => { var listSanPham = _sanPhamService.GetAll(); HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, listSanPham); return response; })); }
public HttpResponseMessage GetAll(HttpRequestMessage request) { IEnumerable <SanPham> listSanPham = null; var toTal = 0; try { listSanPham = _sanPhamService.GetAll(); toTal = listSanPham.ToList().Count; if (toTal > 0) { Message = "Danh sách sản phẩm"; } else { throw new DbEntityValidationException("Không tồn tại sản phẩm nào"); } } catch (DbEntityValidationException ex) { LogException(ex); } return(GetResponseMessage(IsSuccess, Message, toTal, listSanPham)); }
// GET: SanPham public ActionResult Index(string search, int page = 1, int pagesize = 10) { return(View(sanPham.GetAll(search, page, pagesize))); }