public async Task <IActionResult> UpdatePayScale(IndexPayScalesListVM obj) { try { if (obj.PayScales != null) { var PayScales = new UpdatePayScale_PayScales() { Id = obj.PayScales.Id, StaffId = obj.PayScales.StaffId, BasicSalary = obj.PayScales.BasicSalary, Year = obj.PayScales.Year, BasicSalaryTermNo = obj.PayScales.BasicSalaryTermNo, BonusSalary = obj.PayScales.BonusSalary, BonusSalaryTermNo = obj.PayScales.BonusSalaryTermNo }; var model = new UpdatePayScale() { PayScales = PayScales }; await Task.Run(() => _PayScalesServ.UpdatePayScale(model)); } } catch (Exception) { return(BadRequest()); } return(RedirectToAction("PayScalesList")); }
public async Task <IActionResult> PayScalesList(int pg = 1) { try { var PayScalesList = Task.Run(() => _PayScalesServ.getPayScalesList()); var result = await PayScalesList; ViewBag.ddlStaff = _StaffsServ.dropdown_Staffs(); ViewBag.ddlDesignation = _DesignationsServ.dropdown_Designations(); var list = new List <IndexPayScalesListVM_PayScales>(); foreach (var item in result._PayScales.ToList()) { var temp = new IndexPayScalesListVM_PayScales() { Id = item.Id, StaffId = item.StaffId, StaffName = item.StaffName, DesignationName = item.DesignationName, BasicSalary = item.BasicSalary, SalaryYear = item.SalaryYear, BasicSalaryTermNo = item.BasicSalaryTermNo, BonusSalary = item.BonusSalary, BonusSalaryTermNo = item.BonusSalaryTermNo }; list.Add(temp); } ; #region "Paging" const int pageSize = 5; if (pg < 1) { pg = 1; } int recsCount = list.Count(); var pager = new Pager(recsCount, pg, pageSize); int recSkip = (pg - 1) * pageSize; var data = list.Skip(recSkip).Take(pager.PageSize).ToList(); this.ViewBag.Pager = pager; var model = new IndexPayScalesListVM() { _PayScales = data, }; #endregion "Paging" return(View("PayScalesList", model)); } catch (Exception) { return(BadRequest()); } }