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)); }
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)); }
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)); }