public JsonResult GetGridTileEmployees(int pageNumber) { int offSet = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["appTableOffSet"]); int skipRows = (pageNumber - 1) * offSet; using (var dbCntx = new HrDataContext()) { var context = new HttpContextWrapper(System.Web.HttpContext.Current); var query = dbCntx.usp_EmployeeDetail(BRANCHID, ROLECODE); var list = query.OrderByDescending(x => x.EmployeeId) .Skip(skipRows) .Take(offSet) .ToList() .AsEnumerable(); var totalCount = dbCntx.usp_EmployeeDetail(BRANCHID, ROLECODE).Count(); decimal pagerLength = decimal.Divide(Convert.ToDecimal(totalCount), Convert.ToDecimal(offSet)); decimal pagnationRound = Math.Ceiling(Convert.ToDecimal(pagerLength)); var empDirectoryVm = new EmpDirectoryResultVm { employeeVm = list, empSearch = new EmpSearch { }, count = totalCount, PagerLength = pagnationRound }; return(Json(empDirectoryVm, JsonRequestBehavior.AllowGet)); } }
public void Add(Branch entity) { try { using (HrDataContext dbContext = new HrDataContext()) { Branch branch = dbContext.Branches .Where(x => x.BranchID == entity.BranchID).FirstOrDefault(); if (branch == null) { dbContext.Branches.Add(entity); } else { branch.BranchCode = entity.BranchCode; branch.BranchName = entity.BranchName; branch.RegNo = entity.RegNo; branch.CompanyCode = entity.CompanyCode; branch.CompanyId = entity.CompanyId; branch.BranchTaxCode = entity.BranchTaxCode; branch.SSFNumber = entity.SSFNumber; branch.TaxIdNumber = entity.TaxIdNumber; } dbContext.SaveChanges(); } } catch (Exception ex) { throw ex; } }
internal void AddLeave(int empId) { using (HrDataContext dbContext = new HrDataContext()) { Leave leave = dbContext.Leaves.Where(x => x.BranchId == sessionObj.BRANCHID).FirstOrDefault(); LeaveTransaction leavetrasaction = new LeaveTransaction() { BranchId = sessionObj.BRANCHID, CreatedBy = sessionObj.USERID, CreatedOn = UTILITY.SINGAPORETIME, CurrentCasualLeaves = leave.CasualLeavesPerMonth.Value, CurrentPaidLeaves = leave.PaidLeavesPerMonth.Value, CurrentSickLeaves = leave.SickLeavesPerMonth.Value, EmployeeId = empId, FromDt = UTILITY.SINGAPORETIME, ToDt = UTILITY.SINGAPORETIME, PreviousCasualLeaves = leave.CasualLeavesPerMonth.Value, PreviousPaidLeaves = leave.PaidLeavesPerMonth.Value, PreviousSickLeaves = leave.SickLeavesPerMonth.Value, ModifiedBy = sessionObj.USERID, ModifiedOn = UTILITY.SINGAPORETIME, }; Add(leavetrasaction); } }
public ActionResult EmployeeDelete(int EmployeeId) { using (var dbCntx = new HrDataContext()) { var result = dbCntx.usp_EmployeeDelete(BRANCHID, EmployeeId); } return(RedirectToAction("employeedirectory")); }