Example #1
0
 /// <summary>
 /// Конвертация в компанию клиента
 /// </summary>
 /// <param name="client">Компания клиент БД </param>
 /// <returns>Компания клиент </returns>
 public static CompanyCustomer Convert(CompanyCustomerEnt company, bool logic = true)
 {
     if (company != null)
     {
         List <ContactInformation> list             = null;
         List <SalesInvoice>       salesInvoiceEnts = null;
         if (logic == true)
         {
             list = new List <ContactInformation>();
             foreach (var item in company.ContactInformation)
             {
                 list.Add(Convert(item));
             }
             salesInvoiceEnts = new List <SalesInvoice>();
             foreach (var item in company.SalesInvoices)
             {
                 salesInvoiceEnts.Add(Convert(item, false));
             }
         }
         CompanyCustomer companyEnt = new CompanyCustomer
         {
             Description        = company.Description,
             Name               = company.Name,
             Id                 = company.Id,
             SalesInvoices      = salesInvoiceEnts,
             ContactInformation = list
         };
         return(companyEnt);
     }
     else
     {
         return(null);
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            Bank            myBank = new Bank("Access bank");
            List <IAccount> accts  = CreateDummyAccounts();

            foreach (IAccount acct in accts)
            {
                myBank.AddNewAccount(acct, isCashier: false);
            }
            Console.WriteLine($"\t\t Hi, Welcome To { myBank.Name}");
            Console.WriteLine("\t\t##########################################");
            Console.WriteLine($"\n\t\tAccounts in bank:");
            List <string> keyList = new List <string>(myBank.bankAccountList);

            foreach (string acct in keyList)
            {
                Console.WriteLine(myBank.bankDatabase[acct].GetAccountInfo());
                Console.WriteLine("-----------------------------------------------------------------------");
            }
            Cashier.StartWork(myBank);
            ICustomer cust11 = new PersonCustomer("Mr", "Emma", "Okon", "04/04/1995", Gender.Female, "10 dhckbjkhk");
            ICustomer cust1  = new PersonCustomer("Prof Mrs", "Joy", "Okon", "04/04/1995", Gender.Male, "10 djkhk");
            ICustomer cust2  = new PersonCustomer("Engr ", "David", "Ubong", "04/04/1995", Gender.Female, "12 djkhk");
            ICustomer cust3  = new CompanyCustomer("Real Estate", "Tenece", "10/10/1990", "12347", "Enugu", CompanyStatus.Public);
            ICustomer cust4  = new CompanyCustomer("Tech", "Genesys", "10/10/2010", "12347", "Enugu", CompanyStatus.Private);

            //Dictionary<ICustomer, int> newDict = new Dictionary<ICustomer, int>(5);
            //newDict.Add(cust11,1);
            //newDict.Add(cust1,2);
            //newDict.Add(cust2,3);
            //newDict.Add(cust3,4);
            //newDict.Add(cust4,5);
        }
        static void Main()
        {
            CompanyCustomer companyCust = new CompanyCustomer("Gotinata firma");
            IndividualCustemer individualCust = new IndividualCustemer("Pesho");

            MorgageAcount individualMorg = new MorgageAcount(individualCust, 500, 5);
            DepositAcount individualDep = new DepositAcount(individualCust, 1200, 12);
            LoanAcount individualLoan = new LoanAcount(individualCust, 800, 5);

            MorgageAcount companyMorg = new MorgageAcount(companyCust, 3500, 18);
            DepositAcount companyDep = new DepositAcount(companyCust, 960, 7);
            LoanAcount companyLoan = new LoanAcount(companyCust, 1400, 2);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Individuals Accounts:");
            Console.ResetColor();

            Console.WriteLine("{0}'s accoint:\nCalkkulated deposit intrest:{1}\nDeposit: {2}",individualCust.Name,individualDep.CalcuklateIntrest(10),individualDep.Balance);
            Console.WriteLine("Calkkulated morgage intrest: {0}\nMorgage: {1}",individualMorg.CalcuklateIntrest(7), individualMorg.Balance);
            Console.WriteLine("Calkkulated loan intrest: {0}\nLoan: {1}",individualLoan.CalcuklateIntrest(9),individualLoan.Balance);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Companies Accounts:");
            Console.ResetColor();
            Console.WriteLine("{0}'s accoint:\nCalkkulated deposit intrest:{1}\nDeposit: {2}", companyCust.Name, companyDep.CalcuklateIntrest(10), companyDep.Balance);
            Console.WriteLine("Calkkulated morgage intrest: {0}\nMorgage: {1}", companyMorg.CalcuklateIntrest(7), companyMorg.Balance);
            Console.WriteLine("Calkkulated loan intrest: {0}\nLoan: {1}", companyLoan.CalcuklateIntrest(9), companyLoan.Balance);

            Bank someBank = new Bank();
            someBank.AddAcount(individualMorg);
            someBank.AddAcount(individualDep);
            someBank.AddAcount(individualLoan);
            someBank.AddAcount(companyMorg);
            someBank.AddAcount(companyDep);
            someBank.AddAcount(companyLoan);
        }
Example #4
0
        public async Task <IActionResult> EditCompanyCustomer(CompanyCustomer companyCustomer)
        {
            if (ModelState.IsValid)
            {
                string endPointPutCompanyCustomer = $"CompanyCustomer?id={companyCustomer.CompanyCustomerID}";
                string baseUrl = configuration.GetValue <string>("Urls:CustomerBaseUrl");

                int statusCode = await CompanyCustomerHandler.PutHttp(companyCustomer, baseUrl, endPointPutCompanyCustomer);

                if (statusCode == StatusCodes.Status204NoContent)
                {
                    return(RedirectToAction("GetCompanyCustomers"));
                }

                string endPointGetCompanyCustomer = $"CompanyCustomer/{companyCustomer.CompanyCustomerID}";
                var    updatedCustomer            = await CompanyCustomerHandler.CallHttpGetByID(baseUrl, endPointGetCompanyCustomer);

                CompanyCustomerEditViewModel companyCustomerEditViewModel = new();
                companyCustomerEditViewModel.CompanyCustomer = updatedCustomer;
                var ErrorMessageForConflict = "Nogen har sandsynligvis lavet ændringer i mellemtiden. Nyeste version er nu hentet.";

                companyCustomerEditViewModel.ErrorMessage = $"Fejlede med statuskode {statusCode}. {(statusCode == 409 ? ErrorMessageForConflict : "")}";
                ModelState.Clear();

                return(View("EditCompanyCustomer", companyCustomerEditViewModel));
            }
            return(View());
        }
        public ActionResult Save(Customer customer)
        {
            var companyId = customer.Id;

            _context.AddressInfo.Add(customer.AddressInfo);
            _context.SaveChanges();

            var aInfo = _context.AddressInfo.SingleOrDefault(c => c.Email == customer.AddressInfo.Email && c.Address == customer.AddressInfo.Address && c.Phone == customer.AddressInfo.Phone);

            customer.AddressInfoId = aInfo.Id;

            _context.Customer.Add(customer);
            _context.SaveChanges();

            var cInfo = _context.Customer.SingleOrDefault(c => c.AddressInfoId == aInfo.Id);

            var combineInfo = new CompanyCustomer
            {
                CompanyId  = companyId,
                CustomerId = cInfo.Id
            };

            _context.CompanyCustomer.Add(combineInfo);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Customer"));
        }
        static void Main()
        {
            IndividualCustomer pesho = new IndividualCustomer("Petar", "Petrov", "+359894011468",
                "Sofia, bul.Tcarigradsko shose 15");
            IndividualCustomer mimi = new IndividualCustomer("Maria", "Nikolova", "+359894011468",
                "Sofia, bul.Vitoshka 35");
            CompanyCustomer softUni = new CompanyCustomer("Software University Ltd.", "+359894011468",
                "Sofia, bul.NqkoiSi 9");
            CompanyCustomer hardUni = new CompanyCustomer("Hardware University Ltd.", "+359894011468",
                "Sofia, bul.EdiKoiSi 6");

            Deposit d1 = new Deposit(pesho, 1000, 0.1m);
            Deposit d2 = new Deposit(softUni, 50000, 0.15m);
            Loan l1 = new Loan(mimi, 5500, 0.2m);
            Loan l2 = new Loan(hardUni, 90000, 0.18m);
            Mortgage m1 = new Mortgage(pesho, 60000, 0.12m);
            Mortgage m2 = new Mortgage(hardUni, 160000, 0.1m);

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Deposits and withdraws:");
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Write("Old balance " + d1.Balance + ", new balance: ");
            d1.DepositMoney(500);
            Console.WriteLine(d1.Balance);
            Console.Write("Old balance " + d2.Balance + ", new balance: ");
            d2.WithdrawMoney(12500.50m);
            Console.WriteLine(d2.Balance);
            Console.Write("Old balance " + l1.Balance + ", new balance: ");
            l1.DepositMoney(500);
            Console.WriteLine(l1.Balance);
            Console.Write("Old balance " + m1.Balance + ", new balance: ");
            m1.DepositMoney(10000.90m);
            Console.WriteLine(m1.Balance);
            Console.WriteLine();

            IList<Account> accounts = new List<Account>
            {
                d1, d2, l1, l2, m1, m2
            };

            Bank bank = new Bank(accounts);

            Console.WriteLine("The bank:");
            Console.WriteLine(bank);

            // I have changed the formula for calculating the interest, because
            // the given formula returns interest plus amount which is not correct
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Calculated interests:");
            Console.ForegroundColor = ConsoleColor.Black;

            Console.WriteLine("Interest = {0:F2} BGN", d1.CalculateInteres(6));
            Console.WriteLine("Interest = {0:F2} BGN", l1.CalculateInteres(3));
            Console.WriteLine("Interest = {0:F2} BGN", l2.CalculateInteres(6));
            Console.WriteLine("Interest = {0:F2} BGN", d2.CalculateInteres(6));
            Console.WriteLine("Interest = {0:F2} BGN", m1.CalculateInteres(6));
            Console.WriteLine("Interest = {0:F2} BGN", m1.CalculateInteres(13));
            Console.WriteLine("Interest = {0:F2} BGN", m2.CalculateInteres(6));
        }
Example #7
0
        public CompanyCustomerView(CompanyCustomer model)
        {
            Mapper.CreateMap <CompanyCustomer, CompanyCustomerView>();
            Mapper.Map <CompanyCustomer, CompanyCustomerView>(model, this);

            this.created = model.created.ToString().Replace('T', ' ');
            this.updated = model.updated.ToString().Replace('T', ' ');
        }
        public CompanyCustomerView(CompanyCustomer model)
        {
            Mapper.CreateMap<CompanyCustomer, CompanyCustomerView>();
            Mapper.Map<CompanyCustomer, CompanyCustomerView>(model, this);

            this.created = model.created.ToString().Replace('T', ' ');
            this.updated = model.updated.ToString().Replace('T', ' ');
        }
        public CompanyCustomer getModel()
        {
            var model = new CompanyCustomer();

            Mapper.CreateMap<CompanyCustomerView, CompanyCustomer>();
            Mapper.Map<CompanyCustomerView, CompanyCustomer>(this, model);

            return model;
        }
 public CreateCompanyCustomerCommand(
     CompanyCustomer companyCustomer,
     CompanyCustomerCatalog companyCustomerCatalog,
     CompanyCustomerItemViewModel ivm)
 {
     _companyCustomer        = companyCustomer;
     _companyCustomerCatalog = companyCustomerCatalog;
     _ivm = ivm;
 }
Example #11
0
        public CompanyCustomer getModel()
        {
            var model = new CompanyCustomer();

            Mapper.CreateMap <CompanyCustomerView, CompanyCustomer>();
            Mapper.Map <CompanyCustomerView, CompanyCustomer>(this, model);

            return(model);
        }
Example #12
0
        public ActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.Customers.Add(customer);
                        var response = DBHelper.SaveChanges(db);


                        if (!response.Succeeded)
                        {
                            ModelState.AddModelError(string.Empty, response.Message);
                            transaction.Rollback();
                            ViewBag.CityId = new SelectList(CombosHelper.GetCities(customer.DepartmentId), "CityId", "Name", customer.CityId);

                            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartment(), "DepartmentId", "Name", customer.DepartmentId);

                            return(View(customer));
                        }

                        UserHelper.CreateUserASP(customer.UserName, "Customer");

                        var user = db.Users.FirstOrDefault(u => u.UserName == User.Identity.Name);

                        var companyCustomer = new CompanyCustomer
                        {
                            CompanyId  = user.CompanyId,
                            CustomerId = customer.CustomerId
                        };


                        db.CompanyCustomers.Add(companyCustomer);
                        db.SaveChanges();

                        transaction.Commit();

                        return(RedirectToAction("Index"));
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }
                }
            }

            ViewBag.CityId = new SelectList(CombosHelper.GetCities(customer.DepartmentId), "CityId", "Name", customer.CityId);

            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartment(), "DepartmentId", "Name", customer.DepartmentId);


            return(View(customer));
        }
