示例#1
0
        public IActionResult UngVien(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 <UngVien>             data    = new List <UngVien>();
            List <UngVienNhaTuyenDung> list_uv = new List <UngVienNhaTuyenDung>();

            string msg    = "";
            int    stt    = 1;
            var    lst_pq = PhanQuyenBL.GetQuyenActive($"{id}|{token}", 0, PhanQuyenObjType.UNG_VIEN, new List <int>()
            {
                (int)Quyen.VIEW
            }, new string[] { "obj_id" });
            var lst_id_ung_vien_shared = lst_pq.Select(x => x.obj_id).ToList();

            lst_id_ung_vien_shared.AddRange(lst_id);

            data = UngVienBL.GetMany(lst_id_ung_vien_shared);

            list_uv = data.Select(x => new UngVienNhaTuyenDung(x)
            {
                stt = stt++
            }).ToList();
            return(Ok(new DataResponse()
            {
                data = list_uv, success = data != null, msg = msg
            }));
        }
示例#2
0
 public bool Delete(string id)
 {
     if (QLCUNL.BL.UngVienBL.CanDelete(id, user, group) || (is_sys_admin || is_app_admin))
     {
         bool del = UngVienBL.Delete(id);
         return(del);
     }
     return(false);
 }
示例#3
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
            }));
        }
示例#4
0
        public IActionResult Get(string id)
        {
            var note_ung_vien_job = QLCUNL.BL.NoteUngVienJobBL.GetById(id);

            if (!IsInAppId(note_ung_vien_job))
            {
                return(BadRequest());
            }
            if (note_ung_vien_job != null)
            {
                var lst_id_job = new List <string>()
                {
                    note_ung_vien_job.id_job
                };
                var lst_id_ung_vien = new List <string>()
                {
                    note_ung_vien_job.id_ung_vien
                };
                var data_job      = 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 = UngVienBL.GetMany(lst_id_ung_vien).ToDictionary(x => x.id_ung_vien, y => y);

                var lst_id_thuoc_tinh    = note_ung_vien_job.thuoc_tinh != null ? note_ung_vien_job.thuoc_tinh : new List <int>();
                var lst_thuoc_tinh_rieng = ThuocTinhDuLieuBL.GetIdThuocTinhByIdObj(app_id, note_ung_vien_job.id_note_ung_vien_job, user);

                var data_thuoc_tinh = ThuocTinhBL.GetManyByGiaTri(app_id, lst_id_thuoc_tinh, LoaiThuocTinh.NOTE_UNG_VIEN_JOB, ThuocTinhType.SHARED);
                if (lst_thuoc_tinh_rieng.Count() > 0)
                {
                    var thuoc_tinh_rieng = ThuocTinhBL.GetPrivateByLoaiGiaTri(app_id, user, lst_thuoc_tinh_rieng, LoaiThuocTinh.NOTE_UNG_VIEN_JOB, (is_sys_admin || is_app_admin));
                    data_thuoc_tinh.AddRange(thuoc_tinh_rieng);
                }

                Models.NoteUngVienJobMap note = new Models.NoteUngVienJobMap(note_ung_vien_job, data_job, data_ung_vien, data_thuoc_tinh, false);

                return(Ok(new DataResponse()
                {
                    data = note, success = note_ung_vien_job != null, msg = ""
                }));
            }

            return(Ok(new DataResponse()
            {
                data = new { }, success = false, msg = ""
            }));
        }
