示例#1
0
        private async void GetCategories()
        {
            try
            {
                CategoryModel categoryModel = new CategoryModel(db);
                var           categories    = await categoryModel.GetAllCategories();

                allCategories = categories;
                LoadCategories(categories);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show("Failed to get categories");
            }
        }
示例#2
0
        public HttpResponseMessage Get()
        {
            HttpResponseMessage responseMessage;
            JSend json;
            List <CategoryDTO> list = categoryModel.GetAllCategories();

            if (list.Count > 0)
            {
                json            = new JSendData <CategoryDTO>("success", list);
                responseMessage = Request.CreateResponse(HttpStatusCode.OK, json);
            }
            else
            {
                json            = new JSendMessage("fail", "No items found");
                responseMessage = Request.CreateResponse(HttpStatusCode.NotFound, json);
            }

            return(responseMessage);
        }
示例#3
0
 public IEnumerable <CategoryDTO> Get()
 {
     return(categoryModel.GetAllCategories());
 }