Example #13
0
        // GET: CompanyCustomers/Edit/5
        public ActionResult Edit(int id)
        {
            CompanyCustomer companyCustomer = CompanyCustomerMethods.GetItem(id);

            if (companyCustomer == null)
            {
                return(HttpNotFound());
            }
            return(View(companyCustomer));
        }
Example #14
0
        public async Task <CompanyCustomer> Create(CompanyCustomer companyCustomer)
        {
            using (var context = _contextFactory.CreateDbContext())
            {
                context.CompanyCustomers.Add(companyCustomer);
                await context.SaveChangesAsync();

                return(companyCustomer);
            }
        }
Example #15
0
 public ActionResult Create(Customer customer)
 {
     if (ModelState.IsValid)
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Customers.Add(customer);
                 var response = DBHelper.SaveChanges(db);
                 if (!response.Succeeded)
                 {
                     ModelState.AddModelError(string.Empty, response.Message);
                     transaction.Rollback();
                     ViewBag.CityId       = new SelectList(CombosHelper.GetCities(customer.DepartmentId), "CityId", "Name", customer.CityId);
                     ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", customer.DepartmentId);
                     return(View(customer));
                 }
                 if (customer.PhotoFile != null)
                 {
                     var folder    = "~/Content/Customers";
                     var file      = string.Format("{0}.jpg", customer.CustomerId);
                     var response2 = FilesHelper.UploadPhoto(customer.PhotoFile, folder, file);
                     if (response2)
                     {
                         customer.Photo           = string.Format("{0}/{1}", folder, file);
                         db.Entry(customer).State = EntityState.Modified;
                         db.SaveChanges();
                     }
                 }
                 UsersHelper.CreateUserASP(customer.UserName, "Customer");
                 var user            = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();
                 var CompanyCustomer = new CompanyCustomer
                 {
                     CompanyId  = user.CompanyId,
                     CustomerId = customer.CustomerId,
                 };
                 db.CompanyCustomers.Add(CompanyCustomer);
                 db.SaveChanges();
                 transaction.Commit();
                 return(RedirectToAction("Index"));
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 ModelState.AddModelError(string.Empty, ex.Message);
             }
         }
     }
     ViewBag.CityId       = new SelectList(CombosHelper.GetCities(customer.DepartmentId), "CityId", "Name", customer.CityId);
     ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", customer.DepartmentId);
     return(View(customer));
 }
