コード例 #1
0
        public IActionResult GetProducts()
        {
            Respond respond = new Respond();

            try
            {
                using (var db = new Models.NorthwindContext())
                {
                    var productList = db.Products.OrderByDescending(p => p.ProductId).ToList();
                    respond.Success = 1;
                    respond.Data    = productList;
                }
            }
            catch (Exception ex)
            {
                respond.Message = ex.Message;
            }
            return(Ok(respond));
        }
コード例 #2
0
        public IActionResult GetCategory(int categoriaId)
        {
            Respond respond = new Respond();

            try
            {
                using (var db = new Models.NorthwindContext())
                {
                    var find = db.Categories.Find(categoriaId);
                    respond.Success = 1;
                    respond.Message = "This is the Category found";
                    respond.Data    = find;
                }
            }
            catch (Exception ex)
            {
                respond.Message = ex.Message;
            }
            return(Ok(respond));
        }
コード例 #3
0
        public IActionResult GetAllCategorys()
        {
            Respond respond = new Respond();

            try
            {
                using (var db = new Models.NorthwindContext())
                {
                    var categoryList = db.Categories.OrderBy(c => c.CategoryId).ToList();
                    respond.Success = 1;
                    respond.Message = "This is Category List";
                    respond.Data    = categoryList;
                }
            }
            catch (Exception ex)
            {
                respond.Message = ex.Message;
            }
            return(Ok(respond));
        }