public List <JobDTO> GetJobs()
        {
            var JobDTOs = new JobBL().Get();

            if (JobDTOs != null)
            {
                foreach (var JobDTO in JobDTOs)
                {
                    if (JobDTO.JobApplications != null)
                    {
                        foreach (var JobApplication in JobDTO.JobApplications)
                        {
                            JobApplication.User = new UsersBL().Get(JobApplication.ApplicantUserID);
                        }
                    }
                    //var businessUsers = new BusinessUserMapBL().Get().Where(p => p.BusinessID == JobDTO.Business.BusinessID);
                    //if (businessUsers != null)
                    //{
                    //    if (businessUsers.Count(p => p.IsOwner == true) > 0)
                    //        JobDTO.Business.User = new UsersBL().Get(businessUsers.FirstOrDefault(p => p.IsOwner == true).UserID);
                    //}
                }
            }
            return(JobDTOs.ToList());
        }
예제 #2
0
        //<summary>Admin method to give access admin to the admin manual</summary>
        private static void AdminLogin()
        {
            try
            {
                int    adminId;
                string password;

                Console.WriteLine("Enter admin id");
                adminId = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("Enter admin password");
                password = Console.ReadLine();

                bool loginAdmin = JobBL.LoginAdminBL(adminId, password);
                if (loginAdmin)
                {
                    Console.WriteLine("Login Successful.");
                    AdminMenu();
                }

                else
                {
                    Console.WriteLine("Invalid admin id or password.");
                }
            }
            catch (JobPortalSystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #3
0
        //<summary>Delete Job method to delete a already existed job from the job list</summary>
        private static void DeleteJob()
        {
            try
            {
                string employer;
                Console.WriteLine("Enter the name of job whose details you want to delete");
                employer = Console.ReadLine();

                bool jobDeleted = JobBL.DeleteJobBL(employer);
                if (jobDeleted)
                {
                    Console.WriteLine("Job details deleted successfully");
                }
                else
                {
                    Console.WriteLine("Job details cannot be deleted");
                }
            }
            catch (JobPortalSystemException ex)
            {
                Console.WriteLine(ex.Message);
            }

            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #4
0
 //<summary>List Jobs method to list all the jobs in the job list</summary>
 private static void ListJobs()
 {
     try
     {
         List <Job> jobList = JobBL.ListJobsBl();
         if (jobList != null)
         {
             Console.WriteLine("Job Details:");
             foreach (Job job in jobList)
             {
                 Console.WriteLine("Job Name: {0}\nAddress: {1}\n" +
                                   "Contact Number: {2}\nEmail Id: {3} \nSkills Required {4}\n" +
                                   "Qualification: {5} \nLocation: {6}\nSalary: {7}\nNo Of Vacancies: {8}", job.Employer, job.Address, job.ContactNumber, job.EmailId
                                   , job.SkillsRequired, job.Qualification, job.Location, job.Salary, job.NoOfVacancies);
                 Console.WriteLine("----------------------------------------------------------------");
             }
         }
     }
     catch (JobPortalSystemException ex)
     {
         Console.WriteLine(ex.Message);
     }
     catch (SystemException ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
예제 #5
0
        public IActionResult GetNoteUngVienByIdJob(string id_job)
        {
            List <Models.NoteUngVienJobMap> lst = new List <Models.NoteUngVienJobMap>();

            //Check Owner theo ID_JOB truoc roi chay doan code duoi
            if (JobBL.IsOwner(id_job, user) || (is_app_admin || is_sys_admin))
            {
                var data_note_ung_vien = BL.NoteUngVienJobBL.GetNoteUngVienJobByIdJobOwner(app_id, id_job);
                var lst_id_job         = data_note_ung_vien.Select(x => x.id_job);
                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 lst_id_ung_vien    = data_note_ung_vien.Select(x => x.id_ung_vien);
                var data_ung_vien      = QLCUNL.BL.UngVienBL.GetMany(lst_id_ung_vien).ToDictionary(x => x.id_ung_vien, y => y);
                foreach (var item in data_note_ung_vien)
                {
                    var lst_id_thuoc_tinh    = item.thuoc_tinh != null ? item.thuoc_tinh : new List <int>();
                    var lst_thuoc_tinh_rieng = QLCUNL.BL.ThuocTinhDuLieuBL.GetIdThuocTinhByIdObj(app_id, item.id_note_ung_vien_job, user);

                    var data_thuoc_tinh = QLCUNL.BL.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 = QLCUNL.BL.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(item, data_job, data_ung_vien, data_thuoc_tinh);

                    lst.Add(note);
                }
            }
            return(Ok(new DataResponsePaging()
            {
                data = lst, success = true, msg = "", total = lst.Count
            }));
        }
예제 #6
0
        //<summary>User Login method to give access any user the user manual</summary>
        private static void UserLogin()
        {
            try
            {
                int    userId;
                string password;

                Console.WriteLine("Enter user id");
                userId = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("Enter user password");
                password = Console.ReadLine();

                bool loginUser = JobBL.LoginUserBL(userId, password);
                if (loginUser)
                {
                    Console.WriteLine("Login Successful.");
                    UserMenu();
                }

                else
                {
                    Console.WriteLine("Invalid user id or password.");
                }
            }
            catch (JobPortalSystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #7
0
        //<summary>Edit Job method to edit a already existed job in the job list</summary>
        private static void EditJob()
        {
            try
            {
                Job    objJob = new Job();
                string employer;
                Console.WriteLine("Enter job name whose job details you want to edit");
                employer = (Console.ReadLine());

                objJob = JobBL.SearchJobBL(employer);
                if (objJob != null)
                {
                    Console.WriteLine("Enter new address");
                    objJob.Address = (Console.ReadLine());

                    Console.WriteLine("Enter new contact number");
                    objJob.ContactNumber = Convert.ToDouble(Console.ReadLine());

                    Console.WriteLine("Enter new contact email id");
                    objJob.EmailId = (Console.ReadLine());

                    Console.WriteLine("Enter new skill required");
                    objJob.SkillsRequired = (Console.ReadLine());

                    Console.WriteLine("Enter new qualification");
                    objJob.Qualification = (Console.ReadLine());

                    Console.WriteLine("Enter new location");
                    objJob.Location = (Console.ReadLine());

                    Console.WriteLine("Enter new salary");
                    objJob.Salary = Convert.ToDouble(Console.ReadLine());

                    Console.WriteLine("Enter no of vacancies");
                    objJob.NoOfVacancies = Convert.ToInt32(Console.ReadLine());

                    bool jobEdited = JobBL.EditJobBL(objJob);
                    if (jobEdited)
                    {
                        Console.WriteLine("Job Details Edited Successfully.");
                    }
                    else
                    {
                        Console.WriteLine("Job details cannot be edited");
                    }
                }
            }
            catch (JobPortalSystemException ex)
            {
                Console.WriteLine(ex.Message);
            }

            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #8
0
 public bool Delete(string id)
 {
     if (JobBL.IsOwner(id, user) || (is_sys_admin || is_app_admin))
     {
         bool del = JobBL.DelUp(id);
         return(del);
     }
     return(false);
 }
예제 #9
0
        public async Task <IActionResult> Search(string term, 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 <CongTy> data       = new List <CongTy>();
            long          total_recs = 0;
            string        msg        = "";

            if (!string.IsNullOrEmpty(thuoc_tinh))
            {
                foreach (var tt in thuoc_tinh.Split(','))
                {
                    int t = -1;
                    if (int.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.CONG_TY, lst_thuoc_tinh_rieng, page, out long total_recs_thuoc_tinh, out _, 9999);
                    lst_id = lst_id_obj.Select(x => x.id_obj).Where(o => !string.IsNullOrEmpty(o)).ToList();
                }
            }
            if (is_find_thuoc_tinh_rieng && lst_id.Count == 0 && lst_thuoc_tinh.Count == 0)
            {
            }
            else
            {
                var lst_id_job_duoc_giao = await UserJobBL.GetListIdJobByUser(app_id, new List <string>() { user });

                var lst_id_cong_ty_phan_theo_job = await JobBL.GetListIdCongTyByIdJob(app_id, lst_id_job_duoc_giao);


                data = QLCUNL.BL.CongTyBL.Search(app_id, user, group, term, lst_thuoc_tinh, lst_id, lst_id_cong_ty_phan_theo_job, page, out total_recs, out msg, page_size, (is_sys_admin || is_app_admin));
            }

            return(Ok(new DataResponsePaging()
            {
                data = data, total = total_recs, success = data != null, msg = msg
            }));
        }
예제 #10
0
 public IActionResult IsIdAutoExist(string id_auto)
 {
     if (id_auto != null)
     {
         var is_exist = JobBL.IsIdAutoExist(id_auto, app_id);
         return(Ok(new DataResponse()
         {
             data = is_exist, success = true, msg = ""
         }));
     }
     return(Ok(new DataResponse()));
 }
예제 #11
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 = ""
            }));
        }
예제 #12
0
        //<summary>Search Job method to search a job based on name from the job list</summary>
        private static void SearchJob()
        {
            try
            {
                string employer;
                Console.WriteLine("Enter the job name whose details you want to search");
                employer = Console.ReadLine();
                Job objJob = new Job();
                objJob = JobBL.SearchJobBL(employer);
                if (objJob != null)
                {
                    Console.WriteLine("******************************************************************************");
                    Console.WriteLine("Searched Job Details: ");
                    Console.WriteLine("******************************************************************************");
                    Console.WriteLine("Job Name: {0}\n Address: {1}\n" +
                                      "Contact Number: {2}\nEmail Id: {3} \nSkills Required {4}\n" +
                                      "Qualification: {5} \nLocation: {6}\nSalary: {7}\nNo Of Vacancies: {8}", objJob.Employer, objJob.Address, objJob.ContactNumber, objJob.EmailId
                                      , objJob.SkillsRequired, objJob.Qualification, objJob.Location, objJob.Salary, objJob.NoOfVacancies);
                    Console.WriteLine("******************************************************************************");
                }
                else
                {
                    Console.WriteLine("No such job listed");
                }
            }

            catch (JobPortalSystemException ex)
            {
                Console.WriteLine(ex.Message);
            }

            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #13
0
        public IActionResult Grant([FromBody] object value)
        {
            DataResponse res = new DataResponse();

            try
            {
                var obj = JToken.Parse(value.ToString());

                if (obj != null)
                {
                    var users = obj["users"].ToObject <List <string> >();

                    var id_job = obj["id"].ToString();

                    // cũ
                    var data = QLCUNL.BL.UserJobBL.GetByIdJob(app_id, id_job);

                    var lst_id_user = data.Select(x => x.id_user).ToList();

                    var lst_id_user_job = data.Select(o => o.id_user_job);

                    // list id cần xóa
                    var lst_user_need_delete = lst_id_user.Except(users);

                    var lst_can_xoa = data.Where(x => lst_user_need_delete.Contains(x.id_user)).Select(x => x.id_user_job);


                    var lst_id_ung_vien = NoteUngVienJobBL.GetListIdUngVienByIdUserJobNew(app_id, lst_can_xoa).Select(x => x.Key);

                    var lst_phai_xoa = lst_can_xoa.Except(lst_id_ung_vien);
                    if (lst_phai_xoa.Any() == true)
                    {
                        BL.UserJobBL.DeleteByIdUserJob(lst_phai_xoa);
                    }
                    //Check quyền xem User hiện tại có phải owner của Job hoặc admin hay không. Chỉ cho phép chủ sở hữu hoặc admin gán

                    if (JobBL.IsOwner(id_job, user) || is_app_admin)
                    {
                        List <UserJob> lst = new List <UserJob>();
                        foreach (var id_user in users)
                        {
                            var user_job = new UserJob();
                            user_job.id_job        = id_job;
                            user_job.ngay_nhan_job = XMedia.XUtil.TimeInEpoch(DateTime.Now);
                            user_job.id_user       = id_user;
                            user_job.nguoi_sua     = user;
                            user_job.nguoi_tao     = user;
                            SetMetaData(user_job, false);
                            lst.Add(user_job);
                        }

                        int count_success = QLCUNL.BL.UserJobBL.IndexMany(lst);
                        res.success = count_success > 0;
                        res.msg     = $"Đã gán JOB cho: {string.Join(" ", users)}";
                    }
                    else
                    {
                        res.success = false; res.msg = "Bạn không có quyền trên JOB này";
                    }
                }
            }
            catch (Exception ex)
            {
                res.msg = ex.Message; res.success = false;
            }

            return(Ok(res));
        }
예제 #14
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));
        }
예제 #15
0
        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
            }));
        }
