コード例 #1
0
        public IActionResult UngVienDuocXemCv(string id_ung_vien)
        {
            long   total_recs = 0;
            string msg        = "";
            // Có id ứng viên => tìm được tất cả các note ứng viên job
            // Từ Id note ứng viên job lấy được các note, nhà tuyển dụng đã xem cv c
            var get_note_uv_job_by_id_uv = NoteUngVienJobBL.GetNoteUngVienByIdUngVien(app_id, id_ung_vien.Split(","), 1, out total_recs, out msg, 999, (is_sys_admin || is_app_admin));
            // lấy id note ứng viên job
            var id_note_ung_vien_job    = get_note_uv_job_by_id_uv.Select(x => x.id_note_ung_vien_job);
            var all_log_xem_cv_ung_vien = NoteBL.GetLogXemCvTuyenDung(id_note_ung_vien_job, out total_recs, out msg, 9999);
            var cv = all_log_xem_cv_ung_vien.GroupBy(x => x.id_obj).ToDictionary(o => o.Key, o => o.Select(x => x.noi_dung));

            //
            //lấy id job
            var lst_id_job = get_note_uv_job_by_id_uv.Select(x => x.id_job);
            // tìm nhà tuyển dụng bằng id_job sau đó lấy được những nhà tuyển dụng đã được tạo ra gắn với job đó
            var nha_tuyen_dung_job = NhaTuyenDungBL.GetNhaTuyenDungByIdJob(app_id, lst_id_job, 1, out total_recs, out msg, 9999);
            // lst id đã shared trong mỗi nhà tuyển dụng
            var           lst_id_shared = nha_tuyen_dung_job.Select(x => x.lst_id_share);
            List <string> lst           = new List <string>();

            foreach (var id in lst_id_shared)
            {
                lst.AddRange(id);
            }
            bool is_exist = lst.Intersect(id_note_ung_vien_job).Any();
            //
            Dictionary <string, string> dic = new Dictionary <string, string>();

            foreach (var item in cv.Where(x => id_note_ung_vien_job.Contains(x.Key)))
            {
                dic.Add(item.Key, item.Value.FirstOrDefault());
            }
            foreach (var get in get_note_uv_job_by_id_uv)
            {
                if (dic.ContainsKey(get.id_note_ung_vien_job))
                {
                    get.ghi_chu = dic.Values.FirstOrDefault();
                }
                else if (is_exist)
                {
                    get.ghi_chu = "Đã gửi";
                }
                else
                {
                    get.ghi_chu = "Chưa gửi";
                }
            }
            return(Ok(new DataResponse {
                data = get_note_uv_job_by_id_uv, success = true, msg = msg
            }));
        }
コード例 #2
0
        public IActionResult UngVienJob(string id, string token, string id_ung_vien)
        {
            List <string> lst_id = new List <string>();

            if (!string.IsNullOrEmpty(id_ung_vien))
            {
                lst_id = id_ung_vien.Split(',').ToList();
            }
            List <NoteUngVienJob>             data   = new List <NoteUngVienJob>();
            List <NoteUngVienJobNhaTuyenDung> lst_uv = new List <NoteUngVienJobNhaTuyenDung>();
            long   total_recs = 0;
            string msg        = "";
            var    lst_pq     = PhanQuyenBL.GetQuyenActive($"{id}|{token}", -1, PhanQuyenObjType.NOTE_UNG_VIEN_JOB, new List <int>()
            {
                (int)Quyen.VIEW
            }, new string[] { "obj_id", "obj_type" });
            var lst_id_note_ung_vien_job_shared = lst_pq.Select(x => x.obj_id).ToList();

            lst_id_note_ung_vien_job_shared.AddRange(lst_id);
            data = NoteUngVienJobBL.GetMany(lst_id_note_ung_vien_job_shared);

            // lấy note ứng viên
            var nha_tuyen_dung   = NhaTuyenDungBL.GetByToken(token);
            var lst_note_uv_job  = data.Select(x => x.id_note_ung_vien_job);
            var all_note_cua_ntd = NoteBL.NhaTuyenDungNoteUngVien(lst_note_uv_job, nha_tuyen_dung.id_nha_tuyen_dung, out total_recs, out msg, 9999);
            var lst_id_ung_vien  = data.Select(x => x.id_ung_vien).ToList();

            var data_ung_vien = UngVienBL.GetMany(lst_id_ung_vien).ToDictionary(x => x.id_ung_vien, y => y);
            int stt           = 1;

            foreach (var item in data)
            {
                data_ung_vien.TryGetValue(item.id_ung_vien, out UngVien ung_vien);
                if (ung_vien != null)
                {
                    foreach (var temp in all_note_cua_ntd.Where(x => x.id_obj == item.id_note_ung_vien_job).OrderByDescending(o => o.ngay_tao).Take(1))
                    {
                        item.ghi_chu_nha_tuyen_dung = temp.noi_dung;
                    }
                    lst_uv.Add(new NoteUngVienJobNhaTuyenDung(item, ung_vien)
                    {
                        stt = stt++
                    });
                }
            }
            return(Ok(new DataResponse()
            {
                data = lst_uv, success = data != null, msg = msg
            }));
        }
