Ejemplo n.º 1
0
        public void Execute(object parameter)
        {
            SingleCurrentAccount currentAccount = SingleCurrentAccount.GetInstance();

            currentAccount.Account       = new Account();
            MainWindow.MainView.IsLoggin = false;
            new UpdateViewCommand(MainWindow.MainView).Execute("Login");
        }
Ejemplo n.º 2
0
        public StatisticsViewModel()
        {
            PieCharListExpenses = new ObservableCollection <PieCharItem>();
            PieCharListEncomes  = new ObservableCollection <PieCharItem>();
            unitOfWork          = new UnitOfWork();
            SingleCurrentAccount currentAccount = SingleCurrentAccount.GetInstance();

            account = currentAccount.Account;
            StartUp();
        }
Ejemplo n.º 3
0
        public BelarusBankInformation()
        {
            ChromeDriverService service = ChromeDriverService.CreateDefaultService();

            service.HideCommandPromptWindow = true;

            unitOfWork     = new UnitOfWork();
            Histories      = new List <History>();
            CurrentAccount = SingleCurrentAccount.GetInstance().Account;
            driver         = new ChromeDriver(service);
        }
Ejemplo n.º 4
0
        public void CheckLoggin()
        {
            SingleCurrentAccount currentAccount = SingleCurrentAccount.GetInstance();

            CurrentAccount = currentAccount.Account;
            if (CurrentAccount.Username == null)
            {
                IsLoggin = false;
            }
            else
            {
                IsLoggin = true;
            }
        }
Ejemplo n.º 5
0
        public BalanceViewModel()
        {
            SingleCurrentAccount currentAccount = SingleCurrentAccount.GetInstance();

            CurrentAccount = currentAccount.Account;
            UnitOfWork     = new UnitOfWork();
            Histories      = new List <History>();
            GetHistories();

            CreateCommand.CheckRepeatHistories();

            Balance           = GetBalance(Histories);
            UpdateViewCommand = new UpdateViewCommand(MainWindow.MainView);
            RefreshHistoryCollectionView();
            DeleteCommand     = new DeleteCommand(this);
            LinkToEditCommand = new LinkToEditCommand();
        }
Ejemplo n.º 6
0
        public static double GetBalance(List <History> histories)
        {
            double SumOfHistories = SingleCurrentAccount.GetInstance().Account.Balance;

            foreach (History history in histories)
            {
                if (history.Activity.ActivityType.Title == "Доходы")
                {
                    SumOfHistories += history.Amount;
                }
                else if (history.Activity.ActivityType.Title == "Расходы")
                {
                    SumOfHistories -= history.Amount;
                }
            }

            return(SumOfHistories);
        }
Ejemplo n.º 7
0
        public FilterBalanceViewModel()
        {
            unitOfWork = new UnitOfWork();

            Histories  = new List <History>();
            activities = new List <Activity>();
            Histories  = unitOfWork.HistoryRepository.List(x => x.Account.Id == SingleCurrentAccount.GetInstance().Account.Id&& !x.IsRepeat).ToList();
            HistoriesCollectionView = CollectionViewSource.GetDefaultView(Histories);

            HistoriesCollectionView.Filter = FilterHistories;
            HistoriesCollectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(History.Date), new DateTimeConverter()));

            ActivityTypeExpence = unitOfWork.ActivityTypeRepository.List().ToList()[0];
            ActivityTypeEncome  = unitOfWork.ActivityTypeRepository.List().ToList()[1];

            ChangeRadioButtonCommand = new ChangeRadioButtonCommand(this);

            UpdateProperties();
        }
Ejemplo n.º 8
0
        public void Execute(object parameter)
        {
            _createHistoryViewModel.ErrorMessage = string.Empty;
            try
            {
                double Amount = double.Parse(_createHistoryViewModel.Amount.Replace('.', ','));
                if (Amount <= 0)
                {
                    throw new AmountLessThanZeroException(History.Amount);
                }
                History.Id = Guid.NewGuid();

                History.AccountId  = SingleCurrentAccount.GetInstance().Account.Id;
                History.Account    = null;
                History.ActivityId = History.Activity.Id;
                History.Activity   = null;
                History.Amount     = Amount;
                UnitOfWork.HistoryRepository.Create(History);

                if (History.IsRepeat)
                {
                    History.IsRepeat = false;
                    History.Id       = Guid.NewGuid();
                    UnitOfWork.HistoryRepository.Create(History);
                    CheckRepeatHistories();
                }
            }
            catch (FormatException)
            {
                _createHistoryViewModel.ErrorMessage = "Вы что-то ввели не так";
            }
            catch (AmountLessThanZeroException)
            {
                _createHistoryViewModel.ErrorMessage = "Нужно вводить положительную сумму";
            }
            catch (Exception)
            {
                _createHistoryViewModel.ErrorMessage = "Не получилось создать...";
            }
        }
Ejemplo n.º 9
0
        public static void CheckRepeatHistories()
        {
            List <History> RepeatHistoriesList = new List <History>();
            IUnitOfWork    UnitOfWork          = new UnitOfWork();

            RepeatHistoriesList = UnitOfWork.HistoryRepository.List(x => x.Account.Id == SingleCurrentAccount.GetInstance().Account.Id&& x.IsRepeat).ToList();
            DateTime datenow = new DateTime();

            datenow = DateTime.Now;
            //идея в том чтобы добавить в отдельный список все хистори с isrepeat и их не показывать в обычных хистори

            foreach (History history in RepeatHistoriesList)
            {
                DateTime historyDate   = history.Date;
                DateDiff dateDiff      = new DateDiff(history.Date, datenow);
                History  copiedHistory = new History()
                {
                    Id          = Guid.NewGuid(),
                    AccountId   = history.AccountId,
                    ActivityId  = history.ActivityId,
                    Date        = history.Date,
                    Amount      = history.Amount,
                    Description = history.Description,
                    IsRepeat    = false
                };
                int i = 0;
                while (i < dateDiff.Months)
                {
                    i++;
                    copiedHistory.Id   = Guid.NewGuid();
                    copiedHistory.Date = copiedHistory.Date.AddMonths(1);

                    UnitOfWork.HistoryRepository.Create(copiedHistory);
                }
                history.Date = history.Date.AddMonths(dateDiff.Months);
                UnitOfWork.HistoryRepository.Edit(history);
            }
        }
Ejemplo n.º 10
0
 public List <History> GetHistoriesByType(string Type)
 {
     return(unitOfWork.HistoryRepository.List(x => x.Activity.ActivityType.Title == Type && !x.IsRepeat &&
                                              x.Account.Id == SingleCurrentAccount.GetInstance().Account.Id)
            .ToList());
 }