Esempio n. 1
0
        private object GetAll(string owner)
        {
            try {
                // Create a connection to the PetaPoco ORM and try to fetch and object with the given Id
                ItemMapper        itm_mpr = new ItemMapper();
                IList <ItemModel> res     = null;

                // Get all objects or a filtered list by user
                if (owner != null)
                {
                    res = itm_mpr.GetByOwner(owner);
                }
                else
                {
                    res = itm_mpr.Get();
                }

                // Convert this into an array of JSON objects.
                // string json = JsonConvert.SerializeObject(products, Formatting.Indented);
                return(Response.AsJson(res));
            } catch (Exception e) {
                return(HandleException(e, String.Format("ItemModule.GetAll()")));
            }
        }