public string ActionCancel(string selectedIds) { using (var context = new VnrHrmDataContext()) { string message = string.Empty; var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repo = new Hre_HDTJobRepository(unitOfWork); List<Guid> lstIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList(); var lstHDTJobs = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList(); foreach (var HDTJob in lstHDTJobs) { HDTJob.Status = HDTJobStatus.E_CANCEL.ToString(); } repo.SaveChanges(); message = NotificationType.Success.ToString(); return message; } }
public string ActionApprovedForHDTJobWaiting(string selectedIds, string userLG) { string message = string.Empty; Guid userID = Guid.Empty; Guid.TryParse(userLG, out userID); if (userID == Guid.Empty) { message = "Bạn Không Có Quyền Duyệt HDTJob"; return message; } using (var context = new VnrHrmDataContext()) { var unitOfWork = (IUnitOfWork)(new UnitOfWork(context)); var repo = new Hre_HDTJobRepository(unitOfWork); var repoSys_UserApprove = new CustomBaseRepository<Sys_UserApprove>(unitOfWork); List<Guid> lstIds = selectedIds.Split(',').Select(x => Guid.Parse(x)).ToList(); var lstHDTJobs = repo.FindBy(m => m.ID != null && lstIds.Contains(m.ID)).ToList(); int suc = 0; int nop = 0; var checkPermission = repoSys_UserApprove.FindBy(s => s.IsDelete == null && s.Type == ApproveType.E_HDTJOB_PAST.ToString() && s.UserApproveID == userID).ToList(); foreach (var HDTJob in lstHDTJobs) { if (DateTime.Now.Date <= HDTJob.DateFrom.Value.Date) { suc += 1; HDTJob.Status = HDTJobStatus.E_APPROVE.ToString(); repo.Edit(HDTJob); } else { if (checkPermission.Count > 0) { suc += 1; HDTJob.Status = HDTJobStatus.E_APPROVE.ToString(); repo.Edit(HDTJob); } else { nop += 1; } } } repo.SaveChanges(); if (nop > 0 && suc > 0) { message = "Duyệt Thành Công [ " + suc + " ] Dòng HDTJob Và Bạn Không Có Quyền Duyệt [ " + nop + " ] Dòng HDTJob Trong Quá Khứ"; return message; } else if (suc > 0) { message = "Bạn Đã Duyệt Thành Công [ " + suc + " ] Dòng HDTJob"; return message; } else if (nop > 0) { message = "Bạn Không Có Quyền Duyệt [ " + nop + " ] Dòng HDTJob Trong Quá Khứ"; return message; } message = NotificationType.Success.ToString(); return message; } }