Пример #1
0
        internal void OnNewDigitizedCardRequest(NewDigitizedCardRequest newDigitizedCardRequest)
        {
            int cardSchemeNumber = new Random().Next(100, 200) % 2;

            DigitizedCard digitizedCard = new DigitizedCard()
            {
                ClientNumber         = newDigitizedCardRequest.ClientNumber,
                PrimaryAccountNumber = newDigitizedCardRequest.PrimaryAccountNumber,
                Id                     = Guid.NewGuid(),
                CardScheme             = DependencyService.Get <ICardSchemeService>().GetAll().ToArray()[cardSchemeNumber],
                DigitizedCardAnalytics = new System.Collections.Generic.List <DigitizedCardAnalytic>()
            };

            Random generator     = new Random();
            int    analyticCount = (generator.Next(100, 200) % 5) + 1;

            for (int i = 0; i < analyticCount; i++)
            {
                digitizedCard.DigitizedCardAnalytics.Add(new DigitizedCardAnalytic()
                {
                    DigitizedCardId = digitizedCard.Id,
                    Date            = new DateTime(2019, (generator.Next(100, 200) % 8) + 1, (generator.Next(100, 200) % 28) + 1),
                    Amount          = decimal.Parse((generator.NextDouble() * (1000 - 1) + 1).ToString("N2"))
                });
            }

            Messenger.Default.Send(digitizedCard);
        }
Пример #2
0
        internal void Add(DigitizedCard digitizedCard)
        {
            try
            {
                DependencyService.Get <LocalStorage>().Connection.BeginTransaction();

                DependencyService.Get <LocalStorage>().Connection.InsertOrReplace(digitizedCard);

                DependencyService.Get <LocalStorage>().Connection.InsertAll(digitizedCard.DigitizedCardAnalytics);

                DependencyService.Get <LocalStorage>().Connection.Commit();
            }
            catch
            {
                DependencyService.Get <LocalStorage>().Connection.Rollback();
            }
        }
Пример #3
0
        private void OnDigitizedCardReceived(DejamobileBackEnd.Models.DigitizedCard digitizedCard)
        {
            DigitizedCard card = new DigitizedCard()
            {
                Id                     = digitizedCard.Id,
                CardSchemeName         = digitizedCard.CardScheme.Name,
                ClientNumber           = digitizedCard.ClientNumber,
                DigitizedCardAnalytics = (from analytic in digitizedCard.DigitizedCardAnalytics
                                          select new DigitizedCardAnalytic()
                {
                    Amount = analytic.Amount,
                    Date = analytic.Date,
                    DigitizedCardId = analytic.DigitizedCardId
                }).ToList(),
                PrimaryAccountNumber = digitizedCard.PrimaryAccountNumber
            };

            Add(card);

            Messenger.Default.Send(new NewDigitizedCard());
        }
Пример #4
0
        public void Delete(DigitizedCard digitizedCard)
        {
            List <DigitizedCardAnalytic> analytics = DependencyService.Get <LocalStorage>().Connection.Table <DigitizedCardAnalytic>().Where(x => x.DigitizedCardId.Equals(digitizedCard.Id)).ToList();

            try
            {
                DependencyService.Get <LocalStorage>().Connection.BeginTransaction();

                foreach (DigitizedCardAnalytic analytic in analytics)
                {
                    DependencyService.Get <LocalStorage>().Connection.Delete(analytic);
                }

                DependencyService.Get <LocalStorage>().Connection.Delete(digitizedCard);

                DependencyService.Get <LocalStorage>().Connection.Commit();
            }
            catch
            {
                DependencyService.Get <LocalStorage>().Connection.Rollback();
            }
        }
Пример #5
0
        void ExecuteDeleteCardCommand(DigitizedCard digitizedCard)
        {
            DependencyService.Get <IDigitizedCardService>().Delete(digitizedCard);

            LoadItemsCommand.Execute(null);
        }
 public DigitizedCardAnalyticsViewModel(DigitizedCard card)
 {
     Title = $"Payments for {card.PrimaryAccountNumber} account";
     DigitizedCardAnalytics = new ObservableCollection <DigitizedCardAnalytic>(card.DigitizedCardAnalytics.OrderByDescending(x => x.Date));
     OnPropertyChanged("DigitizedCardAnalytics");
 }