public bool Delete(string id) { bool del = NoteUngVienBL.Delete(id); return(del); }
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)); }
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 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)); }