Пример #1
0
 public static void AddPayment(Credit credit, double amount)
 {
     BankContext bank = new BankContext();
     Payment payment = new Payment();
     payment.CreditId = credit.Id;
     payment.Amount = amount;
     payment.PayDate = DateTime.UtcNow;
     bank.Payments.Add(payment);
     bank.SaveChanges();
 }
Пример #2
0
        public static bool ArchiveCredit(Credit credit)
        {
            BankContext bank = new BankContext();
            if (bank.Credits.Contains(credit))
            {
                try
                {
                    if (Archive(credit) == true)
                        return true;
                    else
                        return false;
                }
                catch (Exception)
                {

                }
            }
            return false;
        }
Пример #3
0
 public static double CalculateMonthlyProcentAmount(Credit credit)
 {
     double result = 0;
     switch (credit.PaymentType)
     {
         case PaymentType.ActualBalance:
             {
                 result = credit.Amount / credit.Months + credit.Amount * credit.Rate;
                 break;
             }
         case PaymentType.Annuity:
             {
                 result = (credit.Amount * credit.Rate) / ((1 - 1 / (1 + credit.Rate)) * credit.Months);
                 break;
             }
         case PaymentType.Extraordinary:
             {
                 result = credit.Amount * credit.Rate;
                 break;
             }
     }
     return result;
 }
Пример #4
0
        private static bool Archive(Credit credit)
        {
            try
            {
                credit.Status = CreditStatus.Passive;
                return true;
            }
            catch (Exception)
            {
                return false;

            }
        }
Пример #5
-1
        public static bool EditCredit(Credit creditToEdit, double? amount, Currency? currency, double? rate, int? months)
        {
            BankContext bank = new BankContext();
            if (!bank.Credits.Contains(creditToEdit))
                return false;
            else
            {
                try
                {
                    if (amount != null)
                        creditToEdit.Amount = (double)amount;
                    if (currency != null)
                        creditToEdit.Currency = (Currency)currency;
                    if (months != null)
                        creditToEdit.Months= (int)months;
                    if (rate != null)
                        creditToEdit.Rate = (double)rate;
                    bank.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }

            }
        }