Example #16
0
        public async Task <IActionResult> CreateCompanyCustomer([Bind("CompanyName, BranchManager, CVR, LandlinePhoneNumber, MobilePhoneNumber, Addresse, PostalCode, City, Email, CompanyType, PrimaryDelpinDepartment")] CompanyCustomer companyCustomer)
        {
            if (ModelState.IsValid)
            {
                string endPointGetCompanyCustomer = "CompanyCustomer";
                string baseUrl = configuration.GetValue <string>("Urls:CustomerBaseUrl");

                await CompanyCustomerHandler.PostHttp(companyCustomer, baseUrl, endPointGetCompanyCustomer);

                return(RedirectToAction("GetCompanyCustomers"));
            }
            return(View());
        }
Example #17
0
        public ActionResult Create([Bind(Include = "CustomerId,CompanyId,UserName,FirstName,LastName,Phone,Address,StateId,CityId")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.Customers.Add(customer);
                        var response = DBHelper.SaveChanges(db);
                        if (!response.Succeeded)
                        {
                            ModelState.AddModelError(string.Empty, response.Message);
                            transaction.Rollback();
                            ViewBag.CityId  = new SelectList(db.Cities, "CityId", "Name", customer.CityId);
                            ViewBag.StateId = new SelectList(db.States, "StateId", "Name", customer.StateId);
                            return(View(customer));
                        }

                        UsersHelper.CreateUserASP(customer.UserName, "Customer");
                        var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();

                        var companycustomer = new CompanyCustomer {
                            CompanyId  = user.CompanyId,
                            CustomerId = customer.CustomerId
                        };

                        db.CompanyCustomers.Add(companycustomer);
                        db.SaveChanges();

                        transaction.Commit();
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                    }
                }



                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CityId  = new SelectList(db.Cities, "CityId", "Name", customer.CityId);
            ViewBag.StateId = new SelectList(db.States, "StateId", "Name", customer.StateId);

            return(View(customer));
        }
