/// <summary>
 /// Fetches employee details
 /// </summary>
 private void GetEmployeeDetails()
 {
     try
     {
         int pageNumber = 0;
         if (Start < 2)
         {
             pageNumber = 1;
         }
         else
         {
             pageNumber = (Start / 20) + 1;
         }
         //businessLogic.GetEmployeeDetails(pageNumber);
         Employees  = businessLogic.GetEmployeeDetails(pageNumber).Item1;
         IsLoadData = true;
         if (pageNumber == 1)
         {
             Start      = businessLogic.GetEmployeeDetails(pageNumber).Item2;
             End        = businessLogic.GetEmployeeDetails(pageNumber).Item3;
             TotalItems = businessLogic.GetEmployeeDetails(pageNumber).Item4;
         }
         NotifyPropertyChanged("Start");
         NotifyPropertyChanged("End");
         NotifyPropertyChanged("TotalItems");
     }
     catch (Exception ex)
     {
         ResponseMessage = "Employee data cannot be fetched at the moment!";
         LoggerHelper.logger.Error("Error in GetEmployeeDetails" + ex.Message);
     }
     finally
     {
         ClearContents();
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            //The Dependency Inversion Principle (DIP) states that high-level modules/classes should not depend on low-level modules/classes.
            //Both should depend upon abstractions. Secondly, abstractions should not depend upon details. Details should depend upon abstractions.
            //dependency inversion principle
            var employee = new EmployeeBusinessLogic();

            Console.WriteLine(JsonSerializer.Serialize(employee.GetEmployeeDetails(1)));

            //dependency inversion principle

            //liskov substitution principle : This principle states that, if S is a subtype of T, then objects of type T should be replaced with the objects of type S.
            // yerine koyma

            Apple apple = new Orange();

            Console.WriteLine(apple.GetColor());

            //after

            Fruit fruit = new Avocado();

            Console.WriteLine(fruit.GetColor());
            fruit = new Banana();
            Console.WriteLine(fruit.GetColor());

            //liskov substitution principle

            //open close principle

            var invoice = new Invoice();

            Console.WriteLine(invoice.GetInvoiceDiscount(1000, InvoiceType.FinalInvoice));
            Console.WriteLine(invoice.GetInvoiceDiscount(1000, InvoiceType.ProposedInvoice));

            //after

            InvoiceOCP fInvoice = new FinalInvoice();
            InvoiceOCP pInvoice = new ProposedInvoice();
            InvoiceOCP rInvoice = new RecurringInvoice();

            Console.WriteLine(fInvoice.GetInvoiceDiscount(100));
            Console.WriteLine(pInvoice.GetInvoiceDiscount(100));
            Console.WriteLine(rInvoice.GetInvoiceDiscount(100));

            //open close principle


            Console.Read();


            /*
             *
             * Single Responsibility : Sınıflarımızın iyi tanımlanmış tek bir sorumluluğu olmalı.
             * Open/Closed : Sınıflarımız değişikliğe kapalı ancak yeni davranışların eklenmesine açık olmalı.
             * Liskov Substitution(yerine koyma) : Kodumuzda herhangi bir değişiklik yapmaya gerek kalmadan türetilmiş sınıfları (sub class) türedikleri ata sınıfın (base class) yerine kullanabilmeliyiz.
             * Interface Segregation : Genel kullanım amaçlı tek bir kontrat yerine daha özelleşmiş birden çok kontrat oluşturmayı tercih etmeliyiz.
             * Dependency Inversion : Katmanlı mimarilerde üst seviye modüller alt seviyedeki modüllere doğruda bağımlı olmamalıdır.
             *
             */

            // https://dotnettutorials.net/lesson/dependency-inversion-principle/
        }