Esempio n. 1
0
 public IndexViewModel(RegularPayment regularPayment)
 {
     RegularPaymentId = regularPayment.RegularPaymentId;
     Amount = regularPayment.Amount;
     Name = regularPayment.Name;
     PaymentDay = regularPayment.PaymentDay;
 }
 public EditRegularPaymentViewModel(RegularPayment regularPayment)
 {
     RegularPaymentId = regularPayment.RegularPaymentId;
     Name = regularPayment.Name;
     Amount = regularPayment.Amount;
     PaymentDay = regularPayment.PaymentDay;
     BankAccountId = regularPayment.BankAccountId;
 }
 public void UpdateRegularPayment(RegularPayment newRegularPayment)
 {
     RegularPayment regularPayment = context.RegularPayments.Where(f => f.RegularPaymentId == newRegularPayment.RegularPaymentId).FirstOrDefault();
     regularPayment.Name = newRegularPayment.Name;
     regularPayment.Amount = newRegularPayment.Amount;
     regularPayment.PaymentDay = newRegularPayment.PaymentDay;
     context.SaveChanges();
 }
Esempio n. 4
0
        public EditViewModel(RegularPayment regularPayment)
        {
            var accounts = bankAccountRepository.GetBankAccounts();

            Id = regularPayment.RegularPaymentId;
            Name = regularPayment.Name;
            Amount = regularPayment.Amount;
            PaymentDay = regularPayment.PaymentDay;
            Accounts = accounts.Select(a => new SelectListItem
            {
                Value = a.BankAccountId.ToString(),
                Text = a.Name
            });
        }
 public void InsertRegularPayment(RegularPayment regularPayment)
 {
     context.RegularPayments.Add(regularPayment);
     context.SaveChanges();
 }
Esempio n. 6
0
        public ActionResult EditRegularPayment(EditRegularPaymentViewModel model)
        {
            if (ModelState.IsValid)
            {
                RegularPayment regularPayment = new RegularPayment
                {
                    RegularPaymentId = model.RegularPaymentId,
                    Name = model.Name,
                    Amount = model.Amount,
                    PaymentDay = model.PaymentDay,
                    BankAccountId = model.BankAccountId
                };

                regularPaymentsRepository.UpdateRegularPayment(regularPayment);

                return RedirectToAction("Details", new { accountId = model.BankAccountId });
            }
            else
            {
                return View(model);
            }
        }