public static EmployeeSalaryViewModel GetById(int id) { EmployeeSalaryViewModel result = new EmployeeSalaryViewModel(); using (var db = new PayrollContext()) { result = (from e in db.EmployeeSalary join p in db.PayrollPeriod on e.PayrollPeriodId equals p.Id join s in db.SalaryComponent on e.SalaryComponentId equals s.Id select new EmployeeSalaryViewModel { Id = e.Id, BadgeId = e.BadgeId, PayrollPeriodId = e.PayrollPeriodId, PeriodMonth = p.PeriodMonth, PeriodYear = p.PeriodYear, SalaryComponentId = e.SalaryComponentId, SalaryComponentName = s.Description, BasicValue = e.BasicValue, FinalValue = e.FinalValue, IsActivated = e.IsActivated } ).FirstOrDefault(); } return(result); }
private async Task <EmployeeSalaryViewModel> CalculateEmployeeSalary(EmployeeSalaryViewModel employeeSalaryViewModel) { EmployeeSalaryViewModel evm = new EmployeeSalaryViewModel(); evm.TotalNoOfHoursWorked = 0; evm.Salary = 0; DateTime monthStartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var todaysDateandTime = DateTime.Now; var currentDate = todaysDateandTime.Date; //Selecting Employee matches accessCode var dtemployeeList = await this.employeeService.GetEmployeeDetailsByaccessCode(employeeSalaryViewModel.AccessCode); //Getting Data from EmployeeTask(SalaryData) by passing EmployeeId and startDate var empSalaryData = await this.employeeTaskService.GetEmpHourCapacityOfTheDate(dtemployeeList.EmployeeId, monthStartDate, currentDate); evm.FullName = dtemployeeList.FirstName + " " + dtemployeeList.Surname; evm.StartDate = monthStartDate; evm.EndDate = currentDate; //Calculating the Employee Salary foreach (var item in empSalaryData) { evm.TotalNoOfHoursWorked += item.TotalNoOfHours; evm.Salary = (decimal)(evm.Salary + (item.TotalNoOfHours * item.PayPerTask)); } return(evm); }
public ActionResult Save(EmployeeSalaryViewModel obj) { // IEnumerable<EmployeeSalaryViewModel> en = customerDueFeesList; // en = jss.Deserialize<IEnumerable<EmployeeSalaryViewModel>>(obj.EmployeeSalaryViewModelList); List <EmployeeSalaryViewModel> employeeSalaryViewModelList; JavaScriptSerializer jss = new JavaScriptSerializer(); EmployeeSalary employeeSalary = new EmployeeSalary(); employeeSalaryViewModelList = jss.Deserialize <List <EmployeeSalaryViewModel> >(obj.SalaryList); foreach (var employeeSalaryViewModel in employeeSalaryViewModelList) { if (employeeSalaryViewModel.FullName == null) { //for the last row of table } else { employeeSalary.FullName = employeeSalaryViewModel.FullName; employeeSalary.WorkHours = employeeSalaryViewModel.WorkHours; employeeSalary.RatePerHour = employeeSalaryViewModel.RatePerHour; employeeSalary.OverTimeHours = employeeSalaryViewModel.OverTimeHours; employeeSalary.RatePerHourOvertime = employeeSalaryViewModel.RatePerHourOvertime; employeeSalary.Date = employeeSalaryViewModel.Date; employeeSalary.SalaryId = employeeSalaryViewModel.SalaryId; _dbContext.EmployeeSalaries.Add(employeeSalary); _dbContext.SaveChanges(); } } return(Json(new { success = true })); }
public static EmployeeSalaryViewModel GetById(int id) { EmployeeSalaryViewModel result = new EmployeeSalaryViewModel(); using (var db = new PayrollContext()) { result = (from d in db.EmployeeSalary join pp in db.PayrollPeriod on d.PayrollPeriodId equals pp.Id join sc in db.SalaryComponent on d.SalaryComponentId equals sc.Id where d.Id == id select new EmployeeSalaryViewModel { Id = d.Id, BadgeId = d.BadgeId, PayrollPeriodId = d.PayrollPeriodId, SalaryComponentCode = sc.Code, SalaryComponentName = sc.Description, SalaryComponentId = d.SalaryComponentId, BasicValue = d.BasicValue, FinalValue = d.FinalValue, IsActivated = d.IsActivated }).FirstOrDefault(); } return(result); }
public async Task <ActionResult> ViewTotalDuetoEmployee() { EmployeeSalaryViewModel employeeSalaryViewModel = new EmployeeSalaryViewModel(); await GetAllEmployees(employeeSalaryViewModel); employeeSalaryViewModel.DispalyGrid = false; return(View(employeeSalaryViewModel)); }
public ActionResult RemoveComponent(string bId, int scId) { List <EmployeeSalaryViewModel> models = EmployeeSalaryRepo.GetByBadgeId(bId, scId); if (models.Count > 0) { EmployeeSalaryViewModel model = models[0]; return(PartialView("_RemoveComponent", model)); } return(PartialView("_RemoveComponent", new EmployeeSalaryViewModel())); }
public ActionResult GetSalaryComponent(int jobPositionId, int salaryComponentId) { EmployeeSalaryViewModel model = EmployeeSalaryRepo.GetByComponentId(salaryComponentId); SalaryDefaultValueViewModel sd = SalaryDefaultValueRepo.GetByJobPosition(jobPositionId, salaryComponentId); if (sd != null) { model.BasicValue = sd.Value; } return(PartialView("_GetSalaryComponent", model)); }
public ActionResult Edit(EmployeeSalaryViewModel model) { if (ModelState.IsValid) { Responses responses = EmployeeSalaryRepo.Update(model); if (responses.Success) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = "Error msg" }, JsonRequestBehavior.AllowGet)); } } return(Json(new { success = false, message = "Invalid" }, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(EmployeeSalaryViewModel model) { if (ModelState.IsValid) { Responses responses = EmployeeSalaryRepo.Update(model); if (responses.Success) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = responses.Message }, JsonRequestBehavior.AllowGet)); } } return(Json(new { success = false, message = ModelState.ToString() }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Calculates employee salary by month for the given employee to be used in statistics view /// </summary> /// <param name="username"></param> /// <returns><see cref="EmployeeSalaryViewModel"/></returns> public async Task <EmployeeSalaryViewModel> EmployeeSalary(string username) { var user = await _employeeRepository.GetEmployeeWithPaymentsAsync(username); var payments = user.Payments.Where(p => p.Year == DateTime.Now.Year).OrderBy(p => p.Month); EmployeeSalaryViewModel model = new EmployeeSalaryViewModel { TotalPay = payments.Select(p => p.TotalPay).ToArray(), OvertimePay = payments.Select(p => p.OverTimePay).ToArray(), NormalPay = payments.Select(p => p.NormalPay).ToArray(), MonthNames = CultureInfo.CreateSpecificCulture("en-GB").DateTimeFormat.MonthNames }; return(model); }
public static Responses Update(EmployeeSalaryViewModel entity) { Responses result = new Responses(); try { using (var db = new PayrollContext()) { if (entity.Id != 0) { EmployeeSalary employeesalary = db.EmployeeSalary.Where(o => o.Id == entity.Id).FirstOrDefault(); if (employeesalary != null) { employeesalary.BadgeId = entity.BadgeId; employeesalary.PayrollPeriodId = entity.PayrollPeriodId; employeesalary.SalaryComponentId = entity.SalaryComponentId; employeesalary.BasicValue = entity.BasicValue; employeesalary.FinalValue = entity.FinalValue; employeesalary.IsActivated = entity.IsActivated; employeesalary.ModifyBy = "Azam"; employeesalary.ModifyDate = DateTime.Now; db.SaveChanges(); } } else { EmployeeSalary employeesalary = new EmployeeSalary(); employeesalary.BadgeId = entity.BadgeId; employeesalary.PayrollPeriodId = entity.PayrollPeriodId; employeesalary.SalaryComponentId = entity.SalaryComponentId; employeesalary.BasicValue = entity.BasicValue; employeesalary.FinalValue = entity.FinalValue; employeesalary.IsActivated = entity.IsActivated; employeesalary.CreateBy = "Azam"; employeesalary.CreateDate = DateTime.Now; db.EmployeeSalary.Add(employeesalary); db.SaveChanges(); } } } catch (Exception ex) { result.Message = ex.Message; result.Success = false; } return(result); }
public async Task <ActionResult> GetEmployeeSalary(EmployeeSalaryViewModel employeeSalaryViewModel) { _logger.LogInformation("View total due over a specific timeframe"); try { EmployeeSalaryViewModel evm = await CalculateEmployeeSalary(employeeSalaryViewModel); return(View(evm)); } catch (Exception ex) { _logger.LogError("Error Getting Employee Salary {0}", ex.Message); return(View(ex.InnerException.Message)); } }
public static EmployeeSalaryViewModel GetByComponentId(int id) { EmployeeSalaryViewModel result = new EmployeeSalaryViewModel(); using (var db = new PayrollContext()) { result = (from sc in db.SalaryComponent where sc.Id == id select new EmployeeSalaryViewModel { Id = sc.Id, SalaryComponentId = sc.Id, SalaryComponentCode = sc.Code, SalaryComponentName = sc.Description }).FirstOrDefault(); } return(result); }
public async Task <ActionResult> ViewTotalDuetoEmployee(int EmployeeId, DateTime startDate, DateTime endDate) { _logger.LogInformation("View total due over a specific timeframe"); EmployeeSalaryViewModel evm = new EmployeeSalaryViewModel(); try { await GetTotalDue(EmployeeId, startDate, endDate, evm); return(View(evm)); } catch (Exception ex) { _logger.LogError("Error Retrieving View total due of Employee {0}", ex.Message); return(View(ex.InnerException.Message)); } }
// PUT api/<controller>/5 public Responses Put(int id, [FromBody] EmployeeSalaryViewModel entity) { entity.Id = id; return(EmployeeSalaryRepo.Update(entity)); }
// POST api/<controller> public Responses Post([FromBody] EmployeeSalaryViewModel entity) { return(EmployeeSalaryRepo.Update(entity)); }
public ActionResult Edit(Guid?id, DateTime?date) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var employeeAttendences = _dbContext.EmployeeAttendences.Where(a => a.Date == date).ToList(); if (employeeAttendences == null) { return(HttpNotFound()); } SalaryViewModel salaryViewModel = new SalaryViewModel(); salaryViewModel.Date = date; decimal?grandTotalWorkHours = 0; decimal?grandTotalOverTimeHours = 0; List <EmployeeSalaryViewModel> viewModelList = new List <EmployeeSalaryViewModel>(); foreach (var attendence in employeeAttendences) { EmployeeSalaryViewModel empSalaryViewModel = new EmployeeSalaryViewModel(); var workHours = attendence.WorkHours; empSalaryViewModel.WorkHours = workHours; var overTimeHours = attendence.OverTimeHours; empSalaryViewModel.OverTimeHours = overTimeHours; var empId = attendence.EmployeeId; var employee = _dbContext.Contacts.Where(a => a.Id == empId).FirstOrDefault(); var employeeSalaryDetails = _dbContext.EmployeeSalaryDetails.Where(a => a.ContactId == empId).FirstOrDefault(); if (employeeSalaryDetails == null) { empSalaryViewModel.RatePerHour = null; empSalaryViewModel.RatePerHourOvertime = null; empSalaryViewModel.FullName = employee.FullName; } else { var ratePerHour = employeeSalaryDetails.RatePerHour; empSalaryViewModel.RatePerHour = ratePerHour; var totalWorkHour = ratePerHour * workHours; empSalaryViewModel.WorkHourTotal = totalWorkHour; var rateOverTime = employeeSalaryDetails.RatePerHourOvertime; empSalaryViewModel.RatePerHourOvertime = rateOverTime; var totalOverTime = overTimeHours * rateOverTime; empSalaryViewModel.OverTimeTotal = totalOverTime; grandTotalOverTimeHours = totalOverTime + grandTotalOverTimeHours; grandTotalWorkHours = totalWorkHour + grandTotalWorkHours; empSalaryViewModel.FullName = employee.FullName; } salaryViewModel.GrandTotalWorkHours = grandTotalWorkHours; salaryViewModel.GrandTotalOverTimeHours = grandTotalOverTimeHours; // empSalaryViewModel.RatePerHour =; viewModelList.Add(empSalaryViewModel); salaryViewModel.EmployeeSalaryViewModel = viewModelList; } return(View(salaryViewModel)); }
private async Task GetAllEmployees(EmployeeSalaryViewModel employeeSalaryViewModel) { var employeeList = await this.employeeService.GetEmployees(); employeeSalaryViewModel.Employees = employeeList; }
private async Task GetTotalDue(int EmployeeId, DateTime startDate, DateTime endDate, EmployeeSalaryViewModel evm) { evm.TotalNoOfHoursWorked = 0; evm.Salary = 0; var dtoEmpTask = await this.employeeTaskService.GetEmpHourCapacityOfTheDate(EmployeeId, startDate, endDate); var dtemployeeList = await this.employeeService.GetEmployeeById(dtoEmpTask.Select(x => x.EmployeeId).FirstOrDefault()); evm.FullName = dtemployeeList.FirstName + " " + dtemployeeList.Surname; evm.DispalyGrid = true; //Calculating the Employee Salary foreach (var item in dtoEmpTask) { evm.TotalNoOfHoursWorked += item.TotalNoOfHours; evm.Salary = (decimal)(evm.Salary + (item.TotalNoOfHours * item.PayPerTask)); } }