public static RecommendedJobDto createRecommendedJobDTO(RecommendedJob obj)
 {
     RecommendedJobDto task = new RecommendedJobDto();
     task.JobId = obj.JobId;
     task.RecruiteeId = obj.RecruiteeId;
     task.PredictedRankingValue = (double)obj.PredictedRankingValue;
     return task;
 }
 public static RecommendedJob createRecommendedJob(Guid JobId, Guid RecruiteeId, decimal PredictedRankingValue)
 {
     RecommendedJob obj = new RecommendedJob();
     obj.JobId = JobId;
     obj.RecruiteeId = RecruiteeId;
     obj.PredictedRankingValue = PredictedRankingValue;
     return obj;
 }
 public List<RecommendedJob> selectRecommendedJobByRecruiteeId(RecommendedJob obj)
 {
     try
     {
         IRecommendedJobSvc svc = (IRecommendedJobSvc)this.getService(typeof(IRecommendedJobSvc).Name);
         return svc.selectRecommendedJobByRecruiteeId(obj);
     }
     catch (ServiceLoadException ex)
     {
         return null;
     }
 }
 public Boolean deleteRecommendedJob(RecommendedJob obj)
 {
     try
     {
         IRecommendedJobSvc svc = (IRecommendedJobSvc)this.getService(typeof(IRecommendedJobSvc).Name);
         return svc.deleteRecommendedJob(obj);
     }
     catch (ServiceLoadException ex)
     {
         return false;
     }
 }
        public Boolean insertRecommendedJob(RecommendedJob obj)
        {
            using (NewElasticBankContext db = new NewElasticBankContext())
            {
                try
                {
                    db.RecommendedJobs.Add(obj);
                    db.SaveChanges();
                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }

            }
        }
 public bool insertRecommenderJob(DataResult avgs)
 {
     try
     {
         bool flag = false;
         RecommendedJobManager mgr = new RecommendedJobManager();
         for (int n = 0; n < avgs.Number_top_jobs; n++)
         {
             RecommendedJob job = new RecommendedJob();
             job.RecruiteeId = new Guid(avgs.User_profile.UserID);
             job.JobId = new Guid(avgs.TopJobNames[n]);
             job.PredictedRankingValue = (decimal)avgs.Mylist.ElementAt(n).PredRecJob;
             flag = mgr.insertRecommendedJob(job);
         }
         return flag;
     }
     catch (Exception ex)
     {
         return false;
     }
 }
        public Boolean deleteRecommendedJob(RecommendedJob obj)
        {
            using (NewElasticBankContext db = new NewElasticBankContext())
            {
                try
                {
                    RecommendedJob rec_job = db.RecommendedJobs.SqlQuery("dbo.SelectRecommendedJobByJobIdAndRecruiteeId @JobId='" + obj.JobId.ToString() + "' @RecruiteeId='" + obj.RecruiteeId.ToString() + "'").Single();

                    if (rec_job != null)
                    {
                        db.RecommendedJobs.Remove(rec_job);
                        #region Database Submission

                        try
                        {
                            db.SaveChanges();
                            return true;
                        }
                        catch (Exception ex)
                        {
                            return false;
                        }

                        #endregion
                    }
                    else
                    {
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
        }
    public List<RecommendedJobDto> selectRecommendedJobByRecruiteeId(Guid RecruiteeId)
    {
        RecommendedJobManager mgr = new RecommendedJobManager();
        RecommendedJob obj = new RecommendedJob();
        obj.RecruiteeId = RecruiteeId;
        List<RecommendedJob> recJobList = mgr.selectRecommendedJobByRecruiteeId(obj);
        List<RecommendedJobDto> dtoList = new List<RecommendedJobDto>();

        foreach (RecommendedJob task in recJobList)
        {
            dtoList.Add(RecommendedJobDto.createRecommendedJobDTO(task));
        }

        return dtoList;
    }
 public RecommendedJobDto selectRecommendedJobByJobIdAndRecruiteeId(Guid JobId, Guid RecruiteeId)
 {
     RecommendedJobManager mgr = new RecommendedJobManager();
     RecommendedJob obj = new RecommendedJob();
     obj.JobId = JobId;
     obj.RecruiteeId = RecruiteeId;
     obj = mgr.selectRecommendedJobByJobIdAndRecruiteeId(obj);
     if (obj != null)
     {
         return RecommendedJobDto.createRecommendedJobDTO(obj);
     }
     else
     {
         return null;
     }
 }
        public RecommendedJob selectRecommendedJobByJobIdAndRecruiteeId(RecommendedJob obj)
        {
            NewElasticBankContext db = new NewElasticBankContext();

            try
            {
                return db.RecommendedJobs.SqlQuery("dbo.SelectRecommendedJobByJobIdAndRecruiteeId @JobId='" + obj.JobId.ToString() + "', @RecruiteeId='" + obj.RecruiteeId.ToString() + "'").Single();
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        public List<RecommendedJob> selectRecommendedJobByRecruiteeId(RecommendedJob obj)
        {
            NewElasticBankContext db = new NewElasticBankContext();

            try
            {
                return db.Database.SqlQuery(typeof(RecommendedJob), "dbo.SelectRecommendedJobByRecruiteeId @RecruiteeId='" + obj.RecruiteeId.ToString() + "'").Cast<RecommendedJob>().ToList();
            }
            catch (Exception ex)
            {
                return null;
            }
        }