Beispiel #1
0
        static void Main(string[] args)
        {
            // Abstract class

            // new anahtar kelimesi ile oluşturamıyoruz -> Error CS0144  Cannot create an instance of the abstract class or interface 'Person'
            // var resAbstractError1 = new Person();

            // Interface'ler için new anahtar kelimesinin zaten kullanılmadığını biliyorduk. Üstteki CS0144 nolu hata fırlatılacaktır.
            // var resInterfaceError1 = new IPerson();

            // Person adlı abstract sınıfından türettiğimiz EmployeeAbstract adlı sınıfı artık new anahtar kelimesi ile nesne örneği alabiliyoruz.
            var resAbstract = new EmployeeAbstract {
                Name = "Murat ÖNER"
            };
            var nameAbstract = resAbstract.GetName();
            var nameWithDescriptionAbstract = resAbstract.GetNameWithDesciption();

            Console.WriteLine($"Name Abstract: {nameAbstract}");
            Console.WriteLine($"NameWithDescription Abstract: {nameWithDescriptionAbstract}");

            // IPerson adlı arayüzden türettiğimiz EmployeeInterface adlı sınıfı artık new anahtar kelimesi ile nesne örneği alabiliyoruz.
            var resInterface = new EmployeeAbstract {
                Name = "Sakine ÖNER"
            };
            var nameInterface = resAbstract.GetName();
            var nameWithDescriptionInterface = resAbstract.GetNameWithDesciption();

            Console.WriteLine($"Name Interface: {nameInterface}");
            Console.WriteLine($"NameWithDescription Interface: {nameWithDescriptionInterface}");
        }
Beispiel #2
0
        public async Task <List <EmployeeResponse> > GetAllEmployeeContract()
        {
            EmployeesDTO employeesDTO = new EmployeesDTO();

            var employeesResponse = await employeesDTO.GetAllAnnualSalary();

            if (employeesResponse != null)
            {
                foreach (var e in employeesResponse)
                {
                    EmployeeAbstract employeeAbstract = CalculateAnnualSalary(e);
                    employeeAbstract.GetAnnualSalary(e);
                }
            }
            return(employeesResponse);
        }
Beispiel #3
0
        public async Task <List <EmployeeResponse> > GetEmployeeById(int id)
        {
            List <EmployeeResponse> responseList = new List <EmployeeResponse>();

            EmployeesDTO employeesDTO = new EmployeesDTO();

            var employeesResponse = await employeesDTO.GetEmployeeById(id);

            if (employeesResponse != null)
            {
                EmployeeAbstract employeeAbstract = CalculateAnnualSalary(employeesResponse);

                employeeAbstract.GetAnnualSalary(employeesResponse);

                responseList.Add(employeesResponse);

                return(responseList);
            }
            else
            {
                return(null);
            }
        }