Ejemplo n.º 1
0
      public void Init()
      {
          var contribution = new List <Contribution>
          {
              new Contribution {
                  ContributionID = 1, HRDID = 1, DonorID = 1, Year = 2012
              },
              new Contribution {
                  ContributionID = 2, HRDID = 2, DonorID = 1, Year = 2012
              }
          };


          var contributionService = new Mock <IContributionService>();

          contributionService.Setup(m => m.GetAllContribution()).Returns(contribution);


          var contributionDetail = new List <ContributionDetail>()
          {
              new ContributionDetail
              {
                  ContributionDetailID = 1,
                  ContributionID       = 1,
                  CurrencyID           = 1,
                  PledgeDate           = new DateTime(12 / 12 / 12),
                  PledgeReferenceNo    = "ADE123",
                  Amount = 100
              },

              new ContributionDetail
              {
                  ContributionDetailID = 2,
                  ContributionID       = 1,
                  CurrencyID           = 2,
                  PledgeDate           = new DateTime(12 / 12 / 12),
                  PledgeReferenceNo    = "ADE123",
                  Amount = 100
              }
          };

          var contributionDetailService = new Mock <IContributionDetailService>();

          contributionDetailService.Setup(m => m.GetAllContributionDetail()).Returns(contributionDetail);

          var donor = new List <Donor>()
          {
              new Donor {
                  DonorID = 1, DonorCode = "USAID"
              },
              new Donor {
                  DonorID = 1, DonorCode = "WFP"
              },
          };

          var donorService = new Mock <IDonorService>();

          donorService.Setup(m => m.GetAllDonor()).Returns(donor);

          var hrd = new List <HRD>
          {
              new HRD {
                  HRDID         = 1, RationID = 1, SeasonID = 1, Status = 1, CreatedBY = 1, CreatedDate = new DateTime(12 / 12 / 2012),
                  PublishedDate = new DateTime(12 / 12 / 2013), Year = 2012
              },
              new HRD {
                  HRDID         = 2, RationID = 1, SeasonID = 2, Status = 2, CreatedBY = 2, CreatedDate = new DateTime(12 / 12 / 2012),
                  PublishedDate = new DateTime(12 / 12 / 2013), Year = 2012
              },
          };

          var hrdService = new Mock <IHRDService>();

          hrdService.Setup(m => m.GetAllHRD()).Returns(hrd);

          var currency = new List <Currency>
          {
              new Currency {
                  CurrencyID = 1, Code = "USD", Name = "US Dollar"
              },
              new Currency {
                  CurrencyID = 2, Code = "Birr", Name = "Ethiopian Birr"
              }
          };
          var currencyService = new Mock <ICurrencyService>();

          currencyService.Setup(m => m.GetAllCurrency()).Returns(currency);

          var commodity = new List <Commodity>
          {
              new Commodity {
                  CommodityID = 1, Name = "CSB"
              },
              new Commodity {
                  CommodityID = 2, Name = "Pulse"
              },
          };
          var commodityService = new Mock <ICommodityService>();

          commodityService.Setup(m => m.GetAllCommodity()).Returns(commodity);

          var inkindContributionDetail = new List <InKindContributionDetail>
          {
              new InKindContributionDetail {
                  InKindContributionDetailID = 1, ContributionID = 1, ReferenceNumber = "123456", ContributionDate = new DateTime(12 / 12 / 12), CommodityID = 1, Amount = 120
              }
          };
          var inKindContributionDetailService = new Mock <IInkindContributionDetailService>();

          inKindContributionDetailService.Setup(m => m.GetAllInKindContributionDetail()).Returns(inkindContributionDetail);

          _contributionController = new ContributionController(contributionService.Object, contributionDetailService.Object,
                                                               donorService.Object, currencyService.Object, hrdService.Object, commodityService.Object,
                                                               inKindContributionDetailService.Object);
      }