Example #18
0
    static void Main()
    {
        //Making customers - individual and company
            CompanyCustomer ood = new CompanyCustomer("OOD");
            IndividualCustomer samuel = new IndividualCustomer("Samuel L. Jackson");

            //Testing some stuff
            DepositAccount samuelDepositAccount = new DepositAccount(samuel , 10000m, 100m);
            DepositAccount oodDepositAccount = new DepositAccount(ood, 10000m, 100m);
            Console.WriteLine("{1} has {0} money.", samuelDepositAccount.Balance, samuelDepositAccount.Customer.Name);
            samuelDepositAccount.WithDrawMoney(500m);
            Console.WriteLine("After we with draw some money he has {0} money." , samuelDepositAccount.Balance);
            samuelDepositAccount.AddDeposit(200m);
            Console.WriteLine("After we deposit some money he has " + samuelDepositAccount.Balance);

            Console.WriteLine();
            Console.WriteLine();

            //Testing the deposit account
            Console.WriteLine("Testing the deposit account:");
            Console.WriteLine("----------------------------");
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} "
            , samuelDepositAccount.GetType(), samuelDepositAccount.Customer.GetType(), samuelDepositAccount.Customer.Name, samuelDepositAccount.InterestAmountForPeriod(6));
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} "
                , oodDepositAccount.GetType(), oodDepositAccount.Customer.GetType(), oodDepositAccount.Customer.Name, oodDepositAccount.InterestAmountForPeriod(6));
            Console.WriteLine();
            Console.WriteLine();

            //Testing the loan account
            Console.WriteLine("Testing the loan account:");
            Console.WriteLine("----------------------------");
            LoanAccount samuelLoanAccount = new LoanAccount(samuel, 10000m, 100m);
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} "
                , samuelLoanAccount.GetType(), samuelLoanAccount.Customer.GetType(), samuelLoanAccount.Customer.Name, samuelLoanAccount.InterestAmountForPeriod(6));

            LoanAccount oodLoanAccount = new LoanAccount(ood, 10000m, 100m);
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 6 mounths: {3} "
                , oodLoanAccount.GetType(), oodLoanAccount.Customer.GetType(), oodLoanAccount.Customer.Name, oodLoanAccount.InterestAmountForPeriod(6));
            Console.WriteLine();
            Console.WriteLine();

            //Testing the mortage account
            Console.WriteLine("Testing the mortage account:");
            Console.WriteLine("----------------------------");
            MortageAccount samuelMortageAccount = new MortageAccount(samuel, 10000m, 100m);
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 24 mounths: {3} "
                , samuelMortageAccount.GetType(), samuelMortageAccount.Customer.GetType(), samuelMortageAccount.Customer.Name, samuelMortageAccount.InterestAmountForPeriod(24));
            MortageAccount oodMortageAccount = new MortageAccount(ood, 10000m, 100m);
            Console.WriteLine("The {0} of {2} who is a {1} has interest amount for next 24 mounths: {3} "
                , oodMortageAccount.GetType(), oodMortageAccount.Customer.GetType(), oodMortageAccount.Customer.Name, oodMortageAccount.InterestAmountForPeriod(24));
    }
Example #19
0
        static void Main()
        {
            IndividualCustomer cst        = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221");
            DepositAccount     depositAcc = new DepositAccount(cst, 1000, 0.5m);

            Console.WriteLine(depositAcc);
            //  depositAcc.WithDraw(20);
            Console.WriteLine("New balance:{0}", depositAcc.Balance);
            // depositAcc.Deposit(100000);
            Console.WriteLine("New balance:{0}", depositAcc.Balance);
            Console.WriteLine("{0:0.0}", depositAcc.CalculateInterestAmount(12));
            //------------------------------------------------------------------------------
            Console.WriteLine();

            IndividualCustomer cst1    = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221");
            LoanAccount        loanAcc = new LoanAccount(cst1, 1000, 1m);

            Console.WriteLine(loanAcc);
            loanAcc.Deposit(50);
            //  depositAcc.WithDraw(20);
            // depositAcc.Deposit(100000);
            Console.WriteLine("New balance:{0}", loanAcc.Balance);
            Console.WriteLine("{0:0.0}", loanAcc.CalculateInterestAmount(5));
            //------------------------------------------------------------------------------
            Console.WriteLine();

            IndividualCustomer cst2       = new IndividualCustomer("Ivo", "Pavlev", "Andonov", "083472221");
            MortgageAccount    mortageAcc = new MortgageAccount(cst2, 1000, 1m);

            Console.WriteLine(mortageAcc);
            mortageAcc.Deposit(50);
            //  depositAcc.WithDraw(20);
            // depositAcc.Deposit(100000);
            Console.WriteLine("New balance:{0}", mortageAcc.Balance);
            Console.WriteLine("{0:0.0}", mortageAcc.CalculateInterestAmount(7));

            //------------------------------------------------------------------------------
            Console.WriteLine();
            CompanyCustomer cst3        = new CompanyCustomer("Masson", "083472221");
            MortgageAccount mortageAcc1 = new MortgageAccount(cst3, 10000, 1m);

            Console.WriteLine(mortageAcc1);
            mortageAcc1.Deposit(50);
            //  depositAcc.WithDraw(20);
            // depositAcc.Deposit(100000);
            Console.WriteLine("New balance:{0}", mortageAcc1.Balance);
            Console.WriteLine("{0:0.0}", mortageAcc1.CalculateInterestAmount(24));
        }
