public void Execute(object parameter) { SingleCurrentAccount currentAccount = SingleCurrentAccount.GetInstance(); currentAccount.Account = new Account(); MainWindow.MainView.IsLoggin = false; new UpdateViewCommand(MainWindow.MainView).Execute("Login"); }
public StatisticsViewModel() { PieCharListExpenses = new ObservableCollection <PieCharItem>(); PieCharListEncomes = new ObservableCollection <PieCharItem>(); unitOfWork = new UnitOfWork(); SingleCurrentAccount currentAccount = SingleCurrentAccount.GetInstance(); account = currentAccount.Account; StartUp(); }
public BelarusBankInformation() { ChromeDriverService service = ChromeDriverService.CreateDefaultService(); service.HideCommandPromptWindow = true; unitOfWork = new UnitOfWork(); Histories = new List <History>(); CurrentAccount = SingleCurrentAccount.GetInstance().Account; driver = new ChromeDriver(service); }
public void CheckLoggin() { SingleCurrentAccount currentAccount = SingleCurrentAccount.GetInstance(); CurrentAccount = currentAccount.Account; if (CurrentAccount.Username == null) { IsLoggin = false; } else { IsLoggin = true; } }
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(); }
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); }
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(); }
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 = "Не получилось создать..."; } }
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); } }
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()); }