コード例 #3
0
        public IActionResult GetLog(string id_obj)
        {
            long   total_recs = 0;
            string msg        = "";
            // Số lần nhà tuyển dụng đã truy cập
            var all_log_truy_cap        = NoteBL.GetAllLogNhaTuyenDung(id_obj, out total_recs, out msg, 9999);
            var nha_tuyen_dung          = NhaTuyenDungBL.GetById(id_obj);
            var note_ung_vien_da_shared = nha_tuyen_dung?.lst_id_share;
            // Nhà tuyển dụng đã xem ứng viên nào
            var all_log_xem_cv_ung_vien = NoteBL.GetAllNhaTuyenDungXemCvUngVien(note_ung_vien_da_shared, nha_tuyen_dung.id_nha_tuyen_dung, out total_recs, out msg, 9999);
            // Note của nhà tuyển dụng cho ứng viên
            var all_note_cua_ntd = NoteBL.NhaTuyenDungNoteUngVien(note_ung_vien_da_shared, nha_tuyen_dung.id_nha_tuyen_dung, out total_recs, out msg, 9999);
            //
            var get_id_note_from_note = all_note_cua_ntd.Select(x => x.id_obj);
            // get list note ứng viên job từ note của ứng viên
            var lst_id_note_ung_vien_job = NoteUngVienJobBL.GetMany(get_id_note_from_note);
            // lấy list id ứng viên từ list note ứng viên job
            var lst_id_ung_vien = lst_id_note_ung_vien_job.Select(x => x.id_ung_vien);
            // lấy được list ứng viên
            var ung_vien = QLCUNL.BL.UngVienBL.GetMany(lst_id_ung_vien).ToDictionary(x => x.id_ung_vien, y => y);
            List <NoteUngVienJobMap> lst = new List <NoteUngVienJobMap>();

            foreach (var item in lst_id_note_ung_vien_job)
            {
                NoteUngVienJobMap map = new NoteUngVienJobMap(item, ung_vien);
                lst.Add(map);
            }

            List <NoteUngVienJobMap> lst_cv_log = new List <NoteUngVienJobMap>();

            foreach (var item in all_log_xem_cv_ung_vien)
            {
                NoteUngVienJobMap map_note_ung_vien = new NoteUngVienJobMap(item, lst);
                lst_cv_log.Add(map_note_ung_vien);
            }

            List <NoteUngVienJobMap> lst_map = new List <NoteUngVienJobMap>();

            foreach (var item in all_note_cua_ntd)
            {
                NoteUngVienJobMap map_note_ung_vien = new NoteUngVienJobMap(item, lst);
                lst_map.Add(map_note_ung_vien);
            }
            return(Ok(new { data_log = all_log_truy_cap, data_cv = lst_cv_log, data_note = lst_map, success = true, msg = msg }));
        }
コード例 #4
0
        public IActionResult Search(string term, string token, int page, int page_size)
        {
            long   total_recs = 0;
            string msg        = "";
            List <JobThuocTinhMap> lst_job_map = new List <JobThuocTinhMap>();
            var user = User.FindFirst(x => x.Type == ClaimTypes.NameIdentifier)?.Value;
            List <NhaTuyenDung> data       = new List <NhaTuyenDung>();
            IList <int>         thuoc_tinh = new List <int>();

            data = NhaTuyenDungBL.Search(term, thuoc_tinh, app_id, user, page, token, out total_recs, out msg, page_size, (is_sys_admin || is_app_admin));
            var lst_id_job = data.Select(x => x.id_job);
            var data_job   = QLCUNL.BL.JobBL.GetMany(lst_id_job).ToDictionary(x => x.id_job, y => y);

            foreach (var item in data)
            {
                JobThuocTinhMap job_map = new JobThuocTinhMap(item, data_job);
                lst_job_map.Add(job_map);
            }
            return(Ok(new { data = lst_job_map, total = total_recs, success = lst_job_map != null, msg = msg }));
        }