Example #20
0
        static void Main()
        {
            IndividualCustomer kuncho = new IndividualCustomer("Kuncho");
            CompanyCustomer    mtel   = new CompanyCustomer("Mtel");

            LoanAccount    loanAcc    = new LoanAccount(kuncho, 250, 25);
            DepositAccount depositAcc = new DepositAccount(mtel, 10000, 20);

            loanAcc.DepositAmmount(100);
            Console.WriteLine(loanAcc.Balance);

            depositAcc.WithdrawAmount(5000);
            Console.WriteLine(depositAcc.Balance);

            Console.WriteLine(depositAcc.CalculateInterestAmount(12));
        }
Example #21
0
        static void Main()
        {
            IndividualCustomer pesho             = new IndividualCustomer("Pesho");
            CompanyCustomer    tsarvulInvestment = new CompanyCustomer("Tsarvul Investment");
            //SixMonthDeposit depositPesho = new SixMonthDeposit(pesho, 1500m, 3.2m, DepositType.SixMonth, Accounts.AccountType.Personal);
            //decimal interestDeposit = depositPesho.CalculateInterest(5);
            //Console.WriteLine(interestDeposit);
            //SixMonthLoan loanPesho = new SixMonthLoan(pesho, 1500m, 3.2m, LoanType.SixMonth, AccountType.Personal);
            //decimal interestLoan = loanPesho.CalculateInterest(4);
            //Console.WriteLine(interestLoan);
            ThirtyYearMortgage mortgage = new ThirtyYearMortgage
                                              (tsarvulInvestment, 10000m, 3.2m, AccountType.Company, MortgageType.ThirtyYear);
            decimal interest = mortgage.CalculateInterest(12);

            Console.WriteLine(interest);
        }
Example #22
0
 public static void Main()
 {
     CompanyCustomer company = new CompanyCustomer("Company");
     IndividualCustomer pesho = new IndividualCustomer("Pesho");
     IndividualCustomer ivan = new IndividualCustomer("Ivan");
     IAccount peshoLoan = new Loan(pesho, 2500, 6.5m);
     IAccount companyMortgage = new Mortgage(company, 15000, 8.8m);
     IAccount ivanDeposit = new Deposit(ivan, 8000, 3.5m);
     List<IAccount> myAccounts = new List<IAccount>{peshoLoan, companyMortgage, ivanDeposit};
     Bank bigBank = new Bank(myAccounts);
     Console.WriteLine();
     bigBank.ListAllAccounts();
     Console.WriteLine();
     bigBank.InterestForAll(12);
     Console.WriteLine("\nPesho's interest for 30 months: {0}", peshoLoan.CalculateInterest(30));
     Console.WriteLine();
 }
Example #23
0
        public async Task <ActionResult> PutCompanyCustomer(int id, [FromBody] CompanyCustomer companyCustomer)
        {
            //Husk at chekke om Model is valid
            if (!ModelState.IsValid)
            {
                return(StatusCode(800));
            }

            if (id != companyCustomer.CompanyCustomerID)
            {
                return(BadRequest());
            }

            var statuscode = await _companyCustomerRepository.Update(companyCustomer);

            return(StatusCode(statuscode));
        }
Example #24
0
 public ActionResult Edit(CompanyCustomer company)
 {
     try
     {
         if (ModelState.IsValid)
         {
             CompanyCustomerMethods.ChangeItem(company);
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException)
     {
         //Log the error (add a variable name after DataException)
         ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
     }
     return(View(company));
 }
Example #25
0
    public static void Main()
    {
        Customer kircho = new IndividualCustomer("Kircho Kirev");
        Customer bulPc  = new CompanyCustomer("BulPC");

        List <Account> accounts = new List <Account>
        {
            new DepositAccount(kircho, 22500m, 7.2m),
            new LoanAccount(bulPc, 50000m, 12.3m),
            new MortgageAccount(kircho, 100250m, 9.1m)
        };

        foreach (Account account in accounts)
        {
            Console.WriteLine(account.GetType() + " Interest:{0:F2}", account.CalculateInterest(15));
        }
    }
Example #26
0
        private static void CreateNewAccount()
        {
            Console.Clear();
            string customerType;

            IndividualCustomer inCustomer;
            CompanyCustomer    compCustomer;


            do
            {
                Console.Write("Enter Customer Type(Individual/Company): ");
                customerType = Console.ReadLine();
            }while (!String.Equals(customerType, "Individual") && !String.Equals(customerType, "Company"));
            if (String.Equals(customerType, "Individual"))
            {
                Console.Write("Enter First Name: ");
                var firstName = Console.ReadLine();
                Console.Write("Enter Last Name: ");
                var lastName = Console.ReadLine();

                int customerId = (_customers.OrderByDescending(c => c.CustomerId).FirstOrDefault().CustomerId) + 1;
                inCustomer = new IndividualCustomer
                {
                    CustomerId = customerId, FirstName = firstName, LastName = lastName
                };

                _customers.Add(inCustomer);
                CreateAccount(inCustomer);
            }
            else
            {
                Console.Write("Enter Company Name");
                var companyName = Console.ReadLine();
                int customerId  = (_customers.OrderByDescending(c => c.CustomerId).FirstOrDefault().CustomerId) + 1;

                compCustomer = new CompanyCustomer {
                    CustomerId = customerId, CompanyName = companyName
                };
                _customers.Add(compCustomer);
                CreateAccount(compCustomer);
            }


            ShowListOfAccounts();
        }
Example #27
0
        public ActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {//cuando se manipula mas de dos tablas se usan transaciones
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.Customers.Add(customer);
                        var response = DBHelper.SaveChanges(db);//TODO:Validate when the custoimer email change, para pendientes para no perderse del dessarrollo
                        if (!response.Succeeded)
                        {
                            ModelState.AddModelError(string.Empty, response.Message);
                            transaction.Rollback();
                            ViewBag.CityId       = new SelectList(CombosHelper.GetCities(0), "CityId", "Name");
                            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name");
                            return(View(customer));
                        }

                        UsersHelper.CreateUserASP(customer.UserName, "Customer");
                        var user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault();

                        var companyCustomer = new CompanyCustomer
                        {
                            CompanyId  = user.CompanyId,
                            CustomerId = customer.CustomerId
                        };
                        db.CompanyCustomers.Add(companyCustomer);
                        db.SaveChanges();

                        transaction.Commit();
                        return(RedirectToAction("Index"));
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        ModelState.AddModelError(string.Empty, ex.Message);
                    }
                }
            }

            ViewBag.CityId       = new SelectList(CombosHelper.GetCities(0), "CityId", "Name");
            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name");
            return(View(customer));
        }
Example #28
0
        public async Task <int> Update(CompanyCustomer companyCustomer)
        {
            using (var context = _contextFactory.CreateDbContext())
            {
                context.Entry(companyCustomer).State = EntityState.Modified;

                try
                {
                    await context.SaveChangesAsync();

                    return(204);
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(409);
                }
            }
        }
        static void Main(string[] args)
        {
            Customer indiv1 = new IndividualCustomer("Ivan Todorov");
            Customer indiv2 = new IndividualCustomer("Georgi Georgiev");
            Customer comp = new CompanyCustomer("Toplivo AD");

            Account[] someAccounts = new Account[4]
            {
                new DepositAccount(indiv1,1020,0.4m),
                new LoanAccount(indiv2,300,3),
                new MortgageAccount(indiv2,20000,2),
                new DepositAccount(comp,4000,4)
            };

            foreach (var item in someAccounts)
            {
                Console.WriteLine(item.CalculateInterest(5));
            }
        }
Example #30
0
        static void Main()
        {
            // Creating some customers
            IndividualCustomer customer1 = new IndividualCustomer("Ivan", "Ivanov", 11223344);
            CompanyCustomer    customer2 = new CompanyCustomer("Company 0101", 99887766);
            CompanyCustomer    customer3 = new CompanyCustomer("Company 123", 22334455);

            // Creating different kinds of accounts
            DepositAccount account1 = new DepositAccount(customer1, 20000m, 10m);
            LoanAccount    account2 = new LoanAccount(customer2, 5000m, 6.8m);
            DepositAccount account3 = new DepositAccount(customer3, 3400m, 16.4m);

            // Creating the bank with the accounts
            List <Account> accounts = new List <Account>()
            {
                account1, account2, account3
            };
            Bank bank = new Bank("G Bank", accounts);

            // Adding account to the bank
            IndividualCustomer customer4 = new IndividualCustomer("Georgi", "Georgiev", 66778800);
            MortgageAccount    account4  = new MortgageAccount(customer4, 2000m, 4.1m);

            bank.AddAccount(account4);

            // Printing all the information about the bank and its clients on the console
            Console.WriteLine(bank);

            // Depositting and withdrawing money to account1
            account1.DepositMoney(100m);
            account1.WithdrawMoney(2000m);
            Console.WriteLine("After depositting and withdrawing money from {0} {1}'s account the balance is: {2:C2}",
                              customer1.Fname, customer1.Lname, account1.Balance);
            Console.WriteLine();

            // Calculating the interest amount for all the accounts in the bank
            Console.WriteLine("Deposit account interest amount after 5 months: {0:C2}", account1.CalculateInterestAmount(5));
            account3.WithdrawMoney(2600m);
            Console.WriteLine("Deposit account interest amount after 2 months: {0:C2}", account3.CalculateInterestAmount(2));
            Console.WriteLine("Loan account interest amount after 10 months: {0:C2}", account2.CalculateInterestAmount(10));
            Console.WriteLine("Mortgage account interest amount after 1 year: {0:C2}", account4.CalculateInterestAmount(12));
        }
Example #31
0
        private static void InitializeAccountsAndCustomers()
        {
            var cust1 = new IndividualCustomer
            {
                CustomerId = 1,
                FirstName  = "Tyrion",
                LastName   = "Lannister"
            };

            _customers.Add(cust1);
            var cust2 = new IndividualCustomer
            {
                CustomerId = 2,
                FirstName  = "Jon",
                LastName   = "Snow"
            };

            _customers.Add(cust2);
            var cust3 = new CompanyCustomer
            {
                CustomerId  = 3,
                CompanyName = "Faceless Men"
            };

            _customers.Add(cust3);

            var acc1 = new DepositAccount(cust1, 20000, "ABC00001");

            _accounts.Add(acc1);
            var acc2 = new DepositAccount(cust2, 25000, "ABC00002");

            _accounts.Add(acc2);
            var acc3 = new MortgageAccount(cust2, 35000, "ABC00003");

            _accounts.Add(acc3);

            var acc4 = new LoanAccount(cust3, 500000, "ABC00004");

            _accounts.Add(acc4);
        }
Example #32
0
        static List <IAccount> CreateDummyAccounts()
        {
            ICustomer cust11 = new PersonCustomer("Mr", "Emma", "Okon", "04/04/1995", Gender.Female, "10 dhckbjkhk");
            ICustomer cust1  = new PersonCustomer("Prof Mrs", "Joy", "Okon", "04/04/1995", Gender.Male, "10 djkhk");
            ICustomer cust2  = new PersonCustomer("Engr ", "David", "Ubong", "04/04/1995", Gender.Female, "12 djkhk");
            ICustomer cust3  = new CompanyCustomer("Real Estate", "Tenece", "10/10/1990", "12347", "Enugu", CompanyStatus.Public);
            ICustomer cust4  = new CompanyCustomer("Tech", "Genesys", "10/10/2010", "12347", "Enugu", CompanyStatus.Private);


            DepositAccount new1 = new DepositAccount(cust1, DepositAccountType.Student, startBalance: 1000);
            DepositAccount new2 = new DepositAccount(cust2, DepositAccountType.Savings, startBalance: 15000);
            DepositAccount new3 = new DepositAccount(cust3, DepositAccountType.Current, startBalance: 100000);
            LoanAccount    new4 = new LoanAccount(cust4, 506400, 20);
            DepositAccount new9 = new DepositAccount(cust11, DepositAccountType.Savings, startBalance: 15000);

            List <IAccount> bankaccts = new List <IAccount>()
            {
                new1, new2, new3, new4, new9
            };

            return(bankaccts);
        }
        public static void Main()
        {
            // These examples and most of the solutions for the classes are taken from the forum
            // I actually "did read" all of the code and changed a couple of things

            ICustomer pesho = new IndividualCustomer("Petar Petrov");
            ICustomer agroCompany = new CompanyCustomer("Agro Company Ltd.");

            IAccount mortgageAccInd = new MortgageAccount(pesho, 1024m, 5.3m);
            IAccount mortgageAccComp = new MortgageAccount(agroCompany, 1024m, 5.3m);
            IAccount loanAccInd = new LoanAccount(pesho, 1024m, 5.3m);
            IAccount loanAccComp = new LoanAccount(agroCompany, 1024m, 5.3m);
            IAccount depositAccIndBig = new DepositAccount(pesho, 1024m, 5.3m);
            IAccount depositAccIndSmall = new DepositAccount(pesho, 999m, 5.3m);
            IAccount depositAccComp = new DepositAccount(agroCompany, 11024m, 4.3m);

            List<IAccount> accounts = new List<IAccount>()
            {
                mortgageAccInd,
                mortgageAccComp,
                loanAccInd,
                loanAccComp,
                depositAccIndBig,
                depositAccIndSmall,
                depositAccComp
            };

            foreach (var acc in accounts)
            {
                Console.WriteLine("{5} {0}: {1:N2}, {2:N2}, {3:N2}, {4:N2}",
                    acc.GetType().Name,
                    acc.CalculateRate(2),
                    acc.CalculateRate(3),
                    acc.CalculateRate(10),
                    acc.CalculateRate(13),
                    acc.Customer.GetType().Name);
            }
        }
Example #34
0
 /// <summary>
 /// Конвертация в накладную продаж
 /// </summary>
 /// <param name="client">Накладная продаж БД</param>
 /// <returns>Накладная продаж</returns>
 public static SalesInvoice Convert(SalesInvoiceEnt sales, bool logic = true)
 {
     if (sales != null)
     {
         CompanyCustomer companyСustomer = null;
         ClientUser      clientUser      = null;
         Employee        employee        = null;
         if (logic == true)
         {
             companyСustomer = Convert(sales.CompanyСustomer, false);
             clientUser      = Convert(sales.ClientUser, false);
             employee        = Convert(sales.Employee, false);
         }
         List <Product> products = new List <Product>();
         foreach (var item in sales.ProductEnts)
         {
             products.Add(Convert(item));
         }
         SalesInvoice ent = new SalesInvoice
         {
             ClientUser        = clientUser,
             Date              = sales.Date,
             ClientUserId      = sales.ClientUserId,
             CompanyCustomerId = sales.CompanyCustomerId,
             EmployeeId        = sales.EmployeeId,
             Description       = sales.Description,
             CompanyСustomer   = companyСustomer,
             Employee          = employee,
             Id        = sales.Id,
             Archiving = sales.Archiving,
             Product   = products,
             Status    = sales.Status
         };
         return(ent);
     }
     return(null);
 }
