예제 #1
0
파일: Menu.cs 프로젝트: bar-tek/wallet
        public void AddPurchace()
        {
            decimal amount;

            do
            {
                Console.Write("Wprowadź poprawną kwotę: ");
            } while(!decimal.TryParse(Console.ReadLine(), NumberStyles.Any, new CultureInfo("en-US"), out amount));

            Console.Write("Wprowadź nazwę: ");
            string name = Console.ReadLine();

            Console.Write("Wprowadź kategorię: ");
            string   categoryName = Console.ReadLine();
            Category category     = _manager.GetOrCreateCategory(categoryName);

            var purchace = new Purchace()
            {
                Date     = DateTime.Now,
                Amount   = amount,
                Name     = name,
                Category = category
            };

            _manager.AddPurchace(purchace);
            _manager.Save();
        }
예제 #2
0
        private void Read()
        {
            foreach (var line in File.ReadLines(purchacePath))
            {
                string[] props = line.Split(',');

                DateTime date         = DateTime.Parse(props[0]);
                decimal  amount       = Convert.ToDecimal(props[1], new CultureInfo("en-US"));
                string   name         = props[2];
                string   categoryName = props[3];
                Category category     = GetOrCreateCategory(categoryName);

                Purchace purchace = new Purchace()
                {
                    Date     = date,
                    Amount   = amount,
                    Name     = name,
                    Category = category
                };
                Purchaces.Add(purchace);
            }
        }
예제 #3
0
 public void AddPurchace(Purchace purchace)
 {
     Purchaces.Add(purchace);
 }