示例#1
0
        //Create new job
        public bool CreateJob(JobCreateModel model, string JobPackageName, string skill1, string skill2, string skill3, string recruiterID)
        {
            //try
            //{
            JobPackage jobPackage = this.JobPackageRepository.Get(s => s.Name == JobPackageName).FirstOrDefault();

            if (jobPackage == null)
            {
                return(false);
            }
            PurchaseJobPackage purchaseJobPackage = (from p in this.PurchaseJobPackageRepository.Get()
                                                     join j in this.JobPackageRepository.Get() on p.JobPackageID equals j.JobPackageID
                                                     where p.RecruiterID == recruiterID && p.IsApproved == true && p.IsDeleted == false &&
                                                     p.JobPackageID == jobPackage.JobPackageID &&
                                                     (from jo in this.JobRepository.Get()
                                                      where jo.PurchaseJobPackageId == p.PurchaseJobPackageID
                                                      select jo).Count() < j.JobNumber
                                                     select p)
                                                    .AsEnumerable().FirstOrDefault();

            if (purchaseJobPackage == null)
            {
                return(false);
            }

            this.JobRepository.Insert(Model_Job(model, purchaseJobPackage.PurchaseJobPackageID));
            this.Save();

            Job temp = this.JobRepository.Get(job => job.RecruiterID == model.JobInfo.RecruiterID && job.JobTitle == model.JobInfo.JobTitle).Last();

            //Add city
            foreach (int index in model.CitySelectList)
            {
                JobCity item = new JobCity();
                item.JobID  = temp.JobID;
                item.CityID = index;
                this.JobCityRepository.Insert(item);
                this.Save();
            }

            //Add category
            foreach (int index in model.CategorySelectList)
            {
                JobCategory item = new JobCategory();
                item.JobID      = temp.JobID;
                item.CategoryID = index;
                this.JobCategoryRepository.Insert(item);
                this.Save();
            }

            //Skill part
            if (!String.IsNullOrEmpty(skill1))
            {
                Skill s1 = this.SkillRepository.Get(skill => skill.SkillTag == skill1).SingleOrDefault();
                if (s1 != null)
                {
                    JobSkill tempjs1 = new JobSkill();
                    tempjs1.JobID     = temp.JobID;
                    tempjs1.Skill_ID  = s1.Skill_ID;
                    tempjs1.IsDeleted = false;
                    this.JobSkillRepository.Insert(tempjs1);
                    this.Save();
                }
                else
                {
                    Skill temps1 = new Skill();
                    temps1.SkillTag  = skill1;
                    temps1.IsDeleted = false;
                    this.SkillRepository.Insert(temps1);
                    this.Save();
                    JobSkill tempjs1 = new JobSkill();
                    tempjs1.JobID     = temp.JobID;
                    tempjs1.Skill_ID  = this.SkillRepository.Get(skill => skill.SkillTag == temps1.SkillTag).LastOrDefault().Skill_ID;
                    tempjs1.IsDeleted = false;
                    this.JobSkillRepository.Insert(tempjs1);
                    this.Save();
                }
            }

            if (!String.IsNullOrEmpty(skill2))
            {
                Skill s2 = this.SkillRepository.Get(skill => skill.SkillTag == skill2).SingleOrDefault();
                if (s2 != null)
                {
                    JobSkill tempjs2 = new JobSkill();
                    tempjs2.JobID     = temp.JobID;
                    tempjs2.Skill_ID  = s2.Skill_ID;
                    tempjs2.IsDeleted = false;
                    this.JobSkillRepository.Insert(tempjs2);
                    this.Save();
                }
                else
                {
                    Skill temps2 = new Skill();
                    temps2.SkillTag  = skill2;
                    temps2.IsDeleted = false;
                    this.SkillRepository.Insert(temps2);
                    this.Save();
                    JobSkill tempjs2 = new JobSkill();
                    tempjs2.JobID     = temp.JobID;
                    tempjs2.Skill_ID  = this.SkillRepository.Get(skill => skill.SkillTag == temps2.SkillTag).LastOrDefault().Skill_ID;
                    tempjs2.IsDeleted = false;
                    this.JobSkillRepository.Insert(tempjs2);
                    this.Save();
                }
            }
            if (!String.IsNullOrEmpty(skill3))
            {
                Skill s3 = this.SkillRepository.Get(skill => skill.SkillTag == skill3).SingleOrDefault();
                if (s3 != null)
                {
                    JobSkill tempjs3 = new JobSkill();
                    tempjs3.JobID     = temp.JobID;
                    tempjs3.Skill_ID  = s3.Skill_ID;
                    tempjs3.IsDeleted = false;
                    this.JobSkillRepository.Insert(tempjs3);
                    this.Save();
                }
                else
                {
                    Skill temps3 = new Skill();
                    temps3.SkillTag  = skill3;
                    temps3.IsDeleted = false;
                    this.SkillRepository.Insert(temps3);
                    this.Save();
                    JobSkill tempjs3 = new JobSkill();
                    tempjs3.JobID     = temp.JobID;
                    tempjs3.Skill_ID  = this.SkillRepository.Get(skill => skill.SkillTag == temps3.SkillTag).LastOrDefault().Skill_ID;
                    tempjs3.IsDeleted = false;
                    this.JobSkillRepository.Insert(tempjs3);
                    this.Save();
                }
            }
            return(true);
            //}
            //catch
            //{
            //    return false;
            //}
        }
