Beispiel #1
0
        static void Main(string[] args)
        {
            try
            {
                Employee employee = new Employee();
                Console.WriteLine("Enter date of birth:");
                employee.DateOfBirth = Convert.ToDateTime(Console.ReadLine());

                //Console.WriteLine(employee.DateOfBirth);

                EmployeeBusinessLogic employeeBusinessLogic = new EmployeeBusinessLogic();
                employeeBusinessLogic.AddEmployee(employee);
                Console.WriteLine("Employee Added Successfully");
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    Console.WriteLine(ex.InnerException.Message);
                }
                Console.WriteLine();
                Console.WriteLine(ex.Message);
                Console.WriteLine();
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine();
                Console.WriteLine(ex.Source);
            }
            finally
            {
                Console.WriteLine("Thank you. Returning to Main menu");
            }

            Console.ReadKey();
        }
Beispiel #2
0
        public void SetUp()
        {
            fakeDataAccess = new Mock <IEmployeeDataAccess>();
            ebl            = new EmployeeBusinessLogic(fakeDataAccess.Object);

            fakeDataAccess.Setup(m => m.GetEmployeeSalary(It.IsAny <int>())).Equals(169069);
        }
Beispiel #3
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            string skillID = ShowSkillDialog();

            EmployeeBusinessLogic employeeBusiness = new EmployeeBusinessLogic();

            employeeBusiness.addSkillForEmployee(selectedStaff.Id, skillID);
        }
        static void ViewEmployees()
        {
            EmployeeBusinessLogic employeeBusinessLogic = new EmployeeBusinessLogic();
            List <Employee>       emps = employeeBusinessLogic.GetEmployees();

            foreach (Employee emp in emps)
            {
                Console.WriteLine(emp.EmployeeID + ", " + emp.EmployeeName);
            }
        }
Beispiel #5
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            EmployeeBusinessLogic employeeBusiness = new EmployeeBusinessLogic();

            selectedStaff.FirstName = txtName.Text;
            selectedStaff.Email     = txtEmail.Text;
            selectedStaff.LastName  = txtSurname.Text;
            selectedStaff.Address   = txtNum.Text;

            employeeBusiness.updateEmployee(selectedStaff, employeeType.technician);
        }
Beispiel #6
0
        private string ShowSkillDialog()
        {
            EmployeeBusinessLogic employeeBusiness = new EmployeeBusinessLogic();
            List <Skill>          employeeSkils    = employeeBusiness.getEmployeeSkills(selectedStaff);

            List <string> currentSkills = new List <string>();

            foreach (Skill skill in employeeSkils)
            {
                currentSkills.Add(skill.ID);
            }

            List <string> newSkills = employeeBusiness.listAllSkills(currentSkills);

            Form prompt = new Form()
            {
                Width           = 500,
                Height          = 150,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Text            = "Please enter your new skill name",
                StartPosition   = FormStartPosition.CenterScreen
            };
            Label lblPassword = new Label()
            {
                Left = 50, Top = 20, Text = "New Skill"
            };
            ComboBox cmbSkills = new ComboBox()
            {
                Left = 50, Top = 50, Width = 400
            };

            int count = 0;

            foreach (string item in newSkills)
            {
                cmbSkills.Items.Add(new ComboBoxItem(item, count));
                count++;
            }

            Button confirmation = new Button()
            {
                Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK
            };

            confirmation.Click += (sender, e) => { prompt.Close(); };
            prompt.Controls.Add(cmbSkills);
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(lblPassword);
            prompt.AcceptButton = confirmation;

            return(prompt.ShowDialog() == DialogResult.OK ? cmbSkills.Name : "");
        }
        static void AddEmployee()
        {
            EmployeeBusinessLogic employeeBusinessLogic = new EmployeeBusinessLogic();
            Employee employee = new Employee();

            Console.Write("Enter Emp ID: ");
            employee.EmployeeID = int.Parse(Console.ReadLine());
            Console.Write("Enter Emp Name: ");
            employee.EmployeeName = Console.ReadLine();

            employeeBusinessLogic.Add(employee);
            Console.WriteLine("Employee Added.\n");
        }
