public async Task <ActionResult> LichSuChamCongList(string employeeId) { var nhatKyLamViec = await nhatKylamViecRepository.FindByMaNhanVien(employeeId); var lichSuChamCongVMs = mapper.Map <IEnumerable <LichSuChamCongVM> >(nhatKyLamViec); var leaveRequests = (await leaveRequestRepository.FindAll()) .Where(q => q.RequestingEmployeeId == employeeId && q.StartDate.CompareTo(DateTime.Now) <= 0 && q.Approved == true ); // nghĩa là ngày bắt đầu nhỏ hơn ngày hiện tại và đã được chấp thuận => yêu cầu nghỉ phép đã được thực thi var leaveRequestVMs = mapper.Map <IEnumerable <LeaveRequestVM> >(leaveRequests); foreach (var record in lichSuChamCongVMs) { int soPhut = (int)(record.ThoiGianKetThuc - record.ThoiGianBatDau).TotalMinutes; record.TongLuongCoBan = (int)((double)record.MucLuongCoBan / (6 * 4 * 8 * 60) * record.HeSoLuongCoBan * soPhut); record.TongTienLuong = record.TongLuongCoBan + record.SoTienThuongThem; } var employee = mapper.Map <EmployeeVM>(await userManager.FindByIdAsync(employeeId)); var model = new NhatKyLamViecVM { LeaveRequestVMs = leaveRequestVMs, LichSuChamCongVMs = lichSuChamCongVMs, NhanVien = employee }; return(View(model)); }
// GET: LeaveRequest public ActionResult Index() { var leaveRequests = _leaveRequestRepository.FindAll(); var leaveRequestsModel = _mapper.Map <List <LeaveRequestViewModel> >(leaveRequests); var model = new AdminLeaveRequestViewModel { TotalRequests = leaveRequestsModel.Count, ApprovedRequests = leaveRequestsModel.Count(x => x.Approved == true), PendingRequests = leaveRequestsModel.Count(x => x.Approved == null), RejectedRequest = leaveRequestsModel.Count(x => x.Approved == false), LeaveRequests = leaveRequestsModel }; return(View(model)); }
public async Task <ActionResult> Index() { var leaveRequests = await _leaverequestrepo.FindAll(); var leaveRequestsModel = _mapper.Map <List <LeaveRequestViewModel> >(leaveRequests); var model = new AdminLeaveRequestViewModel { TotalRequests = leaveRequestsModel.Count, ApprovedRequests = leaveRequestsModel.Count(q => q.Approved == true), PendingRequests = leaveRequestsModel.Count(q => q.Approved == null), RejectedRequests = leaveRequestsModel.Count(q => q.Approved == false), LeaveRequests = leaveRequestsModel }; return(View(model)); }
// GET: LeaveRequest public ActionResult Index() { var leaveRequests = _leaveRequestRepo.FindAll(); var leaveRequstsModel = _mapper.Map <List <LeaveRequestVM> >(leaveRequests); var model = new AdminLeaveRequestViewVM { LeaveRequests = leaveRequstsModel }; return(View(model)); }
// GET: LeaveRequestController public async Task <ActionResult> Index() { var truongPhong = _mapper.Map <EmployeeVM>(_userManager.GetUserAsync(User).Result); var phongBan = _mapper.Map <PhongBansVM>(await phongBanRepository.FindById(truongPhong.MaPhongBan)); ICollection <LeaveRequest> leaveRequests = null; if (User.IsInRole("Quản trị viên")) { leaveRequests = (await _leaveRequestRepo.FindAll()); } else { leaveRequests = (await _leaveRequestRepo.FindAll()) .Where(q => q.RequestingEmployee.MaPhongBan == phongBan.MaPhongBan) .ToList(); } var leaveRequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaveRequests); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequestsModel.Count, ApprovedRequets = leaveRequestsModel .Count(q => q.Approved == true), PendingRequests = leaveRequestsModel .Count(q => q.Approved == null), RejectedRequests = leaveRequestsModel .Count(q => q.Approved == false), CancelledRequests = leaveRequestsModel .Count(q => q.Cancelled == true), LeaveRequests = leaveRequestsModel, PhongBan = phongBan, TruongPhong = truongPhong }; return(View(model)); }
public async Task <ActionResult> Index() { var requests = _mapper.Map <List <LeaveRequestViewModel> >(await _requestRepo.FindAll()); var model = new AdminLeaveRequestViewModel { TotalRequests = requests.Count, ApprovedRequests = requests.Count(q => q.Approved == true), PendingRequests = requests.Count(q => q.Approved == null), RejecetdRequests = requests.Count(q => q.Approved == false), LeaveRequests = requests }; return(View(model)); }
// GET: LeaveRequest public ActionResult Index() { var leaveRequests = _mapper.Map <List <LeaveRequestVM> >(_requestRepo.FindAll()); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequests.Count, ApprovedRequests = leaveRequests.Count(r => r.Approved == true), PendingRequests = leaveRequests.Count(r => !r.Approved.HasValue), RejectedRequests = leaveRequests.Count(r => r.Approved == false), LeaveRequests = leaveRequests }; return(View(model)); }
public ActionResult Index() { var leaverequests = _leaveRequestRepo.FindAll(); var leaverequestmodel = _mapper.Map <List <LeaveRequestVM> >(leaverequests); var model = new AdminLeaveRequestVM { TotalRequests = leaverequestmodel.Count, ApprovedRequests = leaverequestmodel.Where(s => s.Approved == true).Count(), PendingRequests = leaverequestmodel.Where(s => s.Approved == null).Count(), RejectedRequests = leaverequestmodel.Where(s => s.Approved == false).Count(), LeaveRequests = leaverequestmodel }; return(View(model)); }
// GET: LeaveTypesController/Delete/5 public async Task <ActionResult> Delete(int id) { if (!await _repo.isExists(id)) { return(NotFound()); } var leavetype = await _repo.FindById(id); if (leavetype == null) { return(NotFound()); } var isSuccess = await _repo.Delete(leavetype); if (!isSuccess) { return(BadRequest()); } var allocation = await _AlloRepo.FindAll(); if (allocation != null) { var AlloToDetete = allocation.ToList().Where(Q => Q.LeaveTypeId == id); foreach (var item in AlloToDetete) { await _AlloRepo.Delete(item); } } var request = await _requestRepo.FindAll(); if (allocation != null) { var requestToDetete = request.ToList().Where(Q => Q.LeaveTypeId == id); foreach (var item in requestToDetete) { await _requestRepo.Delete(item); } } return(RedirectToAction(nameof(Index))); }
public ActionResult Index() { var leaveRequests = _repo.FindAll(); var leaveRequestVM = _mapper.Map <List <LeaveRequestViewModel> >(leaveRequests); var model = new AdminLeaveRequestViewModel { TotalRequest = leaveRequestVM.Count(), ApprovedRequest = leaveRequestVM.Count(q => q.Approved == true), PendingRequest = leaveRequestVM.Count(q => q.Approved == null), RejectedRequest = leaveRequestVM.Count(q => q.Approved == false), LeaveRequests = leaveRequestVM }; return(View(model)); }
// GET: LeaveRequest public async Task <ActionResult> Index() { var leaverequests = await _leaveRequestRepo.FindAll(); var leaveRequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaverequests); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequestsModel.Count, ApprovedRequests = leaveRequestsModel.Count(q => q.Approved == true), //cuento todos los regisrros que cumplen esa condicion PendingRequests = leaveRequestsModel.Count(q => q.Approved == null), RejectedRequests = leaveRequestsModel.Count(q => q.Approved == false), LeaveRequests = leaveRequestsModel }; return(View(model)); }
// GET: LeaveRequest public ActionResult Index() { //Retrieving all the leave request in the Database var leaveRequests = _leaveRequestRepo.FindAll(); var leaveRequestModel = _mapper.Map <List <LeaveRequestViewModel> >(leaveRequests); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequestModel.Count, ApprovedRequests = leaveRequestModel.Count(q => q.Approved == true), PendingRequests = leaveRequestModel.Count(q => q.Approved == null), RejectedRequests = leaveRequestModel.Count(q => q.Approved == false), LeaveRequests = leaveRequestModel }; return(View(model)); }
// GET: LeaveRequest public async Task <ActionResult> Index() { var leaveRequests = await _leaveRequestRepo.FindAll(); var leaveRequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaveRequests); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequestsModel.Count, ApprovedRequests = leaveRequestsModel.Count(lr => lr.Approved == true), PendingRequests = leaveRequestsModel.Count(lr => !lr.Approved.HasValue), RejectedRequests = leaveRequestsModel.Count(lr => lr.Approved == false), LeaveRequests = leaveRequestsModel }; return(View(model)); }
// GET: LeaveRequest public async Task <ActionResult> Index() { //ViewBag.BackgroundImage = "https://res.cloudinary.com/flic-media/image/upload/v1611466925/blank_pvkb9q.webp"; var leaveRequests = await _leaveRequestRepo.FindAll(); var leaveRequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaveRequests); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequestsModel.Count(), ApprovedRequests = leaveRequestsModel.Count(q => q.Approved == true), PendingRequests = leaveRequestsModel.Count(q => q.Approved == null), RejectedRequests = leaveRequestsModel.Count(q => q.Approved == false), LeaveRequests = leaveRequestsModel }; return(View(model)); }
// GET: LeaveRequest public async Task <ActionResult> Index() { var obj = await _repoleaverequest.FindAll(); var leaveRequests = obj.Where(x => x.CancelRequest == false); var leaveRequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaveRequests.ToList()); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequestsModel.Count, //ApprovedRequests = leaveRequestsModel.Where(x => x.Approved == true).Count(), ApprovedRequests = leaveRequestsModel.Count(x => x.Approved == true), PendingRequests = leaveRequestsModel.Where(x => x.Approved == null).Count(), RejectedRequests = leaveRequestsModel.Count(x => x.Approved == false), LeaveRequests = leaveRequestsModel }; return(View(model)); }
// GET: LeaveRequest public async Task <ActionResult> Index()// the landing page { //when the admin want to see the leave requests and total number of each type //need a vm to that lists var leaverequests = await _leaveRequestRepo.FindAll(); //getting them all var leaverequestsmodel = _mapper.Map <List <LeaveRequestVM> > (leaverequests); //mapped to my VM var model = new AdminLeaveRequestViewVM { TotalRequests = leaverequestsmodel.Count, //count property ApprovedRequests = leaverequestsmodel.Where(q => q.Approved == true).Count(), //count function return all like othkor اذكر PendingRequests = leaverequestsmodel.Count(q => q.Approved == null), //same as above RejectedRequests = leaverequestsmodel.Count(q => q.Approved == false), LeaveRequests = leaverequestsmodel }; return(View(model)); }
// GET: LeaveRequest public async Task <ActionResult> Index() { var leaveRequests = await _requestRepo.FindAll(); var leaveRequestsModel = _mapper.Map <List <LeaveRequestViewModel> >(leaveRequests); var model = new AdminLeaveRequestsViewModel { LeaveRequests = leaveRequestsModel.OrderBy(c => !c.Approved.HasValue) .ThenBy(c => c.Approved) .Reverse() .ToList(), TotalRequests = leaveRequestsModel.Count, ApprovedRequests = leaveRequests.Count(x => x.Approved == true), PendingRequests = leaveRequests.Count(x => x.Approved is null), RejectedRequests = leaveRequests.Count(x => x.Approved == false), }; return(View(model)); }
// GET: LeaveRequest public async Task <ActionResult> Index() { var leaveRequests = await _leaveRequestRepo.FindAll(); var leaveReqs = leaveRequests.OrderByDescending(q => q.DateRequested).ThenBy(x => x.RequestingEmployee.Firstname); var leaveRequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaveReqs); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequestsModel.Count, ApprovedRequests = leaveRequestsModel.Where(q => q.Approved == true).Count(), PendingRequests = leaveRequestsModel.Count(q => q.Approved == null && q.Cancelled == false), RejectedRequests = leaveRequestsModel.Count(q => q.Approved == false), CancelledRequests = leaveRequestsModel.Count(q => q.Cancelled == true), LeaveRequests = leaveRequestsModel }; return(View(model)); }
// GET: LeaveRequest public async Task <ActionResult> Index() { var leaveRequests = await _leaveRequestRepo.FindAll(); var leaveRequestsModel = _mapper.Map <List <LeaveRequestVM> >(leaveRequests); var model = new AdminLeaveRequestViewVM { TotalRequests = leaveRequestsModel.Count, ApprovedRequests = 0, PendingRequests = 0, RejectedRequests = 0, LeaveRequests = leaveRequestsModel }; foreach (var m in leaveRequestsModel) { if (m.Approved == null) { model.PendingRequests++; } else if (m.Approved == true) { model.ApprovedRequests++; } else { model.RejectedRequests++; } } //var model = new AdminLeaveRequestViewVM //{ // TotalRequests = leaveRequestsModel.Count, // ApprovedRequests = leaveRequestsModel.Count(t => t.Approved == true), // PendingRequests = leaveRequestsModel.Count(t => t.Approved == null), // RejectedRequests = leaveRequestsModel.Count(t => t.Approved == false), // LeaveRequests = leaveRequestsModel //}; return(View(model)); }
// GET: LeaveRequestController public async Task <ActionResult> Index() { ICollection <LeaveRequest> leaveRequests = await _leaveRequestRepo.FindAll(); List <LeaveRequestViewModel> leaveRequestModel = _mapper .Map <List <LeaveRequestViewModel> >(leaveRequests); AdminLeaveRequestViewViewModel model = new AdminLeaveRequestViewViewModel { ApprovedRequests = leaveRequestModel .Count(q => q.Approved == true), PendingRequests = leaveRequestModel .Count(q => q.Approved == null), RejectedRequests = leaveRequestModel .Count(q => q.Approved == false), TotalRequests = leaveRequestModel.Count, LeaveRequests = leaveRequestModel }; return(View(model)); }