public async Task AddPEmployee(PermanentEmployee permanentEmployee)
        {
            // var user = await _b2CGraphClient.GetAllUsers("");
            await _repository.Insert(permanentEmployee);

            await _repository.SaveChanges();
        }
        public bool UpdatePermanentEmployee(PermanentEmployee employee)
        {
            // If an employee doesn't exist then you can't update it
            _log.Info($"Updateing employee: {employee.EmployeeID}");

            var employeeToUpdate = ReadPermanentEmployee(employee.EmployeeID);

            if (employeeToUpdate == null)
            {
                _log.Warn("Employee could not be found. Was the Id changed?");
                return(false);
            }

            // Check that the new employee has the same ID and StartDate as the one to update
            if (employeeToUpdate.EmployeeID != employee.EmployeeID)
            {
                _log.Warn("EmployeeId's do not match");
                return(false);
            }
            if (employeeToUpdate.StartDate.Date != employee.StartDate.Date)
            {
                _log.Warn("EmployeeId's do not match");
                return(false);
            }

            DeletePermanentEmployee(employeeToUpdate.EmployeeID);
            CreatePermanentEmployee(employee);

            return(SaveChanges());
        }
Example #3
0
        public override IEmplyee Create()
        {
            PermanentEmployee pe = new PermanentEmployee();

            _employee.ExtraBenefit = pe.GetBenefit();
            return(pe);
        }
        protected override IEmployee Create()
        {
            PermanentEmployee permanentEmp = new PermanentEmployee();

            _emp.HouseAllowance = permanentEmp.GetHouseAllowance();
            return(permanentEmp);
        }
        public decimal CalculateAnnualPay(PermanentEmployee employee)
        {
            decimal annualPay = employee.AnnualSalary + employee.AnnualBonus;

            _log.Debug($"Calculated annual pay {annualPay}");
            _log.Info($"AnnualSalary: {employee.AnnualSalary}, AnnualBonus: {employee.AnnualBonus}");
            return(annualPay);
        }
Example #6
0
        public void CalculateAnnualDay_Returns_Expected_Result(decimal annualSalary, decimal annualBonus, decimal expectedResult)
        {
            var employee = new PermanentEmployee("Ben", annualSalary, annualBonus, DateTimeOffset.UtcNow);

            var actualResult = employee.CalculateAnnualPay();

            Assert.Equal(expectedResult, actualResult, 2);
        }
Example #7
0
        public void Permanent_Employee_Will_Have_MinValue_End_Date_By_Default()
        {
            // Act
            var employee = new PermanentEmployee("Harry", 33000, 3000, new DateTimeOffset(2019, 10, 9, 0, 0, 0, TimeSpan.Zero));

            // Assert
            Assert.Equal(DateTimeOffset.MinValue, employee.EndDate);
        }
Example #8
0
        static void Main(string[] args)
        {
            Employee emp1 = new PermanentEmployee("267543", "Galip", 5000);
            Employee emp2 = new ContractEmployee("953456", "AyÅŸe", 30);

            Console.WriteLine(emp1);
            Console.WriteLine(emp2);
        }