Beispiel #8
0
        static void UpdateEmployee()
        {
            EmployeeBusinessLogic employeeBusinessLogic = new EmployeeBusinessLogic();
            Employee employee = new Employee();

            Console.Write("Enter Existing Emp ID: ");
            employee.EmployeeID = int.Parse(Console.ReadLine());
            Console.Write("Enter New Emp Name: ");
            employee.EmployeeName = Console.ReadLine();

            employeeBusinessLogic.UpdateEmployee(employee);
            Console.WriteLine("Employee Updated.\n");
        }
Beispiel #9
0
        public void Setup()
        {
            var fakeList = new List <string>()
            {
                "55000", "45000", "35000"
            };

            FakeDataAccess = new Mock <IEmployee>();
            FakeDataAccess.Setup(e => e.GetEmployeeSalary(It.IsAny <int>())).Returns(55000);
            FakeDataAccess.Setup(i => i.GetTop3Salarys()).Returns(fakeList.ToString());
            FakeDataAccess.Setup(x => x.GetHiringDate(It.IsAny <int>())).Returns(3);

            EBL = new EmployeeBusinessLogic(FakeDataAccess.Object);
        }
        static void UpdateEmployee()
        {
            EmployeeBusinessLogic employeeBusinessLogic = new EmployeeBusinessLogic();
            Employee employee = new Employee();


            //subscribing to event
            employee.EmpNameChanged += employeeBusinessLogic.UpdateEmployeeName;



            Console.Write("Enter Existing Emp ID: ");
            employee.EmployeeID = int.Parse(Console.ReadLine());
            Console.Write("Enter New Emp Name: ");
            employee.EmployeeName = Console.ReadLine(); //executes UpdateEmployeeName method

            employeeBusinessLogic.UpdateEmployee(employee);
            Console.WriteLine("Employee Updated.\n");
        }
Beispiel #11
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/
        }
 public EmployeeController()
 {
     employeeObjBs = new EmployeeBusinessLogic();
 }
 public EmployeeController()
 {
     this.business = new EmployeeBusinessLogic();
 }
Beispiel #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txt_UserName.Text == "" || txt_Password.Text == "")
            {
                MessageBox.Show("Please provide User Name and Password");
                return;
            }
            try
            {
                AuthenticationBusinessLogic authLogic       = new AuthenticationBusinessLogic();
                Dictionary <string, string> userAuthDetails = authLogic.Authenticate(txt_UserName.Text, authenticationLogic.Encipher(txt_Password.Text, 12));

                if (userAuthDetails != null)
                {
                    EmployeeBusinessLogic employeeBusinessLogic = new EmployeeBusinessLogic();

                    switch (userAuthDetails["userType"])
                    {
                    case "CallCentre":
                        List <Employee> callCentreDetails = employeeBusinessLogic.searchEmployeesByParamater(employeeSearchParamaters.id, employeeType.callCenter, userAuthDetails["id"]);
                        this.Hide();
                        FrmCallCenter frmCallCenter = new FrmCallCenter(callCentreDetails[0]);
                        frmCallCenter.Show();
                        break;

                    case "Technician":
                        List <Employee> technicianDetails = employeeBusinessLogic.searchEmployeesByParamater(employeeSearchParamaters.id, employeeType.technician, userAuthDetails["id"]);

                        List <Employee> stanbyEmployees = employeeBusinessLogic.employeesOnStandBy(employeeType.technician);

                        if (stanbyEmployees.FindIndex(employee => employee.Id == technicianDetails[0].Id) >= 0)
                        {
                            AvailableJobsScreen availableJobsScreen = new AvailableJobsScreen(technicianDetails[0]);
                            this.Hide();
                            availableJobsScreen.Show();
                        }
                        else
                        {
                            Job       currentJob = jobLogic.getJobsBySearchParamater(jobSearchParamaters.employeeID, technicianDetails[0].Id).Except(jobLogic.getJobsBySearchParamater(jobSearchParamaters.status, "Completed")).ToList()[0];
                            JobScreen jobScreen  = new JobScreen(job: currentJob, employee: technicianDetails[0]);
                            this.Hide();
                            jobScreen.Show();
                        }
                        break;

                    case "Client":
                        ClientBusinessLogic clientBusinessLogic = new ClientBusinessLogic();
                        List <Client>       clientDetails       = clientBusinessLogic.searchClientByParameter(clientSearchParameter.id, userAuthDetails["id"]);

                        FrmClientSatisfaction clientSatisfaction = new FrmClientSatisfaction(clientDetails[0]);
                        this.Hide();
                        clientSatisfaction.Show();
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }