Esempio n. 1
0
        public static void CreateCustomer(Abstract.model.Person person)
        {
            person.PersonId = 1;
            var persons = GetCurrencyExchangerContext().Person.ToArray();

            foreach (var p in persons)
            {
                if (p.PersonId == person.PersonId)
                {
                    person.PersonId = p.PersonId + 1;
                }
            }
            GetCurrencyExchangerContext().Person.Add(person);
            GetCurrencyExchangerContext().SaveChanges();
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public override void DoCreate(Dictionary <string, object> parameters)
        {
            var person1 = new Abstract.model.Person();
            var person  = person1;

            foreach (var row in parameters)
            {
                if (row.Key.Equals("FirstName"))
                {
                    person.FirstName = row.Value.ToString();
                }

                if (row.Key.Equals("LastName"))
                {
                    person.FirstName = row.Value.ToString();
                }

                if (row.Key.Equals("BirthDate"))
                {
                    person.BirthDate = (DateTime?)row.Value;
                }

                if (row.Key.Equals("PassportSeries"))
                {
                    person.PassportSeries = row.Value.ToString();
                }

                if (row.Key.Equals("PassportId"))
                {
                    person.PassportId = row.Value.ToString();
                }
            }

            GetCurrencyExchangerContext().Person.Add(person);
            GetCurrencyExchangerContext().SaveChanges();
        }