public void Remove(Employee employee)
 {
     using (var context = _dbContextFactory.Create())
     {
         context.Employees.Remove(employee);
         context.SaveChanges();
     }
 }
        public void Remove(Employee employee)
        {
            using (var session = _sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.Delete(employee);
                    transaction.Commit();
                }
            }

        }
 public Employee Save(Employee employee)
 {
     using (var session = _sessionFactory.OpenSession())
     {
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(employee);
             transaction.Commit();
             return employee;
         }
     }
 }
        public Employee Save(Employee employee)
        {
            using (var context = _dbContextFactory.Create())
            {
                if (employee.Id == new Guid())
                {
                    employee.Id = Guid.NewGuid();
                }

                context.Employees.AddOrUpdate(employee);
                context.SaveChanges();
                return employee;
            }
        }
        public void CalculateTax_SalaryLessThen1000_TaxIs10perc_Test()
        {
            // Arrange
            var employee = new Employee
            {
                Salary = 900
            };
            var calc = new FiscalCalc();

            // Act
            var tax = calc.CalculateTax(new[] {employee});

            // Assert
            Assert.AreEqual(tax, 90);
        }
        public void CalculateTax_SumDifferentTaxes_Test()
        {
            // Arrange
            var junior = new Employee { Salary = 900 };
            var middle = new Employee { Salary = 5000 };
            var senior = new Employee { Salary = 100000 };

            var calc = new FiscalCalc();

            // Act
            var tax = calc.CalculateTax(new[] { junior, middle, senior });

            // Assert
            Assert.AreEqual(tax, 36340);
        }
Esempio n. 7
0
        public void Demo()
        {
            var coder = new Employee
            {
                Name = "Dmitry",
                Surname = "Kozhevnikov",
                Patronymic = "Olegovich",
                Salary = 1000,
                IsInStaff = true
            };

            var middleManager = new Employee
            {
                Name = "Alexei",
                Surname = "Volkov",
                Patronymic = "Genadievich",
                Salary = 2000,
                IsInStaff = true
            };

            var owner = new Employee
            {
                Name = "Smith",
                Surname = "John",
                Patronymic = "John",
                Salary = 10000,
                IsInStaff = true
            };

            _employeeRepository.Save(coder);
            _employeeRepository.Save(middleManager);
            _employeeRepository.Save(owner);

            foreach (var employee in _employeeRepository.SelectStaff())
            {
                Console.WriteLine(employee);
            }

            var tax = _fiscalFacade.CalculateAllTax();

            Console.WriteLine("The tax is [{0}]", tax.ToString("C"));
            Console.ReadLine();
        }
 public void Remove(Employee employee)
 {
     _employeeRepository.Remove(employee);
 }
 public Employee Save(Employee employee)
 {
     return _employeeRepository.Save(employee);
 }
 public void Remove(Employee employee)
 {
     _employeeService.Remove(employee);
 }
 public Employee Save(Employee employee)
 {
     return _employeeService.Save(employee);
 }