Exemplo n.º 1
0
        public RecordTemplateDetailsView(IRecordTemplateService service, RecordTemplateModel entity, bool isNew, bool?allowSaveIfNoChanges = null)
            : base(service, entity, isNew, allowSaveIfNoChanges)
        {
            InitializeComponent();

            // load storages
            IStorageService storageService = ServiceManager.ConfigureService <StorageService>();

            _storages = storageService.GetVisible(GlobalVariables.UserId, entity.StorageId);
            comboStorage.ItemsSource = _storages;

            // load currencies
            ICurrencyService currencyService = ServiceManager.ConfigureService <CurrencyService>();

            _currencies = currencyService.GetActive(GlobalVariables.UserId, entity.CurrencyId, entity.Storage?.CurrencyId, entity.Debt?.CurrencyId);
            CurrencySelector.Currencies = _currencies;

            // load debts
            IDebtService debtService = ServiceManager.ConfigureService <DebtService>();

            _debts = debtService.GetActive(GlobalVariables.UserId, entity.DebtId);
            comboDebts.ItemsSource = _debts;

            // set currencies list
            compCurrencyExchangeRate.CurrencyIds =
                _storages.Select(_ => _.CurrencyId).Distinct().Concat(_currencies.Select(c => c.Id)).Distinct().ToList();

            // set header and commands panel context
            LabelHeader.Content       = ViewHeader;
            CommandsPanel.DataContext = Commands;
        }
        public DebtsSummary CalculateSummary()
        {
            var debtsSummary = new DebtsSummary();

            foreach (var debt in _debtSevice.GetActive(_userId))
            {
                debtsSummary.Update(debt.DebtType, debt.Currency, debt.Value - debt.PaidValue);
            }

            return(debtsSummary);
        }
        public RepayDebtEventDetailsView(IRepayDebtEventService service, RepayDebtEventViewModel entity, bool isNew)
            : base(service, entity, isNew)
        {
            InitializeComponent();

            // init
            eventService = ServiceManager.ConfigureService <EventService>();

            // load debts
            IDebtService debtService = ServiceManager.ConfigureService <DebtService>();

            _debts = debtService.GetActive(GlobalVariables.UserId, entity.DebtId);
            comboDebts.ItemsSource = _debts;

            // load storages
            IStorageService storageService = ServiceManager.ConfigureService <StorageService>();

            _storages = storageService.GetVisible(GlobalVariables.UserId, entity.StorageId);
            comboStorage.ItemsSource = _storages;

            // load currencies
            ICurrencyService currencyService = ServiceManager.ConfigureService <CurrencyService>();

            _currencies = currencyService.GetActive(GlobalVariables.UserId, entity.Debt?.CurrencyId, entity.Storage?.CurrencyId);

            if (isNew)
            {
                comboCurrencies.ItemsSource = _currencies;
            }
            else
            {
                UpdateCurrenciesList();
            }

            // set currencies list
            compCurrencyExchangeRate.CurrencyIds = _storages.Select(_ => _.CurrencyId)
                                                   .Concat(_currencies.Select(c => c.Id)).Concat(_debts.Select(c => c.CurrencyId)).Distinct().ToList();

            // set header and commands panel context
            LabelHeader.Content       = ViewHeader;
            CommandsPanel.DataContext = Commands;
        }