コード例 #5
0
        public IActionResult GetUngVienDaNote(string id_obj)
        {
            long   total_recs              = 0;
            string msg                     = "";
            var    nha_tuyen_dung          = NhaTuyenDungBL.GetById(id_obj);
            var    note_ung_vien_da_shared = nha_tuyen_dung?.lst_id_share;
            var    all_note_cua_ntd        = NoteBL.NhaTuyenDungNoteUngVien(note_ung_vien_da_shared, nha_tuyen_dung.id_nha_tuyen_dung, out total_recs, out msg, 9999);

            var get_id_note_from_note = all_note_cua_ntd.Select(x => x.id_obj);
            // get list note ứng viên job từ note của ứng viên
            var lst_id_note_ung_vien_job = NoteUngVienJobBL.GetMany(get_id_note_from_note);
            // lấy list id ứng viên từ list note ứng viên job
            var lst_id_ung_vien = lst_id_note_ung_vien_job.Select(x => x.id_ung_vien);
            // lấy được list ứng viên
            var ung_vien = QLCUNL.BL.UngVienBL.GetMany(lst_id_ung_vien).ToDictionary(x => x.id_ung_vien, y => y);
            List <NoteUngVienJobMap> lst_note_map = new List <NoteUngVienJobMap>();

            foreach (var item in lst_id_note_ung_vien_job)
            {
                NoteUngVienJobMap map = new NoteUngVienJobMap(item, ung_vien);
                lst_note_map.Add(map);
            }
            return(Ok(new { data = lst_note_map, success = ung_vien.Count > 0, msg = msg }));
        }
