コード例 #1
0
ファイル: Core.cs プロジェクト: Zeddex/SkillBox-courses
        /// <summary>
        /// Calculate deposit monthly interest
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        public double[] DepositInfo(int clientId, string depType, int depRate)
        {
            double[] months = new double[12];

            double deposit = SqlQueries.GetDepositAmount(clientId);

            // simple interest
            if (depType == "Simple")
            {
                for (int i = 0; i < months.Length; i++)
                {
                    if (i == 0)
                    {
                        months[i] = (((double)deposit / 100 * depRate) / 12) + deposit;
                        Math.Round(months[i], 2);
                        months[i] = Math.Round(months[i], 2);
                        continue;
                    }

                    months[i] = (((double)deposit / 100 * depRate) / 12) + months[i - 1];
                    Math.Round(months[i], 2);
                    months[i] = Math.Round(months[i], 2);
                }
            }

            // capitalized interest
            else
            {
                for (int i = 0; i < months.Length; i++)
                {
                    if (i == 0)
                    {
                        months[i] = (((double)deposit / 100 * depRate) / 12) + deposit;
                        Math.Round(months[i], 2);
                        months[i] = Math.Round(months[i], 2);
                        continue;
                    }

                    months[i] = ((months[i - 1] / 100 * depRate) / 12) + months[i - 1];
                    months[i] = Math.Round(months[i], 2);
                }
            }

            return(months);
        }
コード例 #2
0
ファイル: Core.cs プロジェクト: Zeddex/SkillBox-courses
        public bool HasDeposit(int clientId)
        {
            double result = SqlQueries.GetDepositAmount(clientId);

            return(result != 0);
        }