public async Task Update(BonusToSalaryBll elementToUpdate) { bonusToSalary bonus = Mapper.Map <BonusToSalaryBll, bonusToSalary>(elementToUpdate); _unitOfWork.BonusToSalaryUnitOfWork.Update(bonus); await _unitOfWork.Save(); }
public async Task Insert(BonusToSalaryBll element) { bonusToSalary bonus = Mapper.Map <BonusToSalaryBll, bonusToSalary>(element); _unitOfWork.BonusToSalaryUnitOfWork.Insert(bonus); await _unitOfWork.Save(); }
public async Task CloseShift(int idPositionServises) { var position = await _position.ChoiceEmployees(idPositionServises); var ordersFulfilled = await _orderCarWashWorkers.SampleForPayroll(DateTime.Now); List <EmployeeDaySummary> employeeDaySummaryList = new List <EmployeeDaySummary>(); foreach (var item in ordersFulfilled.GroupBy(g => g.IdCarWashWorkers)) { var completedEmployeeOrders = ordersFulfilled.Where(x => x.IdCarWashWorkers == item.Key); var employees = await _premiumAndRate.SelectPosition(item.Key); List <EmployeeDaySummary> bonusList = new List <EmployeeDaySummary>(); foreach (var positionItem in position) { var resultEmployee = employees.SingleOrDefault(x => x.positionId == positionItem.idPosition); if (resultEmployee.servicePremium) { double sum = completedEmployeeOrders .Where(x => x.typeServicesId == positionItem.idPosition) .Sum(s => s.Payroll).Value; bonusList.Add(new EmployeeDaySummary { carWashWorkersId = item.Key, SumOrder = sum, percent = resultEmployee.multiplicityOfTheSum.Value, prizeAmount = resultEmployee.prizeAmount }); } } double prizeAmiutSum = bonusList.Sum(x => x.prizeAmount.Value); double percentSum = bonusList.Sum(x => x.percent.Value); double orderSum = bonusList.Sum(x => x.SumOrder.Value); int countServeses = bonusList.Count(); double averagePrize = Average(prizeAmiutSum, countServeses); double averagePercent = Average(percentSum, countServeses); double bonusResult = MathFloor(orderSum, averagePercent); if (bonusResult > 0) { BonusToSalaryBll bonusToSalary = new BonusToSalaryBll(); bonusToSalary.amount = bonusResult * averagePrize; bonusToSalary.carWashWorkersId = item.Key; bonusToSalary.date = DateTime.Now; await InsertTableBonus(bonusToSalary); } } }
public async Task <ActionResult> Create([Bind(Include = "idBonusToSalary,carWashWorkersId,amount,date,note")] BonusToSalaryView bonusToSalaryView) { if (ModelState.IsValid) { BonusToSalaryBll bonusToSalaryBll = Mapper.Map <BonusToSalaryView, BonusToSalaryBll>(bonusToSalaryView); await _bonusToSalary.Insert(bonusToSalaryBll); return(RedirectToAction("Index")); } ViewBag.carWashWorkersId = new SelectList(Mapper.Map <IEnumerable <CarWashWorkersView> >(await _carWashWorkers.GetTable()), "id", "Name"); return(View(bonusToSalaryView)); }
public async Task PremiumAccrual(int carWashWorkers, double payroll) { BonusToSalaryBll bonusToSalaryResult = new BonusToSalaryBll(); double bonusStart = 1500; double bonusRresult = Math.Floor(payroll / bonusStart); if (bonusRresult > 0) { bonusToSalaryResult.amount = bonusRresult * 50; bonusToSalaryResult.carWashWorkersId = carWashWorkers; bonusToSalaryResult.date = DateTime.Now; bonusToSalaryResult.note = $"Премия за кассу { payroll }"; await _bonus.Insert(bonusToSalaryResult); } }
private async Task <bool> InsertTableBonus(BonusToSalaryBll bonusToSalary) { await _bonus.Insert(bonusToSalary); return(true); }