コード例 #6
0
        public IActionResult Put(string id, [FromBody] object value)
        {
            var          obj = JToken.Parse(value.ToString());
            DataResponse res = new DataResponse();

            if (obj == null)
            {
                res.success = false;
                res.msg     = "Đối tượng bị bỏ trống";
                return(Ok(res));
            }
            try
            {
                List <string> note_uv_gui_nha_tuyen_dung = obj["note_ung_vien_gui_nha_tuyen_dung"].ToObject <List <string> >();
                List <Note>   lst                 = new List <Note>();
                var           get_all_ntd         = BL.NhaTuyenDungBL.GetById(id);
                var           old_id_share        = QLCUNL.BL.NhaTuyenDungBL.GetById(id)?.lst_id_share;
                var           edit_employer       = obj["nha_tuyen_dung"].ToObject <NhaTuyenDung>();
                var           note_ung_vien_share = obj["note_ung_vien_share"];
                var           new_id_share        = note_ung_vien_share["id"].ToObject <List <string> >();

                //Theem quyen
                var added_id_share = new_id_share.Except(old_id_share);
                //xoa quyen
                var remove_id_share = old_id_share.Except(new_id_share);
                if (remove_id_share.Any() == true)
                {
                    PhanQuyenBL.RemovePhanQuyenByUser($"{get_all_ntd.id_nha_tuyen_dung}|{get_all_ntd.token}", remove_id_share.ToList());
                }
                edit_employer.lst_id_share = new_id_share;
                edit_employer.id           = id;
                res.success = NhaTuyenDungBL.Update(edit_employer);

                List <string> lst_id_nha_tuyen_dung = new List <string>()
                {
                    edit_employer.id_nha_tuyen_dung
                };
                int  type     = 1;
                int  rule     = 1;
                int  obj_type = note_ung_vien_share["obj_type"].ToObject <int>();
                long ngay_het = 0;

                List <Quyen> quyen = new List <Quyen>();

                ngay_het = XMedia.XUtil.TimeInEpoch(DateTime.Now.AddMonths(1));
                quyen    = new List <Quyen>()
                {
                    Quyen.VIEW
                };

                var obj_type_check = (PhanQuyenObjType)obj_type;
                var user           = User.FindFirst(x => x.Type == ClaimTypes.NameIdentifier).Value;

                var numbersAndWords = new_id_share.Zip(note_uv_gui_nha_tuyen_dung, (n, w) => new { id_obj = n, noi_dung = w });

                foreach (var notes in numbersAndWords)
                {
                    if (!string.IsNullOrEmpty(notes.noi_dung))
                    {
                        Note note = new Note();
                        note.id_obj       = notes.id_obj;
                        note.loai         = LoaiNote.NOTE_UNG_VIEN_GUI_NHA_TUYEN_DUNG;
                        note.loai_du_lieu = LoaiDuLieu.NGUOI_DUNG;
                        note.nguoi_tao    = user;
                        note.nguoi_sua    = user;
                        note.noi_dung     = notes.noi_dung;
                        SetMetaData(note, false);
                        lst.Add(note);
                    }
                }
                var count = QLCUNL.BL.NoteBL.IndexMany(lst);
                res.success = count > 0;
                if (new_id_share.Count > 0)
                {
                    foreach (var ids in new_id_share)
                    {
                        var has_share_permission = false;
                        switch (obj_type_check)
                        {
                        case PhanQuyenObjType.UNG_VIEN:
                            has_share_permission = UngVienBL.IsOwner(ids, user);
                            break;

                        case PhanQuyenObjType.NOTE_UNG_VIEN_JOB:
                            has_share_permission = NoteUngVienJobBL.IsOwner(ids, user);
                            break;
                        }
                        if (has_share_permission)
                        {
                            #region Xóa shared của các đối tượng cũ

                            try
                            {
                                List <string> lst_id_phan_quyen_can_xoa = new List <string>();
                                var           menu_shared = PhanQuyenBL.Get(string.Empty, PhanQuyenRule.ALL, PhanQuyenType.ALL, string.Empty, PhanQuyenObjType.ALL, id,
                                                                            quyen, 0, 0, user, 0, 0, string.Empty, 0, 0, 1, 9999, out _);
                                foreach (var item_shared in menu_shared)
                                {
                                    if (item_shared.type == PhanQuyenType.USERS)
                                    {
                                        if (!lst_id_nha_tuyen_dung.Contains(item_shared.user))
                                        {
                                            lst_id_phan_quyen_can_xoa.Add(item_shared.id);
                                        }
                                        else
                                        {
                                            if (item_shared.ngay_het == ngay_het && item_shared.quyen.All(quyen.Contains) && quyen.All(item_shared.quyen.Contains))
                                            {
                                                lst_id_phan_quyen_can_xoa.Remove(item_shared.user);
                                            }
                                        }
                                    }
                                }
                                PhanQuyenBL.RemoveByListId(lst_id_phan_quyen_can_xoa);
                            }
                            catch (Exception)
                            {
                            }

                            #endregion Xóa shared của các đối tượng cũ

                            #region Shared cho các đối tượng được chọn

                            try
                            {
                                if (lst_id_nha_tuyen_dung.Count == 0)
                                {
                                    res.success = true;
                                    res.msg     = "Không có thay đổi nào được thực hiện";
                                }
                                else
                                {
                                    foreach (var u in lst_id_nha_tuyen_dung)
                                    {
                                        PhanQuyen pq = new PhanQuyen();
                                        pq.ngay_het  = ngay_het;
                                        pq.user      = u + "|" + get_all_ntd.token;
                                        pq.type      = PhanQuyenType.USERS;
                                        pq.rule      = (PhanQuyenRule)rule;
                                        pq.quyen     = quyen;
                                        pq.obj_type  = (PhanQuyenObjType)obj_type;
                                        pq.nguoi_tao = user;
                                        pq.obj_id    = ids;

                                        res.success = QLCUNL.BL.PhanQuyenBL.Index(pq);
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }

                            #endregion Shared cho các đối tượng được chọn
                        }
                    }
                }
                else
                {
                    res.msg     = "Không có đối tượng nào được chọn";
                    res.success = false;
                }
            }
            catch (Exception ex)
            {
                res.msg = ex.StackTrace; res.success = false;
            }

            return(Ok(res));
        }
コード例 #7
0
        public bool Delete(string id)
        {
            bool del = NhaTuyenDungBL.Delete(id);

            return(del);
        }
コード例 #8
0
ファイル: JobController.cs プロジェクト: hvtienfithou997/CUNL
        public IActionResult Search(string value_filter, long ngay_nhan_hd, long ngay_tao, string term, string id_ung_vien,
                                    string id_cong_ty, long ngay_di_lam_from, long ngay_di_lam_to, double don_gia_from, double don_gia_to, string thuoc_tinh,
                                    string thuoc_tinh_rieng, string op, string thuoc_tinh2, string thuoc_tinh_rieng2, string op2, long ngay_tao_from, long ngay_tao_to, int page, int page_size,
                                    string field_sort = "", string sort = "")
        {
            Dictionary <string, bool> sort_order = new Dictionary <string, bool>();

            if (!string.IsNullOrEmpty(field_sort) && !string.IsNullOrEmpty(sort))
            {
                sort_order.Add(field_sort, sort == "0" ? true : false);
            }
            else
            {
                sort_order.Add("id_auto", true);
            }
            var        default_settings     = QLCUNL.BL.UserBL.GetDefaultSettingByAppId(app_id);
            List <int> lst_thuoc_tinh       = new List <int>();
            List <int> lst_thuoc_tinh_rieng = new List <int>();

            List <int> lst_thuoc_tinh2       = new List <int>();
            List <int> lst_thuoc_tinh_rieng2 = new List <int>();

            List <string> lst_id                       = new List <string>();
            List <string> lst_id_should                = new List <string>();
            bool          is_find_thuoc_tinh_rieng     = false;
            List <Job>    data_job                     = new List <Job>();
            Dictionary <string, UserJob> data_user_job = new Dictionary <string, UserJob>();
            Dictionary <string, Dictionary <int, long> > dic_thong_ke_trang_thai_ung_vien_theo_job = new Dictionary <string, Dictionary <int, long> >();
            long   total_recs = 0;
            string msg        = "";

            if (!string.IsNullOrEmpty(thuoc_tinh))
            {
                foreach (var tt in thuoc_tinh.Split(','))
                {
                    int t = -1;
                    if (Int32.TryParse(tt, out t))
                    {
                        lst_thuoc_tinh.Add(t);
                    }
                }
            }
            if (!string.IsNullOrEmpty(thuoc_tinh_rieng) || !string.IsNullOrEmpty(thuoc_tinh_rieng2))
            {
                if (string.IsNullOrEmpty(thuoc_tinh_rieng))
                {
                    thuoc_tinh_rieng = "";
                }
                foreach (var tt in thuoc_tinh_rieng.Split(','))
                {
                    int t = -1;
                    if (Int32.TryParse(tt, out t))
                    {
                        lst_thuoc_tinh_rieng.Add(t);
                    }
                }
                if (string.IsNullOrEmpty(thuoc_tinh_rieng2))
                {
                    thuoc_tinh_rieng2 = "";
                }
                foreach (var tt in thuoc_tinh_rieng2.Split(','))
                {
                    int t = -1;
                    if (Int32.TryParse(tt, out t))
                    {
                        lst_thuoc_tinh_rieng2.Add(t);
                    }
                }

                is_find_thuoc_tinh_rieng = true;
                var lst_id_obj = ThuocTinhDuLieuBL.Search(app_id, user, LoaiThuocTinh.JOB, lst_thuoc_tinh_rieng, 1, out long total_recs_thuoc_tinh, out _, 9999, op, lst_thuoc_tinh_rieng2, op2);

                if (lst_id_obj.Count > 0)
                {
                    if (op == "0")
                    {
                        lst_id_should = lst_id_obj.Select(x => x.id_obj).Distinct().ToList();
                    }
                    else
                    {
                        lst_id = lst_id_obj.Select(x => x.id_obj).Distinct().ToList();
                    }
                }
                else
                {
                    lst_id = new List <string>()
                    {
                        "__NULL__"
                    };
                }
            }

            if (!string.IsNullOrEmpty(thuoc_tinh2))
            {
                foreach (var tt in thuoc_tinh2.Split(','))
                {
                    int t = -1;
                    if (Int32.TryParse(tt, out t))
                    {
                        lst_thuoc_tinh2.Add(t);
                    }
                }
            }

            ///lấy tất cả các UserJob đã được gán cho người dùng này, trộn cùng các Job họ tạo ra (hoặc của team mình) order lại theo ngày nhận Job và ngày Tạo Job
            var           user_job   = UserJobBL.Search(app_id, user, group, new List <string>(), string.Empty, 0, 0, new List <int>(), new List <string>(), 1, out long total_user_job, out string msg_user_job, 100, (is_app_admin || is_app_admin));
            List <string> lst_id_job = new List <string>();

            if (user_job.Count > 0)
            {
                lst_id_job = user_job.Select(x => x.id_job).Distinct().ToList();

                foreach (var item in user_job)
                {
                    if (!data_user_job.ContainsKey(item.id_job))
                    {
                        data_user_job.Add(item.id_job, item);
                    }
                }
                lst_id_should.AddRange(lst_id_job);
            }
            var company = string.Empty;

            if (!string.IsNullOrEmpty(id_cong_ty))
            {
                company = CongTyBL.GetCongTyByNameV2(app_id, id_cong_ty)?.id_cong_ty;
            }

            data_job = JobBL.SearchDefault(app_id, user, group, value_filter, ngay_nhan_hd, ngay_tao, term, id_ung_vien, company, ngay_di_lam_from, ngay_di_lam_to, don_gia_from, don_gia_to, lst_thuoc_tinh, lst_thuoc_tinh2, lst_id, lst_id_should,
                                           ngay_tao_from, ngay_tao_to, page, out total_recs, out msg, page_size, (is_sys_admin || is_app_admin || is_super_user), null, op, op2, sort_order);

            dic_thong_ke_trang_thai_ung_vien_theo_job = NoteUngVienJobBL.ThongKeTrangThaiUngVien(app_id, user, default_settings.trang_thai_thong_ke_ung_vien_job,
                                                                                                 data_job.Select(x => x.id_job), data_job.Where(x => x.owner == user).Select(x => x.id_job),
                                                                                                 (is_app_admin | is_super_user | is_sys_admin));

            //
            var lst_id_thuoc_tinh = data_job.Where(x => x.thuoc_tinh != null).SelectMany(x => x.thuoc_tinh).ToList();

            List <JobThuocTinhMap> lst_job_map = new List <JobThuocTinhMap>();
            var dic_thuoc_tinh_rieng           = ThuocTinhDuLieuBL.GetIdThuocTinhByIdObj(app_id, data_job.Select(x => x.id_job), user);

            if (dic_thuoc_tinh_rieng.Count > 0)
            {
                foreach (var tt_r in dic_thuoc_tinh_rieng)
                {
                    lst_id_thuoc_tinh.AddRange(tt_r.Value);
                }
            }

            var data_thuoc_tinh = ThuocTinhBL.GetManyByGiaTri(app_id, lst_id_thuoc_tinh, LoaiThuocTinh.JOB, -1);
            //
            var all_thuoc_tinh_job = ThuocTinhBL.GetAllByLoaiThuocTinh(app_id, (int)LoaiThuocTinh.JOB, -1);
            var all_thuoc_tinh_note_ung_vien_job = ThuocTinhBL.GetAllByLoaiThuocTinh(app_id, (int)LoaiThuocTinh.NOTE_UNG_VIEN_JOB, 0);
            var lst_id_cong_ty = data_job.Where(x => x.cong_ty != null && !string.IsNullOrEmpty(x.cong_ty.id_cong_ty)).Select(x => x.cong_ty.id_cong_ty);
            var lst_cong_ty    = QLCUNL.BL.CongTyBL.GetMany(lst_id_cong_ty);

            Dictionary <string, string> dic_cong_ty = new Dictionary <string, string>();
            Dictionary <string, long>   dic_count_user_job_theo_job = UserJobBL.ThongKeUserJob(app_id, data_job.Select(x => x.id_job));

            if (lst_cong_ty != null)
            {
                dic_cong_ty = lst_cong_ty.ToDictionary(x => x.id_cong_ty, y => y.ten_cong_ty);
            }
            foreach (var item in data_job)
            {
                dic_thuoc_tinh_rieng.TryGetValue(item.id_job, out List <int> tt_rieng);
                if (tt_rieng == null)
                {
                    tt_rieng = new List <int>();
                }

                if (item.cong_ty != null && !string.IsNullOrEmpty(item.cong_ty.id_cong_ty))
                {
                    dic_cong_ty.TryGetValue(item.cong_ty.id_cong_ty, out string ten_cong_ty);
                    item.cong_ty.ten_cong_ty = ten_cong_ty;
                }

                var jo = new JobThuocTinhMap(item, all_thuoc_tinh_job, tt_rieng);

                // tìm nhà tuyển dụng bằng id_job để lấy số ứng viên đã gửi
                var get_note_uv_job_by_ntd = NhaTuyenDungBL.GetListNtdByIdJob(item.id_job);

                var list_share = new List <string>();
                if (get_note_uv_job_by_ntd != null)
                {
                    foreach (var ntd in get_note_uv_job_by_ntd)
                    {
                        list_share.AddRange(ntd.lst_id_share);
                    }
                    list_share = list_share.Distinct().ToList();
                    if (list_share.Count > 0)
                    {
                        jo.ung_vien_da_gui = list_share.Count;
                    }
                }

                // tìm nhà tuyển dụng đã vào xem job

                IList <int> lst = new List <int>();
                lst.Add(-1);
                long total_seen         = 0;
                var  lst_ntd_seen       = NoteBL.Search(lst, out total_seen, out msg, 9999);
                var  lst_ntd_get_id     = lst_ntd_seen.Select(x => x.id_obj).Distinct();
                var  all_nha_tuyen_dung = BL.NhaTuyenDungBL.GetMany(lst_ntd_get_id).Where(x => x.id_job == item.id_job);
                jo.ntd_da_xem = all_nha_tuyen_dung.Count() > 0;

                //tìm xem nhà tuyển dụng đã phản hồi hay chưa
                List <string> list_id_share           = new List <string>();
                var           note_ung_vien_da_shared = all_nha_tuyen_dung.Select(x => x.lst_id_share);
                foreach (var id in note_ung_vien_da_shared)
                {
                    list_id_share.AddRange(id);
                }

                var id_nha_tuyen_dung = all_nha_tuyen_dung.Select(x => x.id_nha_tuyen_dung);
                var nguoi_tao         = string.Join(",", id_nha_tuyen_dung);

                var all_note_cua_ntd = NoteBL.NhaTuyenDungNoteUngVien(list_id_share, nguoi_tao, out total_seen, out msg, 9999).Where(x => list_id_share.Contains(x.id_obj));
                if (all_note_cua_ntd.Count() > 0)
                {
                    jo.ntd_da_phan_hoi = all_note_cua_ntd.Count() > 0;
                    var id = all_nha_tuyen_dung.Select(x => x.id).FirstOrDefault();
                    jo.id_nha_tuyen_dung = string.Join(",", id);
                }

                jo.is_user_job = data_user_job.ContainsKey(item.id_job);
                jo.is_owner    = (user == (string.IsNullOrEmpty(item.owner) ? item.nguoi_tao : item.owner) || is_app_admin);
                if (jo.is_user_job)
                {
                    jo.ngay_tao    = data_user_job[item.id_job].ngay_nhan_job;
                    jo.id_user_job = data_user_job[item.id_job].id_user_job;
                }
                dic_count_user_job_theo_job.TryGetValue(item.id_job, out long _so_luong_user_job);
                jo.so_luong_user_job = _so_luong_user_job;
                if (jo.is_owner || jo.is_user_job)
                {
                    var thong_ke_thuoc_tinh = new List <dynamic>();
                    if (dic_thong_ke_trang_thai_ung_vien_theo_job.ContainsKey(item.id_job))
                    {
                        foreach (var tt in dic_thong_ke_trang_thai_ung_vien_theo_job[item.id_job])
                        {
                            var tv = all_thuoc_tinh_note_ung_vien_job.Find(f => f.gia_tri == tt.Key);
                            if (tv != null)
                            {
                                thong_ke_thuoc_tinh.Add(new { ten = tv.ten, gia_tri = tt.Key, total = tt.Value });
                            }
                            else
                            {
                                if (tt.Key == 0)
                                {
                                    thong_ke_thuoc_tinh.Add(new { ten = "<b>Tổng số U/V</b>", gia_tri = -1, total = tt.Value });
                                }
                            }
                        }
                    }
                    else
                    {
                        thong_ke_thuoc_tinh.Add(new { ten = "<b>Tổng số U/V</b>", gia_tri = -1, total = 0 });
                    }
                    jo.ung_vien_thong_ke = thong_ke_thuoc_tinh;
                }
                lst_job_map.Add(jo);
            }

            return(Ok(new DataResponsePaging()
            {
                data = lst_job_map, total = total_recs, success = data_job != null, msg = msg
            }));
        }
コード例 #9
0
        public IActionResult Search(string term, string id_user, string id_job, string id_ung_vien, long ngay_gio_phong_van_from, long ngay_gio_phong_van_to,
                                    long ngay_di_lam_from, long ngay_di_lam_to, double luong_thu_viec_from, long luong_thu_viec_to, double luong_chinh_thuc_from, long luong_chinh_thuc_to, string thuoc_tinh, string thuoc_tinh_rieng
                                    , int page, int page_size)
        {
            List <int>            lst_thuoc_tinh       = new List <int>();
            List <int>            lst_thuoc_tinh_rieng = new List <int>();
            List <string>         lst_id = new List <string>();
            bool                  is_find_thuoc_tinh_rieng = false;
            List <NoteUngVienJob> data_note_ung_vien_job   = new List <NoteUngVienJob>();
            long                  total_recs = 0;
            string                msg        = "";

            if (!string.IsNullOrEmpty(thuoc_tinh))
            {
                foreach (var tt in thuoc_tinh.Split(','))
                {
                    int t = -1;
                    if (Int32.TryParse(tt, out t))
                    {
                        lst_thuoc_tinh.Add(t);
                    }
                }
            }
            if (!string.IsNullOrEmpty(thuoc_tinh_rieng))
            {
                foreach (var tt in thuoc_tinh_rieng.Split(','))
                {
                    int t = -1;
                    if (Int32.TryParse(tt, out t))
                    {
                        lst_thuoc_tinh_rieng.Add(t);
                    }
                }
                if (lst_thuoc_tinh_rieng.Count > 0)
                {
                    is_find_thuoc_tinh_rieng = true;
                    var lst_id_obj = BL.ThuocTinhDuLieuBL.Search(app_id, user, LoaiThuocTinh.NOTE_UNG_VIEN_JOB, lst_thuoc_tinh_rieng, page, out long total_recs_thuoc_tinh, out _, 9999);
                    lst_id = lst_id_obj.Select(x => x.id_obj).ToList();
                }
            }
            if (is_find_thuoc_tinh_rieng && lst_id.Count == 0 && lst_thuoc_tinh.Count == 0)
            {
            }
            else
            {
                data_note_ung_vien_job = QLCUNL.BL.NoteUngVienJobBL.Search(app_id, user, group, "", id_user, id_job, id_ung_vien, ngay_gio_phong_van_from, ngay_gio_phong_van_to, ngay_di_lam_from, ngay_di_lam_to,
                                                                           luong_thu_viec_from, luong_thu_viec_to, luong_chinh_thuc_from, luong_chinh_thuc_to, lst_thuoc_tinh, lst_id, page, out total_recs, out msg, page_size, (is_sys_admin || is_app_admin), fields);
            }
            var lst_id_job        = data_note_ung_vien_job.Select(x => x.id_job);
            var lst_id_ung_vien   = data_note_ung_vien_job.Select(x => x.id_ung_vien);
            var data_job          = QLCUNL.BL.JobBL.GetMany(app_id, lst_id_job, new string[] { "chuc_danh", "cong_ty", "nguoi_lien_he" }).ToDictionary(x => x.id_job, y => y);
            var data_ung_vien     = QLCUNL.BL.UngVienBL.GetMany(lst_id_ung_vien).ToDictionary(x => x.id_ung_vien, y => y);
            var lst_id_thuoc_tinh = data_note_ung_vien_job.Where(x => x.thuoc_tinh != null).SelectMany(x => x.thuoc_tinh).ToList();

            // tìm note nhà tuyển dụng của từng ứng viên.
            long total_seen          = 0;
            var  list_id_note_uv_job = data_note_ung_vien_job.Select(x => x.id_note_ung_vien_job);

            var tim_ntd_by_list_note = NhaTuyenDungBL.GetNhaTuyenDungByLstIdShare(app_id, list_id_note_uv_job, 1, out total_seen, out msg, 9999);
            var id_ntd            = tim_ntd_by_list_note.Select(x => x.id);
            var id_nha_tuyen_dung = tim_ntd_by_list_note.Select(x => x.id_nha_tuyen_dung);
            //var nguoi_tao = string.Join(",", id_nha_tuyen_dung);
            //var note_nha_tuyen_dung = NoteBL.NhaTuyenDungNoteUngVien(id_ntd, nguoi_tao, out total_seen, out msg, 9999);

            var list_name = new List <string>();
            var lst_note  = new List <Note>();

            foreach (var nguoi_tao in tim_ntd_by_list_note)
            {
                list_name.Add(nguoi_tao.id_nha_tuyen_dung);
            }

            foreach (var item in list_name)
            {
                var ntd_xem_cv_ung_vien = NoteBL.GetAllNhaTuyenDungXemCvUngVien(list_id_note_uv_job, item, out total_seen, out msg, 9999);
                lst_note.AddRange(ntd_xem_cv_ung_vien);
            }

            List <NoteUngVienJobMap> lst = new List <NoteUngVienJobMap>();

            var dic_thuoc_tinh_rieng = QLCUNL.BL.ThuocTinhDuLieuBL.GetIdThuocTinhByIdObj(app_id, data_note_ung_vien_job.Select(x => x.id_note_ung_vien_job), user);

            if (dic_thuoc_tinh_rieng.Count > 0)
            {
                foreach (var tt_r in dic_thuoc_tinh_rieng)
                {
                    lst_id_thuoc_tinh.AddRange(tt_r.Value);
                }
            }
            var data_thuoc_tinh = QLCUNL.BL.ThuocTinhBL.GetManyByGiaTri(app_id, lst_id_thuoc_tinh, LoaiThuocTinh.NOTE_UNG_VIEN_JOB, -1);

            foreach (var item in data_note_ung_vien_job)
            {
                dic_thuoc_tinh_rieng.TryGetValue(item.id_note_ung_vien_job, out List <int> tt_rieng);
                if (tt_rieng == null)
                {
                    tt_rieng = new List <int>();
                }
                NoteUngVienJobMap note = new NoteUngVienJobMap(item, data_job, data_ung_vien, data_thuoc_tinh, tt_rieng);

                foreach (var em in lst_note.Where(x => x.id_obj.Contains(item.id_note_ung_vien_job)))
                {
                    if (em.id_obj == item.id_note_ung_vien_job)
                    {
                        note.xem_cv = true;
                    }
                    else
                    {
                        note.xem_cv = false;
                    }
                }

                lst.Add(note);
            }

            return(Ok(new DataResponsePaging()
            {
                data = lst, total = total_recs, success = data_note_ung_vien_job != null, msg = msg
            }));
        }