예제 #1
0
        /// <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);
        }
예제 #2
0
        public HttpResponseMessage GetAll(HttpRequestMessage request)
        {
            return(CreateHttpResponse(request, () =>
            {
                var listSanPham = _sanPhamService.GetAll();
                HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, listSanPham);

                return response;
            }));
        }
예제 #3
0
        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));
        }
예제 #4
0
 // GET: SanPham
 public ActionResult Index(string search, int page = 1, int pagesize = 10)
 {
     return(View(sanPham.GetAll(search, page, pagesize)));
 }