Ejemplo n.º 2
0
        public static void Main(string[] args)
        {
            string loc;
            var    culture = CultureInfo.CurrentCulture;

            if (culture.ToString() == "ru-RU")
            {
                loc = "ru";
            }
            else
            {
                loc = "en";
            }

            var resourceManager = new ResourceManager("LTSefp.CMD.Languages.Messages", typeof(Program).Assembly);

            Console.WriteLine(resourceManager.GetString("Hello", culture));

            Console.WriteLine(resourceManager.GetString("Name", culture));
            string name = Console.ReadLine();

            var userController  = new UserController(name);
            var costaController = new CostsAController(userController.CurrentUser);
            var contrController = new ContributionController(userController.CurrentUser);

            if (userController.IsNewUser)
            {
                Console.WriteLine(resourceManager.GetString("Income Type", culture));
                var type = Console.ReadLine();

                var birthDate = ParseDateTime(resourceManager, culture);

                int earning = 0;

                if (loc == "ru")
                {
                    earning = ParseInt("ваш заработок", culture, resourceManager);
                }
                else
                {
                    earning = ParseInt("your earning", culture, resourceManager);
                }

                userController.SetNewUserData(type, birthDate, earning);
            }

            string currency = "R";

            Console.WriteLine(resourceManager.GetString("Currency", culture));
            var cu = Console.ReadKey();

            Console.WriteLine();
            if (cu.Key == ConsoleKey.C)
            {
                Console.WriteLine(resourceManager.GetString("CurrencyName", culture));
                var readl = Console.ReadLine();
                switch (readl)
                {
                case "dollar":
                    currency = "$";
                    break;

                case "доллар":
                    currency = "$";
                    break;

                case "euro":
                    currency = "E";
                    break;

                case "евро":
                    currency = "E";
                    break;

                default:
                    if (readl.Length == 0)
                    {
                        break;
                    }
                    else if (readl.Length == 1)
                    {
                        currency = readl;
                    }
                    else
                    {
                        currency = readl.Substring(0, 2).ToUpper();
                    }
                    break;
                }
            }

            while (true)
            {
                Console.Clear();
                Console.WriteLine(userController.CurrentUser.Hello(resourceManager, culture));

                Console.WriteLine(resourceManager.GetString("Do", culture));
                Console.WriteLine(resourceManager.GetString("Costs", culture));
                Console.WriteLine(resourceManager.GetString("Contrib", culture));
                Console.WriteLine(resourceManager.GetString("Cred", culture));
                Console.WriteLine(resourceManager.GetString("Quit", culture));


                var key = Console.ReadKey();
                Console.WriteLine();

                #region F
                if (key.Key == ConsoleKey.F)
                {
                    Console.Clear();
                    Console.WriteLine(resourceManager.GetString("If you want", culture));
                    Console.WriteLine(resourceManager.GetString("BeforeCosts", culture));
                }

                var coll = new List <int>();

                while (key.Key == ConsoleKey.F)
                {
                    var strin = Console.ReadLine();
                    if (strin != "cont")
                    {
                        Console.WriteLine(resourceManager.GetString("CostName", culture));
                        var cost = Console.ReadLine();
                        if (cost == "cont")
                        {
                            break;
                        }
                        var price = 0;

                        if (loc == "ru")
                        {
                            price = ParseInt("цену", culture, resourceManager);
                        }
                        else
                        {
                            price = ParseInt("price", culture, resourceManager);
                        }


                        coll.Add(price);
                        var ens = coll.Sum();

                        var c = EnterCostsA(cost, price);

                        costaController.Add(c.Costs, c.Price);

                        Console.Clear();
                        Console.WriteLine(resourceManager.GetString("If you want", culture));
                        Console.WriteLine(resourceManager.GetString("BeforeCosts", culture));
                        Console.WriteLine();
                        foreach (var item in costaController.Cost.Cost)
                        {
                            Console.WriteLine($"\t{item.Key} - {item.Value} {currency}");
                        }

                        var ern = userController.CurrentUser.Earning - ens;
                        if (ern >= 0)
                        {
                            Console.WriteLine();
                            string income = resourceManager.GetString("Income", culture);
                            Console.WriteLine(income + ern + currency);
                        }
                        else
                        {
                            Console.WriteLine("Вы ещё добъётесь успеха, вы в минусе ", ern);
                        }
                    }
                    else
                    {
                        Console.Clear();
                        break;
                    }
                }

                #endregion

                #region G
                if (key.Key == ConsoleKey.G)
                {
                    Console.Clear();
                    Console.WriteLine(resourceManager.GetString("Formula", culture));
                    string formula = Console.ReadLine();
                    if (formula == "c")
                    {
                        Console.WriteLine(resourceManager.GetString("ContrName", culture));
                        string ContrName = Console.ReadLine();

                        Console.WriteLine(resourceManager.GetString("InitialAmount", culture));
                        int money = Int32.Parse(Console.ReadLine());

                        Console.WriteLine(resourceManager.GetString("Rate", culture));
                        float rate = float.Parse(Console.ReadLine());

                        Console.WriteLine(resourceManager.GetString("Month", culture));
                        double month = double.Parse(Console.ReadLine());

                        double res = Contribution.Calc(formula, money, rate, month);
                        var    q   = EnterContrA(ContrName, formula, money, rate, month, res);
                        contrController.Add(q.Contribution, q.Money);
                        Console.Clear();

                        foreach (var item in contrController.Contrib.Contributions)
                        {
                            Console.WriteLine($"\t{item.Key.Name} - {item.Value} {currency}");
                            Console.WriteLine($"\t{item.Key.Month} - {item.Key.Money} {currency}");
                            Console.WriteLine();
                        }
                    }
                    else if (formula == "s")
                    {
                        Console.WriteLine(resourceManager.GetString("CostName", culture));
                        string namec = Console.ReadLine();

                        Console.WriteLine(resourceManager.GetString("InitialAmount"), culture);
                        int money = Int32.Parse(Console.ReadLine());

                        Console.WriteLine(resourceManager.GetString("Rate", culture));
                        float rate = float.Parse(Console.ReadLine());

                        Console.WriteLine(resourceManager.GetString("Month", culture));
                        double month = double.Parse(Console.ReadLine());

                        double res = Contribution.Calc(formula, money, rate, month);
                        var    q   = EnterContrA(namec, formula, money, rate, month, res);
                        contrController.Add(q.Contribution, q.Money);
                        Console.WriteLine(res);

                        foreach (var item in contrController.Contrib.Contributions)
                        {
                            Console.WriteLine($"\t{item.Key} - {item.Value} {currency}");
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                #endregion
                Console.WriteLine();
                #region H
                if (key.Key == ConsoleKey.H)
                {
                    Console.WriteLine(resourceManager.GetString("InitialAmount", culture));
                    double InAm = double.Parse(Console.ReadLine());

                    Console.WriteLine(resourceManager.GetString("Month", culture));
                    int month = Int32.Parse(Console.ReadLine());

                    Console.WriteLine(resourceManager.GetString("Rate", culture));
                    double rate = Convert.ToDouble(Console.ReadLine());

                    Console.WriteLine(resourceManager.GetString("FirstContr", culture));
                    int fC = Int32.Parse(Console.ReadLine());

                    string[] Arr = Credit.monthAmount(InAm, rate, month, fC);
                    Console.WriteLine();
                    Console.WriteLine(Arr[0] + currency);
                    Console.WriteLine(Arr[1] + currency);
                }

                #endregion
                Console.WriteLine();
                if (key.Key == ConsoleKey.Q)
                {
                    Quit();
                }
                Console.ReadKey();
            }
        }