示例#5
0
        public IActionResult Put(string id, [FromBody] object value)
        {
            DataResponse res = new DataResponse();

            try
            {
                var ung_vien = Newtonsoft.Json.JsonConvert.DeserializeObject <UngVien>(value.ToString());
                var obj      = JToken.Parse(value.ToString());
                ung_vien.id_ung_vien = id;

                if (UngVienBL.CanEdit(id, user, group) || (is_sys_admin || is_app_admin))
                {
                    SetMetaData(ung_vien, true);
                    res.success = QLCUNL.BL.UngVienBL.Update(ung_vien);
                    UpsertThuocTinhRieng(value, id, LoaiThuocTinh.UNG_VIEN);
                    if (!string.IsNullOrEmpty(obj["note_ung_vien"].ToString()))
                    {
                        var note = new Note();
                        note.noi_dung     = obj["note_ung_vien"].ToString();
                        note.id_obj       = id;
                        note.loai         = LoaiNote.UNG_VIEN;
                        note.loai_du_lieu = LoaiDuLieu.NGUOI_DUNG;
                        note.thuoc_tinh   = new List <int>();
                        SetMetaData(note, false);
                        res.success = NoteBL.Index(note);
                    }
                }
                else
                {
                    res.msg = "Không có quyền sửa đối tượng này";
                }
            }
            catch (Exception ex)
            {
                res.msg = ex.StackTrace; res.success = false;
            }

            return(Ok(res));
        }
