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"); } }
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); }
public IEnumerable <CategoryDTO> Get() { return(categoryModel.GetAllCategories()); }