Example #9
0
        public void CalculateHourlyPay_Returns_Expected_Result(decimal annualSalary, decimal expectedResult)
        {
            var employee = new PermanentEmployee("Richard", annualSalary, 44, DateTimeOffset.UtcNow);

            var actualResult = employee.CalculateHourlyPay();

            Assert.Equal(expectedResult, actualResult, 2);
        }
        public decimal CalculateHourlyPay(PermanentEmployee employee)
        {
            decimal hourlyPay = (((employee.AnnualSalary / 52) / 5) / 7);

            _log.Debug($"Calculated hourly pay {hourlyPay}");
            _log.Info($"AnnualSalary: {employee.AnnualSalary}");
            return(hourlyPay);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            PermanentEmployee permanentEmployee = db.PermanentEmployees.Find(id);

            db.PermanentEmployees.Remove(permanentEmployee);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #12
0
        static void Main(string[] args)
        {
            List <IEmployee> lst = new List <IEmployee>();

            lst.Add(new PermanentEmployee());
            lst.Add(new ContractEmployee());

            Employee obj = new PermanentEmployee();
        }
Example #13
0
 public async Task Update(PermanentEmployee permanentEmployee)
 {
     try
     {
         await _permanentEmployeeManager.UpdatePEmployee(permanentEmployee);
     }
     catch (Exception ex)
     {
     }
 }
Example #14
0
        // SOLID design principles
        //  --S -- Single responsibility Principle
        //  --O-- Open Closed Principle
        //  --L-- Liskov Substitution Principle
        //  --I-- Interface Segregation Principle
        //  --D-- Dependency Inversion Principle


        /* Single responsibility Principle
         *
         * Every Class or Module should have responsibilty over a single part of the functionality of software and
         *  that responsibility should be entirely encapsulated by the class
         *
         * Liskov Substitution Principle
         *
         * Objects in a program should be replacable with their instances of the subtype without affecting the correctness of the program
         * If a Program modeule is using a base class , then reference t the base class can be replaced with the derived class without altering the funtionality of the program module.
         * No new Exception should be thrown.
         *
         * Open Closed Principle
         * Software entities should be open for extension but closed for modification
         * The design and writing of the code should be in such a way that new funcyionality should be added with minimal changes in the existing code
         *
         * Interface Segregation Principle
         * Many client specific interfaces are better than one general purpose interface.
         * We should not enforce client to implement interfaces they don't use.Instead of using one big interface we can break down it to smaller interfaces.
         *
         *
         * Dependency Inversion Principle
         * One should depend upon abstractions and not concretions.
         * Abstraction should not depend on the details where as detail should depend on abstractions.
         * High-level modules should not depend on low level modules.
         *
         *
         */
        static void Main(string[] args)
        {
            Employee lEmployee = new TemporaryEmployee(1, 10000);

            Console.WriteLine(lEmployee.getBonus());

            Employee lEmployeeT = new PermanentEmployee(1, 10000);

            Console.WriteLine(lEmployeeT.getBonus());
        }
 public PermanentEmployee CreatePermanentEmployee(PermanentEmployee employee)
 {
     _log.Debug($"Adding Permanent Employee. EmployeeID: {employee.EmployeeID}.");
     if (employee.EmployeeID.Equals(Guid.Empty))
     {
         employee.EmployeeID = Guid.NewGuid();
     }
     _employees.Add(employee);
     return(employee);
 }
 public ActionResult Edit([Bind(Include = "ID,AnuualSalary,FirstName,LastName,Gender")] PermanentEmployee permanentEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(permanentEmployee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(permanentEmployee));
 }
Example #17
0
 public async Task Create(PermanentEmployee permanentEmployee)
 {
     try
     {
         await _permanentEmployeeManager.AddPEmployee(permanentEmployee);
     }
     catch (Exception ex)
     {
         throw ex.InnerException;
     }
 }
Example #18
0
        private static void Main(string[] args)
        {
            var visitingEmployee = new VisitingEmployee()
            {
                EmployeeId          = 593826,
                FirstName           = "John",
                MiddleName          = "",
                LastName            = "Skull",
                DateOfBirth         = new DateTime(1984, 3, 12),
                Gender              = Gender.Male,
                RatePerVisit        = 35,
                VisitCount          = 13,
                Department          = Department.Management,
                RequestedDeviceType = DeviceType.Laptop
            };

            var permanentEmployee = new PermanentEmployee()
            {
                EmployeeId          = 513873,
                FirstName           = "Ted",
                MiddleName          = "",
                LastName            = "M",
                DateOfBirth         = new DateTime(1995, 6, 5),
                Gender              = Gender.Male,
                JoinedDate          = new DateTime(2016, 11, 10),
                MonthlySalary       = 150,
                Department          = Department.Research,
                RequestedDeviceType = DeviceType.Laptop
            };

            var contractEmployee = new ContractEmployee()
            {
                EmployeeId         = 598764,
                FirstName          = "Mary",
                MiddleName         = "",
                LastName           = "M",
                DateOfBirth        = new DateTime(1993, 8, 15),
                Gender             = Gender.Female,
                ContractStartDate  = new DateTime(1995, 6, 5),
                ContractEndDate    = new DateTime(1995, 6, 5),
                HourlyRate         = 60,
                WorkingHoursPerDay = 8,
                Department         = Department.Engineering
            };

            var deviceFactory         = EmployeeDeviceFactory.Create(permanentEmployee);
            var employeeDeviceManager = new EmployeeDeviceManager(deviceFactory);

            var employeeWorkStation = employeeDeviceManager.GetEmployeeWorkStation();

            Console.WriteLine(employeeWorkStation);

            Console.ReadLine();
        }
        public IEmployee CreateEmployee()
        {
            PermanentEmployee permanentEmployee = new PermanentEmployee
            {
                EmpName = "Emp ABC"
            };

            permanentEmployee.GetNetSalary = permanentEmployee.GetTotalSalary(123) + " |AND| " + permanentEmployee.GetGratuity(123);

            return(permanentEmployee);
        }
Example #20
0
        static void GetEmployeeDetails(Employee s)
        {
            if (count < 3)
            {
                Console.Write("Enter Employee ID:");
                int sid = Convert.ToInt32(Console.ReadLine());
                Console.Write("Enter Employee Name:");
                string name = Console.ReadLine();
                Console.Write("Enter Address:");
                string address = Console.ReadLine();
                Console.Write("Enter City:");
                string city = Console.ReadLine();
                Console.Write("Enter Department:");
                string department = Console.ReadLine();
                Console.Write("Enter Salary:");
                double salary = Convert.ToDouble(Console.ReadLine());
                s.EmployeeId   = sid;
                s.EmployeeName = name;
                s.City         = city;
                s.Address      = address;
                s.Department   = department;
                s.Salary       = salary;

                if (s is PermanentEmployee)
                {
                    PermanentEmployee pe = (PermanentEmployee)s;
                    Console.Write("Enter Provident Fund:");
                    double pf = Convert.ToDouble(Console.ReadLine());

                    Console.Write("Enter No of Leaves:");
                    int noofleaves = Convert.ToInt32(Console.ReadLine());
                    pe.providentFund = pf;
                    pe.noOfLeaves    = noofleaves;
                }
                else if (s is ContractEmployee)
                {
                    ContractEmployee ce = (ContractEmployee)s;

                    Console.Write("Enter Perks:");
                    double perks = Convert.ToInt32(Console.ReadLine());

                    ce.Perks = perks;
                }
                else
                {
                    Employees[count] = s;
                }
                count++;
            }
            else
            {
                Console.WriteLine("No More Space");
            }
        }
        public void CalcWeeksWorked_Returns_Expected_Result_When_EndDate_MinValue()
        {
            // Arrange
            var employee       = new PermanentEmployee("Richard", 10.0m, 1.1m, DateTimeOffset.UtcNow.AddDays(-7));
            var expectedResult = (DateTimeOffset.Now - employee.StartDate).TotalDays / 7;
            // Act
            var actualResult = employee.CalcWeeksWorked();

            // Assert
            Assert.Equal(expectedResult, actualResult, 2);
        }
        public ActionResult Create([Bind(Include = "ID,AnuualSalary,FirstName,LastName,Gender")] PermanentEmployee permanentEmployee)
        {
            if (ModelState.IsValid)
            {
                db.PermanentEmployees.Add(permanentEmployee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(permanentEmployee));
        }
Example #23
0
        public void Can_Add_New_Permanent_Employee()
        {
            // Arrange
            var employee       = new PermanentEmployee("Harry Smith", 20000, 111, new DateTimeOffset(2019, 6, 2, 0, 0, 0, TimeSpan.Zero));
            var expectedResult = employee.EmployeeID;

            // Act
            var actualResult = _repo.CreatePermanentEmployee(employee).EmployeeID;

            // Assert
            Assert.Equal(expectedResult, actualResult);
        }
Example #24
0
        public void Permanent_Employee_Will_Have_Todays_Date_If_StartDate_Not_Specified()
        {
            // Arrange
            var employee     = new PermanentEmployee("Harry");
            var expectedDate = DateTimeOffset.UtcNow.Date;

            // Act
            var actualDate = employee.StartDate;

            // Assert
            Assert.Equal(expectedDate, actualDate);
        }
        public void StartDate_After_Current_Date_WeeksWorked_Zero()
        {
            // Arrange
            var employee       = new PermanentEmployee("Toby", 100.00m, 1m, DateTimeOffset.UtcNow.AddDays(7));
            var expectedResult = 0;

            // Act
            var actualResult = employee.CalcWeeksWorked();

            // Assert
            Assert.Equal(expectedResult, actualResult);
        }
Example #26
0
        public void PrintResult()
        {
            var permEmp = new PermanentEmployee(".Net employee", "Ujjwal");
            var tempEmp = new TemporaryEmployee("java employee", "ram");

            Console.WriteLine("Before Decorator");
            Console.WriteLine(permEmp.GetDetails());
            Console.WriteLine("After Decorator");
            var permDec = new PermEmployeeDecorator(permEmp);

            permDec.GetDetails();
            Console.WriteLine(permDec.GetDetails());
        }
Example #27
0
        public void An_Employee_With_No_Id_Will_Be_Assigned_Id_When_Added_To_Repo()
        {
            // Arrange
            var employee = new PermanentEmployee("Harry");

            employee.EmployeeID = Guid.Empty;

            // Act
            var actualResult = _repo.CreatePermanentEmployee(employee).EmployeeID;

            // Assert
            Assert.NotEqual(Guid.Empty, actualResult);
        }
        // GET: PermanentEmployees/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PermanentEmployee permanentEmployee = db.PermanentEmployees.Find(id);

            if (permanentEmployee == null)
            {
                return(HttpNotFound());
            }
            return(View(permanentEmployee));
        }
Example #29
0
        public Employees EmployeeList()
        {
            if (_empList != null)
            {
                PermanentEmployee _pe = new PermanentEmployee()
                {
                    ID = 1,
                    FirstName = "David",
                    LastName = "Shaw",
                    MonthlySalary = 500,
                };
                _pe.AnnualSalary = _pe.GetAnnualSalary();
                _empList.Add(_pe);

                PermanentEmployee _pe2 = new PermanentEmployee()
                {
                    ID = 2,
                    FirstName = "Paul",
                    LastName = "Fisher",
                    MonthlySalary = 600
                };
                _pe2.AnnualSalary = _pe.GetAnnualSalary();
                _empList.Add(_pe2);

                ContractEmployee _ce = new ContractEmployee()
                {
                    ID = 3,
                    FirstName = "Naveen",
                    LastName = "Donepudi",
                    HourlySalary = 8
                };
                _ce.AnnualSalary = _ce.GetAnnualSalary();
                _empList.Add(_ce);

                ContractEmployee _ce2 = new ContractEmployee()
                {
                    ID = 4,
                    FirstName = "Viswanath",
                    LastName = "Mannam",
                    HourlySalary = 10
                };
                _ce2.AnnualSalary = _ce2.GetAnnualSalary();
                _empList.Add(_ce2);

            }
            //return JsonConvert.SerializeObject(_empList);
            Employees employees = new Employees();
            employees.employeeList = _empList;
            return employees;
        }
        public IEmployeeManager GetEmployeeManager(int employeeTypeId)
        {
            IEmployeeManager returnValue = null;

            if (employeeTypeId == 1)
            {
                returnValue = new PermanentEmployee();
            }
            else if (employeeTypeId == 2)
            {
                returnValue = new TemporaryEmployee();
            }
            return(returnValue);
        }