public void Abstract_Class_constructor_And_Calling_Abstarct_method_Thorugh_Constructor()
 {
     //If you want abstract method to be invoked automatically whenever an instance of the class that is derived from abstract class is created,
     //then we call it in an abstract class constructor
     CorporateCustomer cc = new CorporateCustomer();//See that the Print method is called automatically
     SavingsCustomer   sc = new SavingsCustomer();
 }
Example #2
0
    static void Main()
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

        Customer depositAccountCustomer = new IndividualCustomer(
            "2343PJ34752",
            "William",
            "Harris",
            "1 Microsoft Way, Redmond, WA",
            "1-888-553-6562");

        DepositAccount depositAccount = new DepositAccount(
            depositAccountCustomer,
            2500,
            1.0825M,
            12);

        Customer loanAccountCustomer = new CorporateCustomer(
            "89BPQ123YJ0",
            "Oracle Corporation",
            "500 Oracle Parkway, Redwood Shores, Redwood City, California, United States",
            "1-981-717-9366");

        Account loanAccount = new LoanAccount(
            loanAccountCustomer,
            1000000000,
            1.0931M,
            24);

        Customer mortgageLoanAccountCustomer = new IndividualCustomer(
            "97A20LX3YJU",
            "Ginni",
            "Rometty",
            "Armonk, New York, U.S.",
            "1-129-342-3817");

        Account mortgageLoanAccount = new MortgageLoanAccount(
            mortgageLoanAccountCustomer,
            300000,
            1.0875M,
            36);

        decimal depositInterest = depositAccount.CalculateInterest(3);

        Console.WriteLine("Deposit account interest: {0:C2}", depositInterest);

        depositAccount.Deposit(459.76M);
        depositAccount.Withdraw(400.76M);

        Console.WriteLine("Deposit account balance: {0:C2}", depositAccount.Balance);

        decimal loanInterest = loanAccount.CalculateInterest(10);

        Console.WriteLine("Loan account interest: {0:C2}", loanInterest);

        decimal mortgageLoanInterest = mortgageLoanAccount.CalculateInterest(10);

        Console.WriteLine("Mortgage loan account interest: {0:C2}", mortgageLoanInterest);
    }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            CorporateCustomer corporateCustomer = db.Customers.Find(id) as CorporateCustomer;//had to add "as CorporateCustomer"

            db.Customers.Remove(corporateCustomer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
    public void PrintID()
    {
        CorporateCustomer CC = new CorporateCustomer();
        // CC.IDS = 101; //this should owrk perfectly since it inherited IDS from Customer

        //base.IDS = 33; // the base keyword access the base property of the protected member, where it got it's derived data from. From the inherited parent.
        //MainClass below can't use base.IDS to access any inheritance from Customer class.
    }
            public void PrintCustomerID()
            {
                CorporateCustomer corporateCustomerInstance = new CorporateCustomer();

                // Can access the base class protected instance member using the derived class object
                Console.WriteLine(corporateCustomerInstance.Id);
                // Can access the base class protected instance member using this or base keyword
                Console.WriteLine(this.Id);
                Console.WriteLine(base.Id);
            }
Example #6
0
 public ActionResult Edit([Bind(Include = "CustomerID,Firstname,Lastname,MailAdress,StreetAdress,City,ZipCode,CompanyName,CompanyPhoneNumber,CompanyWebSite")] CorporateCustomer corporateCustomer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(corporateCustomer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(corporateCustomer));
 }
        public IActionResult Update(CorporateCustomer corporateCustomer)
        {
            var result = _corporateCustomerService.Update(corporateCustomer);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Example #8
0
        static void Main(string[] args)
        {
            CorporateCustomer CC = new CorporateCustomer();

            Console.WriteLine(CC.ID);

            SavingsCustomer SC = new SavingsCustomer();

            Console.WriteLine(SC.ID);
        }
Example #9
0
        public IResult Update(CorporateCustomer customer)
        {
            var result = _corporateCustomerDal.Any(c => c.CompanyName == customer.CompanyName);

            if (result)
            {
                _corporateCustomerDal.Update(customer);
                return(new SuccessResult(Messages.CorporateCustomer.Update(customer.CompanyName)));
            }
            return(new ErrorResult(Messages.NotFound()));
        }
Example #10
0
        public IResult Delete(CorporateCustomer customer)
        {
            var result = _corporateCustomerDal.Any(c => c.Id == customer.Id);

            if (!result)
            {
                return(new ErrorResult(Messages.NotFound()));
            }
            _corporateCustomerDal.Delete(customer);
            return(new SuccessResult(Messages.CorporateCustomer.Delete(customer.CompanyName)));
        }
Example #11
0
        public IResult Add(CorporateCustomer customer)
        {
            var result = _corporateCustomerDal.Any(c => c.CompanyName == customer.CompanyName);

            if (!result)
            {
                _corporateCustomerDal.Add(customer);
                return(new SuccessResult(Messages.CorporateCustomer.Add(customer.CompanyName)));
            }
            return(new ErrorResult(Messages.CorporateCustomer.Exists(customer.CompanyName)));
        }
        static void Main(string[] args)
        {
            Customer pc = new PersonalCustomer("Furkan", "Işıtan");
            Customer cc = new CorporateCustomer("Test", "Username", "Example");

            UsageCredit.Leasing(pc);
            UsageCredit.Leasing(cc);
            UsageCredit.Mortgage(pc);
            UsageCredit.Mortgage(cc);

            Console.ReadKey();
        }
Example #13
0
        public async Task <IActionResult> GetbyIdAsync([FromRoute] string id)
        {
            //TODO return not found error
            // var customerItem = await _customerContext.RetailCustomer.SingleOrDefaultAsync(i => i.Id == customerToUpdate.Id);

            // if (customerItem == null)
            // {
            //     return NotFound(new { Message = $"Item with id {customerToUpdate.Id} not found." });
            // }

            CorporateCustomer customer = await _customerContext.CorporateCustomer.Where(x => x.Id == id).SingleOrDefaultAsync();

            return(Ok(customer));
        }
Example #14
0
        // GET: CorporateCustomer/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CorporateCustomer corporateCustomer = db.Customers.Find(id) as CorporateCustomer;//had to add "as CorporateCustomer"

            if (corporateCustomer == null)
            {
                return(HttpNotFound());
            }
            return(View(corporateCustomer));
        }
Example #15
0
        public async Task <IActionResult> UpdateAsync([FromBody] CorporateCustomer customerToUpdate)
        {
            // var customerItem = await _customerContext.RetailCustomer.SingleOrDefaultAsync(i => i.Id == customerToUpdate.Id);

            //TODO return not found error
            // if (customerItem == null)
            // {
            //     return NotFound(new { Message = $"Item with id {customerToUpdate.Id} not found." });
            // }

            _customerContext.CorporateCustomer.Update(customerToUpdate);

            await _customerContext.SaveChangesAsync();

            return(Ok(customerToUpdate));
        }
Example #16
0
        private static void AddCorporateCustomer(CorporateCustomerManager corporateCustomerManager)
        {
            var corporate = new CorporateCustomer
            {
                CompanyName = "ABC LTD.",
                TaxNumber   = "1234567891",
                Address     = "İstanbul Şişli",
                Email       = "*****@*****.**",
                //PasswordHash = "12345",
                PhoneNumber = "02124445566",
                JoinDate    = DateTime.Now
            };
            var result = corporateCustomerManager.Add(corporate);

            Console.WriteLine(result.Message);
        }
    public void PrintID()
    {
        CorporateCustomer corporateCustomer = new CorporateCustomer();

        corporateCustomer.Name = "Customer 1";
        Console.WriteLine(corporateCustomer.Name);
        Console.WriteLine(this.Name);
        Console.WriteLine(base.Name);

        //We cannot print '_Id' because it's private
        //Console.WriteLine(corporateCustomer._Id);

        //To access above type member with the help of public getter and setter method as

        corporateCustomer.Id = 101;

        Console.WriteLine(corporateCustomer.Id);
    }
Example #18
0
        public async Task <IActionResult> AddAsync([FromBody] CorporateCustomer newCustomer)
        {
            string validationResult = newCustomer.ValidateAndPrepeareForInsert();

            if (!string.IsNullOrEmpty(validationResult))
            {
                Error a = new Error();

                a.Title   = "Invalid fields";
                a.Message = validationResult;

                return(BadRequest(a));
            }

            _customerContext.CorporateCustomer.Add(newCustomer);
            await _customerContext.SaveChangesAsync();

            return(Ok(newCustomer));
        }
    public static void Main()
    {
        CorporateCustomer corporateCustomer = new CorporateCustomer();

        Console.WriteLine(corporateCustomer.Email);

        //We cannot print '_Id' because it's private
        //Console.WriteLine(corporateCustomer._Id);

        //To access above type member with the help of public getter and setter method as

        corporateCustomer.Id = 102;

        Console.WriteLine(corporateCustomer.Id);

        //We cannot print 'Nane' because it's protected
        //Console.WriteLine(corporateCustomer.Name);

        corporateCustomer.PrintID();
    }
Example #20
0
        static void Main()
        {
            // A bank holds different types of accounts for its customers: deposit accounts, loan accounts and
            // mortgage accounts. Customers could be individuals or companies.
            // All accounts have customer, balance and interest rate (monthly based). Deposit accounts are allowed
            // to deposit and with draw money. Loan and mortgage accounts can only deposit money.
            // All accounts can calculate their interest amount for a given period (in months). In the common case
            // its is calculated as follows: number_of_months * interest_rate.
            // Loan accounts have no interest for the first 3 months if are held by individuals and for the first 2
            // months if are held by a company.
            // Deposit accounts have no interest if their balance is positive and less than 1000.
            // Mortgage accounts have ½ interest for the first 12 months for companies and no interest for the first
            // 6 months for individuals.
            // Your task is to write a program to model the bank system by classes and interfaces. You should identify
            // the classes, interfaces, base classes and abstract actions and implement the calculation of the interest
            // functionality through overridden methods.

            Thread.CurrentThread.CurrentCulture = new CultureInfo ("bg-BG");

            var Dimitar = new IndividualCustomer (34334752, "Dimitar", "Petrov");

            var Pipi = new IndividualCustomer (97203, "Pipi", "Topcheva");

            var Gogo = new IndividualCustomer (34334752, "Gogo", "Petrov");

            var Gana = new IndividualCustomer (97203, "Gana", "Pamukova");

            var CorporateTroshikamak = new CorporateCustomer (891230, "Troshikamak Corporation");

            var depositIC_Dimitar = new Deposit (Dimitar, 2500M, 1.0825M, 12);

            var depositIC_Gogo = new Deposit (Gogo, 500M, 1.0825M, 12);

            var loanIC_Gogo = new Loan (Gogo, 500M, 1.0825M, 2);

            var loanCC_CorporateTroshikamak = new Loan (CorporateTroshikamak, 1000000000M, 1.0931M, 36);

            var mortgageCC_CorporateTroshikamak = new Mortgage (CorporateTroshikamak, 1000000000M, 1.0931M, 6);

            var mortgageIC_Gana = new Mortgage (Gana, 100000M, 1.0875M, 7);

            var mortgageIC_Pipi = new Mortgage (Pipi, 100000M, 1.0875M, 3);

            List<Deposit> D_L = new List<Deposit> ();
            D_L.Add (depositIC_Dimitar);
            D_L.Add (depositIC_Gogo);

            List<Loan> L_L = new List<Loan> ();
            L_L.Add (loanIC_Gogo);
            L_L.Add (loanCC_CorporateTroshikamak);

            List<Mortgage> M_L = new List<Mortgage> ();
            M_L.Add (mortgageIC_Gana);
            M_L.Add (mortgageIC_Pipi);
            M_L.Add (mortgageCC_CorporateTroshikamak);

            Bank bank = new Bank ();
            bank.DepositAccountsList = D_L;
            bank.LoanAccountsList = L_L;
            bank.MortgageAccountsList = M_L;

            foreach (var item in bank.DepositAccountsList)
            {
                Console.WriteLine (item);
                Console.WriteLine ();
            }

            foreach (var item in bank.LoanAccountsList)
            {
                Console.WriteLine (item);
                Console.WriteLine ();
            }

            foreach (var item in bank.MortgageAccountsList)
            {
                Console.WriteLine (item);
                Console.WriteLine ();
            }
        }
Example #21
0
 static void Main(string[] args)
 {
     SavingsCustomer   sc = new SavingsCustomer();
     CorporateCustomer cc = new CorporateCustomer();
 }