Пример #1
0
        public static List <LoadAndCategory> sortLoadByCategory(string Category)
        {
            var loadStore = new LoadStore()
            {
                Path = loadPath
            };
            var loadList      = loadStore.GetCollection();
            var categoryStore = new CategoryStore()
            {
                Path = categoryPath
            };
            var categoryList = categoryStore.GetCollection();

            var loadAndCategory = loadList
                                  .Join(categoryList, load => load.CategoryId, category => category.Id, (load, category) => new
            {
                load,
                category
            }).ToList();

            var returnVale = loadAndCategory
                             .Select(
                x => new LoadAndCategory()
            {
                Id          = x.load.Id,
                Phone       = x.load.Phone,
                Description = x.category.Description
            }
                ).Where(y => y.Description.Equals(Category))
                             .ToList();

            return(returnVale);
        }
Пример #2
0
        public static void AddLoad(string Phone, string Category)
        {
            var categoryStore = new CategoryStore()
            {
                Path = categoryPath
            };
            var categoryList = categoryStore.GetCollection();
            var loadStore    = new LoadStore()
            {
                Path = loadPath
            };
            var loadList = loadStore.GetCollection();

            int categoryId = Convert.ToInt32(categoryList
                                             .Where(x => x.Description.Equals(Category))
                                             .Select(y => y.Id));

            Load load = new Load(loadList.Count + 1, Phone, categoryId);

            File.AppendAllText(loadPath, load.DataToString() + Environment.NewLine);
        }