public async Task <ActionResult> ThuHoi(string id) { var phieuchi_luongCuoiThang = await phieuChi_LuongCuoiThangRepository.FindById(id); var phieuchi_tamUngLuong = await phieuChi_TamUngLuongRepository.FindById(id); if (phieuchi_luongCuoiThang != null) { phieuchi_luongCuoiThang.MaNhanVienThuHoi = userManager.GetUserAsync(User).Result.Id; phieuchi_luongCuoiThang.ThoiGianThuHoi = DateTime.Now; var isSuccess = await phieuChi_LuongCuoiThangRepository.Update(phieuchi_luongCuoiThang); } else if (phieuchi_tamUngLuong != null) { phieuchi_tamUngLuong.MaNhanVienThuHoi = userManager.GetUserAsync(User).Result.Id; phieuchi_tamUngLuong.ThoiGianThuHoi = DateTime.Now; var isSuccess = await phieuChi_TamUngLuongRepository.Update(phieuchi_tamUngLuong); } else { throw new Exception("Không tìm thấy phiếu chi"); } return(RedirectToAction(nameof(Index))); }
public static PhieuChi_LuongCuoiThangVM FeedSomeDataToPhieuChi_LuongCuoiThangModel(IMapper mapper, IPhieuChi_LuongCuoiThangRepository phieuChi_LuongCuoiThangRepository, INhatKylamViecRepository nhatKylamViecRepository, IPhieuChi_NKLVRepository phieuChi_NKLVRepository, UserManager <Employee> userManager, ClaimsPrincipal User, string maPhieuChi) { var phieuChiLuongCuoiThang = phieuChi_LuongCuoiThangRepository.FindById(maPhieuChi).Result; var model = mapper.Map <PhieuChi_LuongCuoiThangVM>(phieuChiLuongCuoiThang); //var maNhanVienDuocXuatLuong = await phieuChi_NKLVRepository.FindMaNhanVienByMaPhieuChi(model.MaPhieuChi); var phieuchi_nklv = (phieuChi_NKLVRepository.FindAll().Result) .FirstOrDefault(q => q.MaPhieuChi == model.MaPhieuChi); var thoiGianTinhLuong = phieuchi_nklv.ThoiGianBatDau_NKLV; var maNhanVienDuocChiTien = phieuchi_nklv.MaNhanVien_NKLV; int tongSoPhutLamViec = TinhTongSoPhutLamDaTichLuyTrongThang( nhatKylamViecRepository, maNhanVienDuocChiTien, thoiGianTinhLuong.Year, thoiGianTinhLuong.Month); model.TongSoGioLam = new TongSoGioLam(); model.TongSoGioLam.SoGio = tongSoPhutLamViec / 60; model.TongSoGioLam.SoPhut = tongSoPhutLamViec % 60; model.TongTienLuongCoBanDaTichLuyTrongThang = TinhTongLuongCoBanTichLuyTrongThang( nhatKylamViecRepository, maNhanVienDuocChiTien, thoiGianTinhLuong.Year, thoiGianTinhLuong.Month); model.TongTienThuongDaTichLuyTrongThang = TinhTongTienThuongDaTichLuyTrongThang( nhatKylamViecRepository, maNhanVienDuocChiTien, thoiGianTinhLuong.Year, thoiGianTinhLuong.Month); model.TongTienLuong = model.TongTienLuongCoBanDaTichLuyTrongThang + model.TongTienThuongDaTichLuyTrongThang; model.NhanVienDuocChiTien = mapper.Map <EmployeeVM>(userManager.FindByIdAsync(maNhanVienDuocChiTien).Result); model.NhanVienXuatLuong = mapper.Map <EmployeeVM>(userManager.FindByIdAsync(model.MaNhanVienXuatLuong).Result); return(model); }