示例#1
0
        private void CategoryLoad()
        {
            string text;

            string[] items;
            string[] splits = new string[1];
            splits[0] = OVERHEAD;

            try
            {
                foreach (var txtFile in categoryDirectoryInfo.GetFiles())
                {
                    text  = File.ReadAllText(CATEGORY_FILE_PATH + txtFile);
                    items = text.Split(splits, StringSplitOptions.RemoveEmptyEntries);

                    Category category = new Category
                    {
                        Name = items[0],
                        Kind = (ECategory)Enum.Parse(typeof(ECategory), items[1])
                    };


                    Categories.Add(category);
                    CategoryNames.Add(category.Name);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex + DateTime.Now.ToLongTimeString());
            }
        }
示例#2
0
        private void CategoryValuePush()
        {
            Category category = new Category
            {
                Name = Name,
                Kind = ECategory.Other
            };

            Categories.Add(category);
            CategorySave(category);
            CategoryNames.Add(Name);
        }
        public ArticleViewModelCollection()
        {
            var categories = new CategoryCollection();

            //List<string> categoryList = new List<string>();
            foreach (var item in categories.AvailibleCategories.Keys)
            {
                CategoryNames.Add(new SelectListItem {
                    Text = item, Value = item
                });
            }
        }
        public async System.Threading.Tasks.Task AddNewCat(string name)
        {
            var cat = new Category()
            {
                Name = name, DoneCat = false, Items = new List <Item>()
            };
            var        catJson    = JsonConvert.SerializeObject(cat);
            HttpClient httpClient = new HttpClient();
            var        res        = await httpClient.PostAsync(new Uri("http://localhost:5001/api/Category/"),
                                                               new HttpStringContent(catJson, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json"));

            if (res.IsSuccessStatusCode)
            {
                Category newCat = JsonConvert.DeserializeObject <Category>(res.Content.ToString());
                Categories.Add(newCat);
                Travellist.Categories.Add(newCat);
                CategoryNames.Add(newCat.Name);
            }
        }
        private void loadCategories()
        {
            //HttpClient httpClient = new HttpClient();
            //var json = await httpClient.GetStringAsync(new Uri("http://localhost:5001/api/Category"));
            //var categoryList = JsonConvert.DeserializeObject<IList<Category>>(json);


            var categoryList = Travellist.Categories;

            if (categoryList != null)
            {
                foreach (var c in categoryList)
                {
                    List <Item> orderdItems = c.Items.OrderBy(i => i.Name).ToList();
                    c.Items = orderdItems;
                    Categories.Add(c);
                    CategoryNames.Add(c.Name);
                }
            }
        }