示例#2
0
        public JJobItem GetJobDetail(int jobID)
        {
            Job jobDetail = this.JobRepository.GetByID(jobID);
            PurchaseJobPackage purchaseJobPackage = this.PurchaseJobPackageRepository.GetByID(jobDetail.PurchaseJobPackageId);
            JobPackage         jobPackage         = this.JobPackageRepository.GetByID(purchaseJobPackage.JobPackageID);

            jobDetail.JobView += Int64.Parse(jobPackage.ViewMultiNumber.GetValueOrDefault() <= 0 ? "1" : jobPackage.ViewMultiNumber.ToString());
            this.JobRepository.Update(jobDetail);
            Save();

            JJobItem job = (from j in this.JobRepository.Get()
                            join c in this.CompanyInfoRepository.Get() on j.RecruiterID equals c.RecruiterID
                            join d in this.JobLevelRepository.Get() on j.JobLevel_ID equals d.JobLevel_ID
                            join e in this.JobCategoryRepository.Get() on j.JobID equals e.JobID
                            join f in this.SchoolLevelRepository.Get() on j.MinSchoolLevel_ID equals f.SchoolLevel_ID
                            where ((j.JobID == jobID) && (c.IsVisible = true) && (j.IsPublic = true) && (j.StartedDate <= DateTime.Now) && (j.EndedDate >= DateTime.Now))
                            select new JJobItem()
            {
                JobID = j.JobID,
                RecruiterID = j.RecruiterID,
                JobTitle = j.JobTitle,
                LogoURL = c.LogoURL,
                JobLevelName = d.Name,
                MinSalary = j.MinSalary,
                MaxSalary = j.MaxSalary,
                PostedDate = j.StartedDate,
                SchoolLevel = f.LevelNum,
                Company = c.Company,
                Address = c.Address,
                JobView = j.JobView,
                JobDescription = j.JobDescription,
                JobRequirement = j.JobRequirement,
                CompanyDescription = c.Description
            }).ToArray().First();

            job.ApplicantNumber = this.AppliedJobRepository.Get(filter: m => m.JobID == jobID).Count();

            job.JobCities = (from a in this.JobCityRepository.Get()
                             join b in this.CityRepository.Get() on a.CityID equals b.CityID
                             where a.JobID == job.JobID
                             select new JJobCity()
            {
                CityID = a.CityID,
                Name = b.Name
            }).ToArray();
            job.JobSkills = (from a in this.JobSkillRepository.Get()
                             join b in this.SkillRepository.Get() on a.Skill_ID equals b.Skill_ID
                             where a.JobID == job.JobID
                             select new JJobSkill()
            {
                JobID = a.JobID,
                SkillID = b.Skill_ID,
                SkillTag = b.SkillTag
            }).ToArray();
            job.JobCategory = (from a in this.JobCategoryRepository.Get()
                               join b in this.CategoryRepository.Get() on a.CategoryID equals b.CategoryID
                               where a.JobID == job.JobID
                               select new JJobCategory()
            {
                JobID = a.JobID,
                CategoryID = b.CategoryID,
                Name = b.Name
            }).ToArray();

            return(job);
        }