Example #35
0
 /// <summary>
 /// Конвертация в компанию клиента БД
 /// </summary>
 /// <param name="client">Компания клиент  </param>
 /// <returns>Компания клиент БД</returns>
 public static CompanyCustomerEnt Convert(CompanyCustomer company)
 {
     if (company != null)
     {
         var x = Unit.CompanyСustomerRepository.GetItem(company.Id);
         if (x != null)
         {
             return(x);
         }
         else
         {
             List <ContactInformationEnt> list = new List <ContactInformationEnt>();
             foreach (var item in company.ContactInformation)
             {
                 list.Add(Convert(item));
             }
             List <SalesInvoiceEnt> salesInvoiceEnts = new List <SalesInvoiceEnt>();
             foreach (var item in company.SalesInvoices)
             {
                 salesInvoiceEnts.Add(Convert(item));
             }
             CompanyCustomerEnt companyEnt = new CompanyCustomerEnt
             {
                 Description        = company.Description,
                 Name               = company.Name,
                 Id                 = company.Id,
                 SalesInvoices      = salesInvoiceEnts,
                 ContactInformation = list
             };
             return(companyEnt);
         }
     }
     else
     {
         return(null);
     }
 }
Example #36
0
        static void Main()
        {
            IndividualCustomer Bobo  = new IndividualCustomer("Bobo");
            CompanyCustomer    Komfo = new CompanyCustomer("Komfo");

            DepositAccount firstDeposit  = new DepositAccount(Bobo, 800, 15);
            LoanAccoint    secondDeposit = new LoanAccoint(Komfo, 2299, 19);

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , firstDeposit.Customer.Name, firstDeposit.Balance, firstDeposit.CalculateInterest(12));

            firstDeposit.DepositMoney(600);
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , firstDeposit.Customer.Name, firstDeposit.Balance, firstDeposit.CalculateInterest(12));


            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , secondDeposit.Customer.Name, secondDeposit.Balance, secondDeposit.CalculateInterest(2));

            Console.WriteLine();
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , secondDeposit.Customer.Name, secondDeposit.Balance, secondDeposit.CalculateInterest(6));

            MortgageAccount death = new MortgageAccount(Bobo, 750, 15);
            MortgageAccount metal = new MortgageAccount(Komfo, 1000, 15);

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , death.Customer.Name, death.Balance, death.CalculateInterest(6));
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , death.Customer.Name, death.Balance, death.CalculateInterest(7));
            Console.WriteLine();

            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , metal.Customer.Name, metal.Balance, metal.CalculateInterest(12));
            Console.WriteLine("Balance {0}: {1:#.##} lv.; Interest: {2:0.##}"
                              , metal.Customer.Name, metal.Balance, metal.CalculateInterest(24));
        }
Example #37
0
        public IHttpActionResult CreateCustomer(CustomerDTO customerdto)
        {
            var customer = Mapper.Map <CustomerDTO, Customer>(customerdto);

            var companyId = customerdto.Id;

            _context.Customer.Add(customer);
            _context.SaveChanges();

            var cInfo = _context.Customer.SingleOrDefault(c => c.AddressInfoId == customer.AddressInfoId);

            var combineInfo = new CompanyCustomer
            {
                CompanyId  = companyId,
                CustomerId = cInfo.Id
            };

            _context.CompanyCustomer.Add(combineInfo);
            _context.SaveChanges();

            customerdto.Id = customer.Id;

            return(Ok(Mapper.Map <Customer, CustomerDTO>(customer)));
        }
Example #38
0
       public static void Main()
        {
            Customer client1 = 
                new IndividualCustomer(
                    "7711240547",
                    "Лазур 18бл.", 
                    "0886630111", 
                    "Николай", 
                    "Костадинов");
            
            Customer client2 =
                new IndividualCustomer(
                    "5165656515",
                    "Изгрев 193бл.",
                    "0886123456",
                    "Христо",
                    "Григоров");

            Customer client3 =
                new CompanyCustomer(
                    "1234567890",
                    "пп Нефтохим",
                    "+3598863710",
                    "ИТСИБ ООД",
                    "0123456789");

            Customer client4 =
                new CompanyCustomer(
                    "1234567890",
                    "пп Нефтохим",
                    "+3598863710",
                    "ЛТСБ ООД",
                    "0123456789");

            IList<ICalculatable> accounts = new List<ICalculatable>
            {
                new DepositAccount(
                    client1,
                    1200M,
                    0.05M),

                new DepositAccount(
                    client3,
                    1200M,
                    0.05M),

                new LoanAccount(
                    client2,
                    100000M,
                    0.01M),

                new LoanAccount(
                    client4, 
                    100000M, 
                    0.02M),

                new MortgageAccount(
                    client1,
                    100000M,
                    0.012M),

                new MortgageAccount(
                    client3,
                    100000M,
                    0.012M),
            };
            int ix = 0;

            foreach (Account account in accounts)
            {
                ix++;
                Console.WriteLine(
                    "{0,-28} {1,-32} -> {2,13:C2}", 
                    account.ToString(), 
                    account.Awner.ToString(), 
                    account.CalculateInterestForPerion(12 + ix));
            }
        }
 public CompanyCustomer createCompanyCustomer(CompanyCustomer model)
 {
     db.companyCustomers.Add(model);
     db.SaveChanges();
     return model;
 }
 public CompanyCustomer createCompanyCustomer(CompanyCustomer model)
 {
     db.companyCustomers.Add(model);
     db.SaveChanges();
     return(model);
 }