示例#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 IActionResult Post([FromBody] object value)
        {
            //value = {'nha_tuyen_dung':{'id_nha_tuyen_dung':'tuyendun@xmedi'},'ung_vien_share':{'id':['uv_1','uv_2'],'obj_type':4}}
            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           user = User.FindFirst(x => x.Type == ClaimTypes.NameIdentifier).Value;
                //var note_nha_tuyen_dung = obj["note_ung_vien_gui_nha_tuyen_dung"].ToObject<Note>();

                var    ip_add       = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv6().ToString();
                string browser      = Request.Headers["User-Agent"];
                var    add_employer = obj["nha_tuyen_dung"].ToObject <NhaTuyenDung>();
                SetMetaData(add_employer, false);
                add_employer.ip      = ip_add;
                add_employer.browser = browser;
                var note_ung_vien_share = obj["note_ung_vien_share"];
                var ids = note_ung_vien_share["id"].ToObject <List <string> >();
                add_employer.lst_id_share = ids;
                var employer = QLCUNL.BL.NhaTuyenDungBL.Index(add_employer, out string token);
                res.success = !string.IsNullOrEmpty(employer);

                List <string> lst_id_nha_tuyen_dung = new List <string>()
                {
                    add_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 numbersAndWords = ids.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;

                foreach (var id in ids)
                {
                    var has_share_permission = false;
                    switch (obj_type_check)
                    {
                    case PhanQuyenObjType.UNG_VIEN:
                        has_share_permission = UngVienBL.IsOwner(id, user);
                        break;

                    case PhanQuyenObjType.NOTE_UNG_VIEN_JOB:
                        has_share_permission = NoteUngVienJobBL.IsOwner(id, user) || (is_app_admin);
                        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 = QLCUNL.BL.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 + "|" + add_employer.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    = id;
                                    res.success  = QLCUNL.BL.PhanQuyenBL.Index(pq);
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }

                        #endregion Shared cho các đối tượng được chọn
                    }
                }
            }
            catch (Exception ex)
            {
                res.msg = ex.Message; res.success = false;
            }
            return(Ok(res));
        }
        public IActionResult Share([FromBody] object value)
        {
            //check quyền trước khi share? Chỉ admin + owner mới được quyền share
            bool         has_share_permission = (is_sys_admin || is_app_admin);
            DataResponse res = new DataResponse()
            {
                msg = "Không có quyền chia sẻ thông tin", success = false
            };

            try
            {
                var obj = JToken.Parse(value.ToString());
                if (obj != null)
                {
                    List <string> users = obj["user"].ToObject <List <string> >();
                    List <string> lst_id_nha_tuyen_dung = new List <string>();
                    if (obj["id_nha_tuyen_dung"] != null)
                    {
                        string id_nha_tuyen_dung = obj["id_nha_tuyen_dung"].ToString();
                        try
                        {
                            lst_id_nha_tuyen_dung = id_nha_tuyen_dung.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToList();
                        }
                        catch (Exception)
                        {
                        }
                    }
                    string       id       = obj["id"].ToString();
                    int          type     = obj["type"].ToObject <int>();
                    int          rule     = obj["rule"].ToObject <int>();
                    int          obj_type = obj["obj_type"].ToObject <int>();
                    long         ngay_het = 0;
                    List <Quyen> quyen    = new List <Quyen>();
                    List <int>   teams    = new List <int>();

                    if (obj["ngay_het"] != null)
                    {
                        try
                        {
                            ngay_het = XMedia.XUtil.TimeInEpoch(Convert.ToDateTime(ngay_het, dtfi));
                        }
                        catch (Exception)
                        {
                            ngay_het = XMedia.XUtil.TimeInEpoch(DateTime.Now.AddYears(10));
                        }
                    }
                    if (obj["quyen"] != null)
                    {
                        quyen = obj["quyen"].ToObject <List <Quyen> >();
                    }
                    if (!(is_sys_admin || is_app_admin))
                    {
                        var obj_type_check = (PhanQuyenObjType)obj_type;
                        switch (obj_type_check)
                        {
                        case PhanQuyenObjType.CONG_TY:
                            has_share_permission = CongTyBL.IsOwner(id, user);
                            break;

                        case PhanQuyenObjType.USER_JOB:
                            has_share_permission = UserJobBL.IsOwner(id, user);
                            break;

                        case PhanQuyenObjType.NOTE_UNG_VIEN:
                            has_share_permission = NoteUngVienBL.IsOwner(id, user);
                            break;

                        case PhanQuyenObjType.UNG_VIEN:
                            has_share_permission = UngVienBL.IsOwner(id, user);
                            break;

                        case PhanQuyenObjType.JOB:
                            has_share_permission = JobBL.IsOwner(id, user);
                            break;

                        case PhanQuyenObjType.NOTE_UNG_VIEN_JOB:
                            has_share_permission = NoteUngVienJobBL.IsOwner(id, user);
                            break;

                        case PhanQuyenObjType.MENU:
                            has_share_permission = MenuBL.IsOwner(id, user);
                            break;
                        }
                    }
                    if (!has_share_permission)
                    {
                        return(Ok(res));
                    }

                    if (obj["teams"] != null)
                    {
                        try
                        {
                            teams = obj["teams"].ToObject <List <int> >();
                        }
                        catch
                        {
                            teams = new List <int>();
                        }
                    }

                    #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 = QLCUNL.BL.PhanQuyenBL.Get(string.Empty, PhanQuyenRule.ALL, PhanQuyenType.ALL, string.Empty, PhanQuyenObjType.ALL, id, quyen, 0, 0, ((is_sys_admin || is_app_admin) ? string.Empty : user), 0, 0, string.Empty, 0, 0, 1, 9999, out _);
                        foreach (var item_shared in menu_shared)
                        {
                            if (item_shared.type == PhanQuyenType.GROUP_USERS)
                            {
                                int id_team_shared = -1;

                                if (Int32.TryParse(item_shared.user, out id_team_shared))
                                {
                                    if (!teams.Contains(id_team_shared))
                                    {
                                        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))
                                        {
                                            teams.Remove(id_team_shared);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (item_shared.type == PhanQuyenType.USERS)
                                {
                                    if (!users.Contains(item_shared.user) && !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))
                                        {
                                            users.Remove(item_shared.user);
                                        }
                                    }
                                }
                            }
                        }
                        PhanQuyenBL.RemoveByListId(lst_id_phan_quyen_can_xoa);
                    }
                    catch (Exception)
                    {
                    }
                    #endregion
                    #region Shared cho các đối tượng được chọn
                    try
                    {
                        if (users.Count == 0 && teams.Count == 0 && 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 user in users)
                            {
                                PhanQuyen pq = new PhanQuyen();
                                pq.ngay_het  = ngay_het;
                                pq.user      = user;
                                pq.type      = PhanQuyenType.USERS;
                                pq.rule      = (PhanQuyenRule)rule;
                                pq.quyen     = quyen;
                                pq.obj_type  = (PhanQuyenObjType)obj_type;
                                pq.nguoi_tao = this.user;
                                pq.obj_id    = id;

                                res.success = QLCUNL.BL.PhanQuyenBL.Index(pq);
                            }
                            foreach (var user in lst_id_nha_tuyen_dung)
                            {
                                PhanQuyen pq = new PhanQuyen();
                                pq.ngay_het  = ngay_het;
                                pq.user      = user;
                                pq.type      = PhanQuyenType.USERS;
                                pq.rule      = (PhanQuyenRule)rule;
                                pq.quyen     = quyen;
                                pq.obj_type  = (PhanQuyenObjType)obj_type;
                                pq.nguoi_tao = this.user;
                                pq.obj_id    = id;

                                res.success = QLCUNL.BL.PhanQuyenBL.Index(pq);
                            }
                            if (teams.Count > 0)
                            {
                                foreach (var id_team in teams)
                                {
                                    PhanQuyen pq = new PhanQuyen();
                                    pq.ngay_het  = ngay_het;
                                    pq.user      = id_team.ToString();
                                    pq.type      = PhanQuyenType.GROUP_USERS;
                                    pq.rule      = (PhanQuyenRule)rule;
                                    pq.quyen     = quyen;
                                    pq.nguoi_tao = user;
                                    pq.obj_type  = (PhanQuyenObjType)obj_type;
                                    pq.obj_id    = id;
                                    res.success  = QLCUNL.BL.PhanQuyenBL.Index(pq);
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                res.msg = ex.Message; res.success = false;
            }

            return(Ok(res));
        }
        public IActionResult Post([FromBody] object value)
        {
            DataResponse res = new DataResponse();

            try
            {
                res.success = false;
                string json = value.ToString();

                var obj_tk = Newtonsoft.Json.Linq.JToken.Parse(json);
                if (obj_tk != null)
                {
                    if (obj_tk["thuoc_tinh_rieng"] != null)
                    {
                        var data = Newtonsoft.Json.JsonConvert.DeserializeObject <ThuocTinhDuLieu>(json);
                        data.thuoc_tinh = obj_tk["thuoc_tinh_rieng"].ToObject <List <int> >();
                        if (data.thuoc_tinh.Count > 0)
                        {
                            bool is_valid = true;
                            if (((int)data.loai_obj) == -1)
                            {
                                res.msg  = "Cần chọn đối tượng";
                                is_valid = is_valid & false;
                            }
                            else
                            {
                                is_valid = is_valid & true;

                                if (data.thuoc_tinh == null || (data.thuoc_tinh != null && data.thuoc_tinh.Count == 0))
                                {
                                    res.msg  = "Cần chọn thuộc tính";
                                    is_valid = is_valid & false;
                                }
                                else
                                {
                                    is_valid = is_valid & true;

                                    if (string.IsNullOrEmpty(data.id_obj))
                                    {
                                        res.msg  = "Thiếu ID đối tượng";
                                        is_valid = is_valid & false;
                                    }
                                    else
                                    {
                                        is_valid = is_valid & true;
                                    }
                                }
                            }

                            if (is_valid)
                            {
                                SetMetaData(data, false);
                                res.success = QLCUNL.BL.ThuocTinhDuLieuBL.Index(data);
                            }
                        }
                    }
                    if (obj_tk["thuoc_tinh"] != null)
                    {
                        string id         = obj_tk["id_obj"].ToString();
                        string loai_obj   = obj_tk["loai_obj"].ToString();
                        var    thuoc_tinh = obj_tk["thuoc_tinh"].ToObject <List <int> >();

                        switch (loai_obj)
                        {
                        case "JOB":
                            res.success = JobBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "CONG_TY":
                            res.success = CongTyBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "NOTE_UNG_VIEN":
                            res.success = NoteUngVienBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "UNG_VIEN":
                            res.success = UngVienBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "NOTE_UNG_VIEN_JOB":
                            res.success = NoteUngVienJobBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "USER_JOB":
                            res.success = UserJobBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                res.msg = ex.Message; res.success = false;
            }

            return(Ok(res));
        }
示例#10
0
        public IActionResult SaveThuocTinh([FromBody] object value)
        {
            DataResponse res = new DataResponse();

            try
            {
                //{"id_ung_vien":"123123123123", "thuoc_tinh_ung_vien":[], "ghi_chu": "gi do", "thuoc_tinh_ghi_chu":[]}
                var obj = JToken.Parse(value.ToString());
                if (obj != null)
                {
                    var        is_ok                = false;
                    string     id_ung_vien          = obj["id_ung_vien"].ToString();
                    string     id_note_uv_job       = obj["id_obj"].ToString();
                    List <int> thuoc_tinh_uv_chung  = obj["thuoc_tinh_uv_chung"].ToObject <List <int> >();
                    List <int> thuoc_tinh_uv_rieng  = obj["thuoc_tinh_uv_rieng"].ToObject <List <int> >();
                    List <int> thuoc_tinh_job       = obj["thuoc_tinh"].ToObject <List <int> >();
                    List <int> thuoc_tinh_job_rieng = obj["thuoc_tinh_rieng"].ToObject <List <int> >();
                    //thuộc tính ứng viên
                    is_ok = QLCUNL.BL.UngVienBL.SetThuocTinh(id_ung_vien, thuoc_tinh_uv_chung);
                    if (thuoc_tinh_uv_rieng.Count > 0)
                    {
                        ThuocTinhDuLieu thuoc_tinh_rieng = new ThuocTinhDuLieu();

                        thuoc_tinh_rieng.id_obj     = id_ung_vien;
                        thuoc_tinh_rieng.loai_obj   = LoaiThuocTinh.UNG_VIEN;
                        thuoc_tinh_rieng.thuoc_tinh = thuoc_tinh_uv_rieng;
                        SetMetaData(thuoc_tinh_rieng, false);
                        is_ok = is_ok | QLCUNL.BL.ThuocTinhDuLieuBL.Index(thuoc_tinh_rieng);
                    }

                    if (thuoc_tinh_job_rieng != null)
                    {
                        var data = Newtonsoft.Json.JsonConvert.DeserializeObject <ThuocTinhDuLieu>(value.ToString());
                        data.thuoc_tinh = thuoc_tinh_job_rieng;
                        if (thuoc_tinh_job_rieng.Count > 0)
                        {
                            bool is_valid = true;
                            if (((int)data.loai_obj) == -1)
                            {
                                res.msg  = "Cần chọn đối tượng";
                                is_valid = is_valid & false;
                            }
                            else
                            {
                                is_valid = is_valid & true;

                                if (data.thuoc_tinh == null || (data.thuoc_tinh != null && data.thuoc_tinh.Count == 0))
                                {
                                    res.msg  = "Cần chọn thuộc tính";
                                    is_valid = is_valid & false;
                                }
                                else
                                {
                                    is_valid = is_valid & true;

                                    if (string.IsNullOrEmpty(data.id_obj))
                                    {
                                        res.msg  = "Thiếu ID đối tượng";
                                        is_valid = is_valid & false;
                                    }
                                    else
                                    {
                                        is_valid = is_valid & true;
                                    }
                                }
                            }

                            if (is_valid)
                            {
                                SetMetaData(data, false);
                                res.success = QLCUNL.BL.ThuocTinhDuLieuBL.Index(data);
                            }
                        }
                    }
                    if (thuoc_tinh_job != null)
                    {
                        string id         = obj["id_obj"].ToString();
                        string loai_obj   = obj["loai_obj"].ToString();
                        var    thuoc_tinh = thuoc_tinh_job;

                        switch (loai_obj)
                        {
                        case "JOB":
                            res.success = JobBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "CONG_TY":
                            res.success = CongTyBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "NOTE_UNG_VIEN":
                            res.success = NoteUngVienBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "UNG_VIEN":
                            res.success = UngVienBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "NOTE_UNG_VIEN_JOB":
                            res.success = NoteUngVienJobBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;

                        case "USER_JOB":
                            res.success = UserJobBL.UpdateThuocTinh(id, thuoc_tinh);
                            break;
                        }
                    }
                    // thuộc tính note ứng viên theo job

                    res.success = is_ok;
                }
            }
            catch (Exception ex)
            {
                res.success = false;
                res.msg     = ex.Message;
            }

            return(Ok(res));
        }