예제 #16
0
        public IActionResult ThongKeThuocTinh(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)
        {
            List <string> lst_id = new List <string>();
            List <string> lst_id_obj_thuoc_tinh_rieng = new List <string>();
            List <string> lst_id_should         = new List <string>();
            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>();

            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          = "";
            var    dic_thong_ke = new Dictionary <int, long>();
            var    dic_thong_ke_thuoc_tinh_rieng = new Dictionary <int, long>();

            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_tinh2))
            {
                foreach (var tt in thuoc_tinh2.Split(','))
                {
                    int t = -1;
                    if (Int32.TryParse(tt, out t))
                    {
                        lst_thuoc_tinh2.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 = BL.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();
                    }

                    lst_id_obj_thuoc_tinh_rieng = lst_id_obj.Select(x => x.id).ToList();
                }
                else
                {
                    lst_id = new List <string>()
                    {
                        "__NULL__"
                    };
                    lst_id_obj_thuoc_tinh_rieng = new List <string>()
                    {
                        "__NULL__"
                    };
                }
            }

            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();
                lst_id_should.AddRange(lst_id_job);
            }

            var tuple = BL.JobBL.ThongKeTheoThuocTinh(app_id, user, group, term, id_ung_vien, id_cong_ty, ngay_di_lam_from, ngay_di_lam_to, don_gia_from, don_gia_to, lst_thuoc_tinh, lst_id, lst_id_should,
                                                      ngay_tao_from, ngay_tao_to, page, out long _total_recs, out string _msg, 9999, (is_sys_admin || is_app_admin || is_super_user), null, op, lst_thuoc_tinh2, op2);

            dic_thong_ke = tuple.Item1;
            var lst_id_out = tuple.Item2;

            if (lst_id_out.Count == 0)
            {
                lst_id_out = new List <string>()
                {
                    "__NULL__"
                };
            }
            //Nếu có thuộc tính chung và điều kiện là chứa tất cả thì phải tìm lại các bản ghi Job trước sau đó truyền vào bảng ThuocTinhDuLieu để tìm tiếp với các điều kiện của thuộc tính riêng

            var lst_must_not_id = JobBL.GetIdDeleted(app_id);

            dic_thong_ke_thuoc_tinh_rieng = ThuocTinhDuLieuBL.ThongKeTheoThuocTinh(app_id, user, LoaiThuocTinh.JOB, lst_thuoc_tinh_rieng, lst_id_out, new List <string>(), lst_must_not_id, (is_app_admin || is_app_admin), op);

            return(Ok(new { data_rieng = dic_thong_ke_thuoc_tinh_rieng.Select(x => new { k = x.Key, v = x.Value }), data = dic_thong_ke.Select(x => new { k = x.Key, v = x.Value }), success = true, msg = "" }));
        }
        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));
        }
