Ejemplo n.º 1
0
        public void EmployeeSalaryRepository_GetEmployeeTest()
        {
            EmployeeSalaryRepository repository = new EmployeeSalaryRepository();
            var employees = repository.GetEmployeeSalary();

            Assert.IsNotNull(employees);
        }
Ejemplo n.º 2
0
        public virtual bool AddBonusToEmployeeList(int departmentId, Bonuses bonus, string employeeIdsList)
        {
            try
            {
                EmployeeSalaryRepository empSalRepo  = new EmployeeSalaryRepository();
                BonusRepository          bonusRepo   = new BonusRepository();
                BonusesRepository        bonusesRepo = new BonusesRepository();

                var idList = employeeIdsList.Trim().Split(',');

                var salaryBonus = from empSal in empSalRepo.GetAll()
                                  join bon in bonusRepo.GetAll() on empSal.BonusId equals bon.BonusId
                                  select new
                {
                    EmployeeId = empSal.EmployeeId,
                    BonusId    = empSal.BonusId
                };

                salaryBonus = salaryBonus.Where(item => idList.Contains(item.EmployeeId.ToString()));

                foreach (var item in salaryBonus)
                {
                    Bonuses bonusesItem = new Bonuses
                    {
                        BonusId          = item.BonusId,
                        BonusValue       = bonus.BonusValue,
                        BonusDescription = bonus.BonusDescription,
                        BonusesDate      = bonus.BonusesDate
                    };
                    bonusesRepo.Insert(bonusesItem);

                    Bonus tempBonus = bonusRepo.Get(item.BonusId);
                    tempBonus.BonusValue += bonus.BonusValue;
                    bonusRepo.Update(tempBonus, item.BonusId);
                }
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public virtual bool AssignBonusToEmployee(Bonuses bonus, int EmployeeId)
        {
            try
            {
                EmployeeSalaryRepository empSalRepo  = new EmployeeSalaryRepository();
                BonusRepository          bonusRepo   = new BonusRepository();
                BonusesRepository        bonusesRepo = new BonusesRepository();


                var salaryBonus = from empSal in empSalRepo.GetAll()
                                  join bon in bonusRepo.GetAll() on empSal.BonusId equals bon.BonusId
                                  select new
                {
                    EmployeeId = empSal.EmployeeId,
                    BonusId    = empSal.BonusId
                };

                salaryBonus = salaryBonus.Where(item => item.EmployeeId == EmployeeId);

                foreach (var item in salaryBonus)
                {
                    Bonuses bonusesItem = new Bonuses
                    {
                        BonusId          = item.BonusId,
                        BonusValue       = bonus.BonusValue,
                        BonusDescription = bonus.BonusDescription,
                        BonusesDate      = bonus.BonusesDate
                    };
                    bonusesRepo.Insert(bonusesItem);

                    Bonus tempBonus = bonusRepo.Get(item.BonusId);
                    tempBonus.BonusValue += bonus.BonusValue;
                    bonusRepo.Update(tempBonus, item.BonusId);
                }
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EmployeeSalaryService"/> class.
 /// </summary>
 public EmployeeSalaryService()
 {
     employeeSalaryRepository = new EmployeeSalaryRepository();
 }