public MethodResponse <List <Product> > GetAllProducts() { var response = new MethodResponse <List <Product> >(); try { var logicEngine = new LogicEngine(); var logic = logicEngine.GetProducts(); if (int.Parse(logic.Code.ToString()) != 0) { return(new MethodResponse <List <Product> >() { Code = logic.Code, Message = logic.Message }); } response.Code = 0; response.Result = logic.Result; return(response); } catch (Exception ex) { return(new MethodResponse <List <Product> >() { Code = -1, Message = "Ocurrio un error al extraer los productos: " + ex.Message }); } }
public ActionResult Index() { try { var logicEngine = new LogicEngine(); var logic = (List <Product>)logicEngine.GetProducts().Result; ViewBag.Products = logic; ViewBag.TotalProducts = logic.Count(); } catch (Exception ex) { throw; } return(View()); }