示例#1
0
        public static void ExchangeCurrency(string personFirstName, string personLastName, DateTime birthDate,
                                            string passportSeries, string passportId, string currencyName, double amount, bool isSelling)
        {
            var person = GetCustomerBO.GetCustomerByPassportId(passportId);

            if (person == null)
            {
                person = new Abstract.model.Person
                {
                    FirstName      = personFirstName, LastName = personLastName, BirthDate = birthDate,
                    PassportSeries = passportSeries, PassportId = passportId
                };
                CreateCustomerBO.CreateCustomer(person);
            }

            var currency = GetCurrencyBO.GetCurrencyByName(currencyName);

            var outcomeAmount = currency.Purchase * amount;

            if (isSelling)
            {
                outcomeAmount = amount / currency.Sell;
            }


            if (!ValidateForDailyLimits(amount, currency))
            {
                ModernDialog.ShowMessage("Person can't exchange more than 1000 units \nof currency per day.", "Warning",
                                         MessageBoxButton.OK);
                return;
            }

            var outReport = new Abstract.model.Report
            {
                UserId        = SessionService.GetInstance().User.UserId,
                PersonId      = person.PersonId,
                CurrencyId    = currency.CurrencyId,
                IncomAmount   = amount,
                OutcomeAmount = outcomeAmount,
                Date          = DateTime.Now
            };

            CreateReportBO.CreateReport(outReport);

            ModernDialog.ShowMessage("The operation completed successfully. \nYou need to issue " + outcomeAmount +
                                     " units of currency.", "Success!", MessageBoxButton.OK);
        }
示例#2
0
 public ReportList()
 {
     InitializeComponent();
     foreach (var report in (Abstract.model.Report[])GetReportsBO.GetInstance().DoRead())
     {
         var user     = GetEmployeeBO.GetUserById(report.UserId);
         var currency = GetCurrencyBO.GetCurrencyById(report.CurrencyId);
         var person   = GetCustomerBO.GetPersonById(report.PersonId);
         Reports.Children.Add(new TextBlock
         {
             Text = " - " + person.FirstName + " " + person.LastName + ", " +
                    person.BirthDate.Value.ToShortDateString() + " birth, passport id: " + person.PassportId +
                    " has exchanged " + report.IncomAmount + " " + currency.CurrencyName + " to " +
                    report.OutcomeAmount + " units. \nResponsible for the operation is " + user.FirstName + " " +
                    user.LastName + ". Date: " + report.Date.ToShortDateString() + ".\n\n"
         });
     }
 }