public Boolean AddEmployeeSalary(EmployeeSalaryVM model) { return(EmployeeVM.AddEmployeeSalary(model)); }
public IActionResult EmployeeSalaryList() { if (HttpContext.Session.GetString("UserRole") == "1" || HttpContext.Session.GetString("UserRole") == "2" && HttpContext.Session.GetString("UserRole") != "Expired") { var e = db.Employee.AsNoTracking().ToList(); var a = db.Attendance.AsNoTracking().ToList(); var emps = db.EmployeeSalary.AsNoTracking().ToList(); var i = new List <EmployeeSalaryVM>(); var query = (from es in emps join employee in e on es.EmployeeId equals employee.EmployeeId join at in a on es.AttendanceId equals at.AttendanceId select new { employeeid = employee.EmployeeId, firstname = employee.FirstName, lastname = employee.LastName, attendanceid = at.AttendanceId, loginduration = at.LoginDuration, salaryid = es.SalaryId, basicsalary = es.BasicSalary, tax = es.Tax / 100, benifits = es.Benifits, hourprice = es.HourPrice, totalhourPrice = at.LoginDuration * es.HourPrice, withdraw = es.Withdraw, netsalary = ((es.BasicSalary + es.Benifits) - es.Tax), paymentstatus = (es.NetSalary - es.Withdraw) }); foreach (var item in query) { EmployeeSalaryVM es = new EmployeeSalaryVM(); { es.EmployeeId = item.employeeid; es.FirstName = item.firstname; es.LastName = item.lastname; es.AttendanceId = item.attendanceid; es.LoginDuration = item.loginduration; es.SalaryId = item.salaryid; es.BasicSalary = item.basicsalary; es.Tax = item.tax; es.Benifits = item.benifits; es.HourPrice = item.hourprice; es.TotalHourPrice = item.totalhourPrice; es.Withdraw = item.withdraw; es.NetSalary = Convert.ToInt32(item.netsalary + item.totalhourPrice); es.PaymentStatus = Convert.ToInt32(item.paymentstatus); } i = i.GroupBy(x => x.EmployeeId).Select(x => x.First()).ToList(); i.Add(es); } return(View(i)); } else { return(RedirectToAction("Index", "Home")); } }