예제 #18
0
        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));
        }
예제 #19
0
        //<summary>Register method to regsiter any new user</summary>
        private static void RegisterUser()
        {
            try
            {
                UserInfo objUser = new UserInfo();


                Console.WriteLine("Enter your first name");
                objUser.FirstName = (Console.ReadLine());
                while (objUser.FirstName.Length == 0)
                {
                    Console.WriteLine("First Name should not be empty");
                    objUser.FirstName = Console.ReadLine();
                    if (objUser.FirstName.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter your last name");
                objUser.LastName = (Console.ReadLine());
                while (objUser.LastName.Length == 0)
                {
                    Console.WriteLine("Last Name should not be empty");
                    objUser.LastName = Console.ReadLine();
                    if (objUser.LastName.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter your password");
                objUser.Password = (Console.ReadLine());
                while (objUser.Password.Length == 0)
                {
                    Console.WriteLine("Password should not be empty");
                    objUser.Password = Console.ReadLine();
                    if (objUser.Password.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter your age");
                string age = Console.ReadLine();
                int    resAge;
                while (!int.TryParse(age, out resAge))
                {
                    Console.WriteLine("Please enter a valid age. It should be a number.");
                    age = Console.ReadLine();
                    if (!int.TryParse(age, out resAge))
                    {
                        break;
                    }
                }
                objUser.Age = Convert.ToInt32(age);

                int choice;
                Console.WriteLine("Select your gender:\n1:Male\n2:Female");
                do
                {
                    choice = Convert.ToInt32(Console.ReadLine());
                    switch (choice)
                    {
                    case 1:
                        objUser.Gender = "Male";
                        break;

                    case 2:
                        objUser.Gender = "Female";
                        break;

                    default:
                        Console.WriteLine("please enter a valid choice");
                        break;
                    }
                } while (choice != 1 && choice != 2);


                Console.WriteLine("Enter your address");
                objUser.Address = (Console.ReadLine());
                while (objUser.Address.Length == 0)
                {
                    Console.WriteLine("Address should not be empty");
                    objUser.Address = Console.ReadLine();
                    if (objUser.Address.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter your phone number");
                string phoneNo = Console.ReadLine();
                double resPhoneNo;
                while (!double.TryParse(phoneNo, out resPhoneNo))
                {
                    Console.WriteLine("Please enter a valid phone no. It should be a number.");
                    phoneNo = Console.ReadLine();
                    if (!double.TryParse(phoneNo, out resPhoneNo))
                    {
                        break;
                    }
                }
                objUser.PhoneNo = Convert.ToDouble(phoneNo);



                Random     objRandom = new Random();
                List <int> randomLst = new List <int>();
                objUser.UserId = objRandom.Next(1000, 9999);
                while (true)
                {
                    if (randomLst.Contains(objUser.UserId))
                    {
                        objUser.UserId = objRandom.Next(100, 9999);
                    }
                    else
                    {
                        randomLst.Add(objUser.UserId);
                    }
                    break;
                }

                bool userAdded = JobBL.RegisterUserBL(objUser);
                if (userAdded)
                {
                    Console.WriteLine("User Registered Successfully.");
                    Console.WriteLine("Your User Id is: {0} and Password is: {1}", objUser.UserId, objUser.Password);
                }
                else
                {
                    Console.WriteLine("User cannot be regstered.");
                }
            }
            catch (JobPortalSystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
예제 #20
0
        public IActionResult Search(string term, int page, int page_size, string thuoc_tinh)
        {
            long   total_recs = 0;
            string msg        = "";
            List <JobThuocTinhMap> lst_job_map = new List <JobThuocTinhMap>();
            List <NhaTuyenDung>    data        = new List <NhaTuyenDung>();
            var        user           = User.FindFirst(x => x.Type == ClaimTypes.NameIdentifier).Value;
            List <int> lst_thuoc_tinh = new List <int>();

            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);
                    }
                }
                var lst_ntd_seen       = NoteBL.Search(lst_thuoc_tinh, out total_recs, out msg, 9999);
                var lst_ntd_get_id     = lst_ntd_seen.Select(x => x.id_obj).Distinct().Where(i => i != null);
                var all_nha_tuyen_dung = BL.NhaTuyenDungBL.GetMany(lst_ntd_get_id).Where(x => x.nguoi_tao == user && x.trang_thai != TrangThai.DELETED);
                var lst_id_job         = all_nha_tuyen_dung.Select(x => x.id_job);
                //var data_job = QLCUNL.BL.JobBL.GetMany(lst_id_job).Where(x => x.owner == user && all_nha_tuyen_dung.Select(y => y.id_job).Contains(x.id_job));
                var data_job = QLCUNL.BL.JobBL.GetMany(lst_id_job);
                var list_job = data_job.ToDictionary(x => x.id_job, y => y);
                all_nha_tuyen_dung = all_nha_tuyen_dung.Where(o => data_job.Select(u => u.id_job).Contains(o.id_job)).ToList();
                foreach (var item in all_nha_tuyen_dung)
                {
                    JobThuocTinhMap job_map = new JobThuocTinhMap(item, list_job);
                    lst_job_map.Add(job_map);
                }
                return(Ok(new { data = lst_job_map, total = all_nha_tuyen_dung.Count(), success = lst_job_map != null, msg = msg }));
            }
            else
            {
                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));
                var                 lst_job_in_user_job = user_job.Select(x => x.id_job);
                string[]            fields = new string[] { "id_job", "chuc_danh" };
                List <NhaTuyenDung> result = new List <NhaTuyenDung>();

                var all_job = JobBL.GetAllJobsIsOwner(app_id, user, fields, (is_app_admin || is_sys_admin));

                var lst_id_job_is_owner = all_job.Select(x => x.id_job);

                // viet query get all nha tuyen dung

                var all_nha_tuyen_dung = BL.NhaTuyenDungBL.GetAllNhaTuyenDung(term, new List <int>(), app_id, page, out long total_rec, out msg, 9999, (is_app_admin || is_app_admin)).Where(x => x.nguoi_tao == user || lst_id_job_is_owner.Contains(x.id_job));

                //all_nha_tuyen_dung = NhaTuyenDungBL.Search(term, lst_thuoc_tinh, app_id, user, page, "", out total_recs, out msg, page_size, (is_sys_admin || is_app_admin));

                var lst_id_job = all_nha_tuyen_dung.Select(x => x.id_job);

                var data_job = JobBL.GetMany(lst_id_job).Where(x => x.owner == user || (is_app_admin || is_sys_admin) || lst_job_in_user_job.Contains(x.id_job));
                var list_job = data_job.ToDictionary(x => x.id_job, y => y);

                //.Where(x => data_job.Any(e => e.id_job == x.id_job) && x.nguoi_tao == user || (is_app_admin || is_sys_admin))
                foreach (var item in all_nha_tuyen_dung)
                {
                    JobThuocTinhMap job_map = new JobThuocTinhMap(item, list_job);
                    lst_job_map.Add(job_map);
                }
                return(Ok(new DataResponsePaging {
                    data = lst_job_map, total = lst_job_map.Count, success = lst_job_map != null, msg = msg
                }));
            }
        }
예제 #21
0
        //<summary>Add Job method to add a new job in the job list</summary>
        private static void AddJob()
        {
            try
            {
                Job objJob = new Job();

                Console.WriteLine("Enter job name");
                objJob.Employer = (Console.ReadLine());
                while (objJob.Employer.Length == 0)
                {
                    Console.WriteLine("Job Name should not be empty");
                    objJob.Employer = Console.ReadLine();
                    if (objJob.Employer.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter address");
                objJob.Address = (Console.ReadLine());
                while (objJob.Address.Length == 0)
                {
                    Console.WriteLine("Address should not be empty");
                    objJob.Address = Console.ReadLine();
                    if (objJob.Address.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter contact number");
                string contactNo = Console.ReadLine();
                double resContactNo;
                while (!double.TryParse(contactNo, out resContactNo))
                {
                    Console.WriteLine("Please enter a valid phone no. It should be a number.");
                    contactNo = Console.ReadLine();
                    if (!double.TryParse(contactNo, out resContactNo))
                    {
                        break;
                    }
                }
                objJob.ContactNumber = Convert.ToDouble(contactNo);

                Console.WriteLine("Enter contact email id");
                objJob.EmailId = (Console.ReadLine());
                while (objJob.EmailId.Length == 0)
                {
                    Console.WriteLine("EmailId should not be empty");
                    objJob.EmailId = Console.ReadLine();
                    if (objJob.EmailId.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter skill required");
                objJob.SkillsRequired = (Console.ReadLine());
                while (objJob.SkillsRequired.Length == 0)
                {
                    Console.WriteLine("Skill should not be empty");
                    objJob.SkillsRequired = Console.ReadLine();
                    if (objJob.SkillsRequired.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter qualification");
                objJob.Qualification = (Console.ReadLine());
                while (objJob.Qualification.Length == 0)
                {
                    Console.WriteLine("Qualification should not be empty");
                    objJob.Qualification = Console.ReadLine();
                    if (objJob.Qualification.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter location");
                objJob.Location = (Console.ReadLine());
                while (objJob.Location.Length == 0)
                {
                    Console.WriteLine("Location should not be empty");
                    objJob.Location = Console.ReadLine();
                    if (objJob.Location.Length != 0)
                    {
                        break;
                    }
                }

                Console.WriteLine("Enter salary");
                string salary = Console.ReadLine();
                double reSalary;
                while (!double.TryParse(salary, out reSalary))
                {
                    Console.WriteLine("Please enter a valid salary. It should be a number.");
                    salary = Console.ReadLine();
                    if (!double.TryParse(salary, out reSalary))
                    {
                        break;
                    }
                }
                objJob.Salary = Convert.ToDouble(salary);

                Console.WriteLine("Enter no of vacancies");
                string noOfVacancies = Console.ReadLine();
                int    resNoOfVacancies;
                while (!int.TryParse(noOfVacancies, out resNoOfVacancies))
                {
                    Console.WriteLine("Please enter a valid no of vacancies. It should be a number.");
                    noOfVacancies = Console.ReadLine();
                    if (!int.TryParse(noOfVacancies, out resNoOfVacancies))
                    {
                        break;
                    }
                }
                objJob.NoOfVacancies = Convert.ToInt32(noOfVacancies);

                Random     objRandom  = new Random();
                List <int> randomList = new List <int>();
                objJob.JobId = objRandom.Next(1000, 9999);
                while (true)
                {
                    if (randomList.Contains(objJob.JobId))
                    {
                        objJob.JobId = objRandom.Next(100, 9999);
                    }
                    else
                    {
                        randomList.Add(objJob.JobId);
                    }
                    break;
                }

                bool jobAdded = JobBL.AddJobBL(objJob);
                if (jobAdded)
                {
                    Console.WriteLine("Job Details Added Successfully.");
                }
                else
                {
                    Console.WriteLine("Job details cannot be added");
                }
            }
            catch (JobPortalSystemException ex)
            {
                Console.WriteLine(ex.Message);
            }

            catch (SystemException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }