Пример #1
0
        public HttpResponseMessage GetAll(HttpRequestMessage request)
        {
            return(CreateHttpResponse(request, () =>
            {
                var listLoaiSanPham = _loaiSanPhamService.GetAll();
                HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, listLoaiSanPham);

                return response;
            }));
        }
Пример #2
0
        public HttpResponseMessage GetAll(HttpRequestMessage request)
        {
            IEnumerable <LoaiSanPham> listLoaiSanPham = null;
            var toTal = 0;

            try
            {
                listLoaiSanPham = _loaiSanPhamService.GetAll();
                toTal           = listLoaiSanPham.ToList().Count;
                if (toTal > 0)
                {
                    Message = "Danh sách loại sản phẩm";
                }
                else
                {
                    throw new DbEntityValidationException("Không tồn tại loại sản phẩm nào");
                }
            }
            catch (DbEntityValidationException ex)
            {
                LogException(ex);
            }
            return(GetResponseMessage(IsSuccess, Message, toTal, listLoaiSanPham));
        }