public async void RefreshDataAsync(RefreshMessage refreshDataMessage) { if (GetType().Name.Equals(refreshDataMessage.ViewModelName)) { Credits.Clear(); var credits = (await _CreditRepository.GetAll()).Where(d => d.Client.User.Id.Equals(_authenticator.GetCurrentUser().Id)).OrderBy(d => d.StartDate).Reverse(); foreach (var credit in credits) { Credits.Add(credit); } } }
// + -move forth, -move back private void MoveTime(int days) { using (var context = kernel.Get<BankDbContext>()) { _creditRepo = new CreditRepository(context); _paymentRepo = new PaymentRepository(context); _clientRepo = new ClientRepository(context); var daysDiff = TimeSpan.FromDays(days); timeDifference += daysDiff; var credits = _creditRepo.GetAll(); //.ToList(); var test = credits.Count(); foreach (var item in credits) { item.StartDate -= daysDiff; item.CountFineFromThisDate -= daysDiff; } //var crArray = credits.Select( // x => // new Credit { // CreditId = x.CreditId, // AccountId = x.AccountId, // CreditTypeId = x.CreditTypeId, // RequestId = x.RequestId, // AllreadyPaid = x.AllreadyPaid, // AmountOfPaymentPerMonth = x.AmountOfPaymentPerMonth, // StartDate = x.StartDate - daysDiff, // IsRepaid = x.IsRepaid, // HasDelays = x.HasDelays, // PaidForFine = x.PaidForFine, // CountFineFromThisDate = x.CountFineFromThisDate - daysDiff//, // //Account = x.Account, // //CreditType = x.CreditType, // //Request = x.Request//, // //Payments = x.Payments // }).ToArray();// _creditRepo.Update(credits.ToArray() /*crArray*/); var payments = _paymentRepo.GetAll().ToList(); payments.ForEach(x => x.Date -= daysDiff); _paymentRepo.Update(payments.ToArray()); var clients = _clientRepo.GetAll().ToList(); foreach (var item in clients) { item.Birthday -= daysDiff; } //var clArray = // clients.Select( // x => // new Client() // { // ClientId = x.ClientId, // UserId = x.UserId, // LastName = x.LastName, // Name = x.Name, // Patronymic = x.Patronymic, // Birthday = x.Birthday - daysDiff, // Mobile = x.Mobile, // Email = x.Email, // PassportNo = x.PassportNo, // PassportIdentificationNo = x.PassportIdentificationNo, // PassportAuthority = x.PassportAuthority, // PassportExpirationDate = x.PassportExpirationDate - daysDiff, // PlaceOfResidence = x.PlaceOfResidence, // RegistrationAddress = x.RegistrationAddress, // User = x.User // }).ToArray(); _clientRepo.Update(clients.ToArray()); context.SaveChanges(); //_context.Dispose(); } //using (var kernel = new StandardKernel(new TimeTravelBindings())) //{ // _context = kernel.Get<BankDbContext>(); //} }
private void MoveTime(int days) // + -move forth, -move back { using (var context = kernel.Get <BankDbContext>()) { _creditRepo = new CreditRepository(context); _paymentRepo = new PaymentRepository(context); _clientRepo = new ClientRepository(context); var daysDiff = TimeSpan.FromDays(days); timeDifference += daysDiff; var credits = _creditRepo.GetAll(); //.ToList(); var test = credits.Count(); foreach (var item in credits) { item.StartDate -= daysDiff; item.CountFineFromThisDate -= daysDiff; } //var crArray = credits.Select( // x => // new Credit { // CreditId = x.CreditId, // AccountId = x.AccountId, // CreditTypeId = x.CreditTypeId, // RequestId = x.RequestId, // AllreadyPaid = x.AllreadyPaid, // AmountOfPaymentPerMonth = x.AmountOfPaymentPerMonth, // StartDate = x.StartDate - daysDiff, // IsRepaid = x.IsRepaid, // HasDelays = x.HasDelays, // PaidForFine = x.PaidForFine, // CountFineFromThisDate = x.CountFineFromThisDate - daysDiff//, // //Account = x.Account, // //CreditType = x.CreditType, // //Request = x.Request//, // //Payments = x.Payments // }).ToArray();// _creditRepo.Update(credits.ToArray() /*crArray*/); var payments = _paymentRepo.GetAll().ToList(); payments.ForEach(x => x.Date -= daysDiff); _paymentRepo.Update(payments.ToArray()); var clients = _clientRepo.GetAll().ToList(); foreach (var item in clients) { item.Birthday -= daysDiff; } //var clArray = // clients.Select( // x => // new Client() // { // ClientId = x.ClientId, // UserId = x.UserId, // LastName = x.LastName, // Name = x.Name, // Patronymic = x.Patronymic, // Birthday = x.Birthday - daysDiff, // Mobile = x.Mobile, // Email = x.Email, // PassportNo = x.PassportNo, // PassportIdentificationNo = x.PassportIdentificationNo, // PassportAuthority = x.PassportAuthority, // PassportExpirationDate = x.PassportExpirationDate - daysDiff, // PlaceOfResidence = x.PlaceOfResidence, // RegistrationAddress = x.RegistrationAddress, // User = x.User // }).ToArray(); _clientRepo.Update(clients.ToArray()); context.SaveChanges(); //_context.Dispose(); } //using (var kernel = new StandardKernel(new TimeTravelBindings())) //{ // _context = kernel.Get<BankDbContext>(); //} }