public ActionResult Add()
 {
     List<string> lstPostionTypes = new List<string>();
     List<string> lstJobCatgs = new List<string>();
     List<string> lstExps = new List<string>();
     List<string> lstPartners = new List<string>();
     Business.CommonFunctions cf = new CommonFunctions();
     foreach (string item in CommonFunctions.m_listJobPosition)
     {
         lstPostionTypes.Add(item);
     }
     ViewData["PostTypes"] = lstPostionTypes;
     foreach (string item in CommonFunctions.m_listJobCategoires)
     {
         lstJobCatgs.Add(item);
     }
     ViewData["JobCatgs"] = new SelectList(lstJobCatgs);
     foreach (string item in CommonFunctions.m_listJobExperience)
     {
         lstExps.Add(item);
     }
     ViewData["Exps"] = new SelectList(lstExps);
     return View();
 }
        public Job getPublicJobById(string intJobId)
        {
            CommonFunctions cf = new CommonFunctions();
            try
            {
                Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();
                Business.ApplicationService.jobs sjob = new Business.ApplicationService.jobs();
                sjob = appclient.GetJob(intJobId, "", "", "");

                Job tempjob = new Job();
                tempjob.JobId = sjob.jobid;
                tempjob.JobIDforPublisPartnersList = 0;
                tempjob.JobName = sjob.jobname;
                tempjob.Exp = CommonFunctions.MapIDtoExperience[sjob.expid.ToString()].ToString();
                tempjob.PayRate = sjob.payrate;
                tempjob.PrefSkills = sjob.preferenceskills;
                tempjob.Status = sjob.status;
                tempjob.State = sjob.cityid;
                tempjob.JobLength = sjob.additionaldetails;
                tempjob.Email = sjob.email;
                tempjob.Phone = sjob.phone;
                tempjob.jobdata = sjob.data;
                tempjob.CompanyId = sjob.objectid;
                try
                {
                    tempjob.ExpiryDate = new DateTime(Convert.ToInt32(sjob.endyear), Convert.ToInt32(sjob.endmonth), Convert.ToInt32(sjob.enddate));
                }
                catch (Exception enddatexception)
                {

                    string strdatexceptioninfo = enddatexception.Message;
                }
                try
                {
                    tempjob.StartDate = new DateTime(Convert.ToInt32(sjob.startyear), Convert.ToInt32(sjob.startmonth), Convert.ToInt32(sjob.startdate));
                }
                catch (Exception strdatexception)
                {

                    string strdatexceptioninfo = strdatexception.Message;
                }
                tempjob.jobmailstatus = sjob.emailstatus;
                try
                {
                    tempjob.createddate = DateTime.Parse(sjob.createddate);
                }
                catch (Exception createddatexception)
                {

                    string strdatexceptioninfo = createddatexception.Message;
                }
                tempjob.JobDesc = sjob.jobdescription;
                tempjob.additionaldetails = sjob.additionaldetails;
                try
                {
                    tempjob.postype = CommonFunctions.MapIDtoPosition[sjob.positiontype].ToString();
                }
                catch { }

                return tempjob;

            }

            catch { throw; }
        }
        public List<Job> getJobDetailsByJobId(string intJobId, string companyid)
        {
            CommonFunctions cf = new CommonFunctions();
            try
            {
                Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();
                Business.ApplicationService.jobs sjob = new Business.ApplicationService.jobs();
                sjob = appclient.GetJob(intJobId, "", "", companyid);

                Job tempjob = new Job();

                tempjob.JobId = sjob.jobid;
                tempjob.JobIDforPublisPartnersList = 0;
                tempjob.JobName = sjob.jobname;
                tempjob.Exp = CommonFunctions.MapIDtoExperience[sjob.expid.ToString()].ToString();
                tempjob.PayRate = sjob.payrate;
                tempjob.PrefSkills = sjob.preferenceskills;
                tempjob.Status = sjob.status;
                tempjob.State = sjob.cityid;
                tempjob.JobLength = sjob.additionaldetails;
                tempjob.Email = sjob.email;
                tempjob.Phone = sjob.phone;
                tempjob.jobdata = sjob.data;
                UI.Models.Job Objob = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.Models.Job>(sjob.data);
                tempjob.payratemax = Objob.payratemax;
                tempjob.payratemode = Objob.payratemode;
                tempjob.Travel = Objob.Travel;
                tempjob.payratenegotaible = Objob.payratenegotaible;

                try
                {
                    tempjob.ExpiryDate = new DateTime(Convert.ToInt32(sjob.endyear), Convert.ToInt32(sjob.endmonth), Convert.ToInt32(sjob.enddate));
                }
                catch (Exception enddatexception)
                {

                    string strdatexceptioninfo = enddatexception.Message;
                }
                try
                {
                    tempjob.StartDate = new DateTime(Convert.ToInt32(sjob.startyear), Convert.ToInt32(sjob.startmonth), Convert.ToInt32(sjob.startdate));
                }
                catch (Exception strdatexception)
                {

                    string strdatexceptioninfo = strdatexception.Message;
                }
                tempjob.jobmailstatus = sjob.emailstatus;
                try
                {
                    tempjob.createddate = DateTime.Parse(sjob.createddate);
                }
                catch (Exception createddatexception)
                {

                    string strdatexceptioninfo = createddatexception.Message;
                }
                tempjob.JobDesc = sjob.jobdescription;
                tempjob.additionaldetails = sjob.additionaldetails;
                try
                {
                    string[] jobpositioncodearray = sjob.positiontype.Split(',');
                    foreach (string positioncode in jobpositioncodearray)
                    {
                        if (tempjob.postype == "")
                        {
                            tempjob.postype = CommonFunctions.MapIDtoPosition[positioncode].ToString();
                            tempjob.PositionType.Add(CommonFunctions.MapIDtoPosition[positioncode].ToString());
                        }
                        else
                        {
                            tempjob.postype = tempjob.postype + "," +CommonFunctions.MapIDtoPosition[positioncode].ToString();
                            tempjob.PositionType.Add(CommonFunctions.MapIDtoPosition[positioncode].ToString());
                        }
                    }

                }
                catch { tempjob.postype = CommonFunctions.MapIDtoPosition[sjob.positiontype].ToString(); }

                List<Job> jobslist = new List<Job>();

                jobslist.Add(tempjob);
                //}

                return jobslist;

            }

            catch { throw; }
        }
        //for time being using static userid
        public List<Job> getAllInhouseorPublishActiveorInactiveJobsList()
        {
            string executionprocess = "";
            CommonFunctions cf = new CommonFunctions();
            executionprocess += "created commonfunctions Object";
            try
            {
                List<Business.ApplicationService.jobs> servicejobslist = new List<Business.ApplicationService.jobs>();
                executionprocess += "service jobs list object";
                try
                {
                    Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();
                    executionprocess += "appclient object";
                    executionprocess += "; companyid =" + System.Web.HttpContext.Current.Session["companyid"].ToString();
                    Business.ApplicationService.jobs[] serviceJobs = appclient.GetJobs("", "", System.Web.HttpContext.Current.Session["companyid"].ToString());
                    executionprocess += "service jobs array";
                    servicejobslist = serviceJobs.ToList();
                    executionprocess += "service jobs array to list done";
                }
                catch
                {
                    throw (new Exception(executionprocess + "exception at service jobs list"));
                }
                List<Job> jobslist = new List<Job>();
                executionprocess += "service joblist object";

                foreach (Business.ApplicationService.jobs sjob in servicejobslist)
                {
                    Job tempjob = new Job();
                    executionprocess += "service tempjob object";

                    tempjob.JobId = sjob.jobid;
                    tempjob.JobIDforPublisPartnersList = 0;
                    tempjob.JobName = sjob.jobname;
                    tempjob.Exp = CommonFunctions.MapIDtoExperience[sjob.expid.ToString()].ToString();
                    tempjob.PayRate = sjob.payrate;
                    tempjob.PrefSkills = sjob.preferenceskills;
                    tempjob.Status = sjob.status;
                    tempjob.jobdata = sjob.data;

                    UI.Models.Job Objob = Newtonsoft.Json.JsonConvert.DeserializeObject<UI.Models.Job>(sjob.data);
                    tempjob.payratemax = Objob.payratemax;
                    tempjob.payratemode = Objob.payratemode;
                    tempjob.Travel = Objob.Travel;
                    tempjob.payratenegotaible = Objob.payratenegotaible;

                    tempjob.State = sjob.cityid;
                    executionprocess += "assigning values to temp job";
                    try
                    {
                        try
                        {
                            tempjob.ExpiryDate = new DateTime(Convert.ToInt32(sjob.endyear), Convert.ToInt32(sjob.endmonth), Convert.ToInt32(sjob.enddate));
                        }
                        catch
                        {
                            tempjob.ExpiryDate = new DateTime(Convert.ToInt32(sjob.endyear), Convert.ToInt32(sjob.endmonth), Convert.ToInt32(sjob.enddate));
                        }
                    }
                    catch (Exception enddatexception)
                    {

                        string strdatexceptioninfo = executionprocess + enddatexception.Message;
                    }

                    try
                    {
                        try
                        {
                            tempjob.StartDate = new DateTime(Convert.ToInt32(sjob.startyear), Convert.ToInt32(sjob.startmonth), Convert.ToInt32(sjob.startdate));
                        }
                        catch
                        {
                            tempjob.StartDate = new DateTime(Convert.ToInt32(sjob.startyear), Convert.ToInt32(sjob.startmonth), Convert.ToInt32(sjob.startdate));
                        }
                    }
                    catch (Exception strdatexception)
                    {

                        string strdatexceptioninfo = executionprocess + strdatexception.Message;
                    }
                    tempjob.jobmailstatus = sjob.emailstatus;

                    try
                    {
                        try
                        {
                            tempjob.createddate = DateTime.ParseExact(sjob.createddate, "MM/dd/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
                        }
                        catch
                        {
                            tempjob.createddate = DateTime.Parse(sjob.createddate);
                        }
                    }
                    catch (Exception createddatexception)
                    {

                        string strdatexceptioninfo = executionprocess + createddatexception.Message;
                    }
                    executionprocess += "time conversions done";
                    tempjob.JobDesc = sjob.jobdescription;
                    tempjob.additionaldetails = sjob.additionaldetails;
                    executionprocess += "desc and additional details added";
                    try
                    {
                        string[] positiontypecodearray = sjob.positiontype.Split(',');
                        if (positiontypecodearray.Length > 0)
                        {
                            foreach (string positioncode in positiontypecodearray)
                            {
                                if (tempjob.postype == null || tempjob.postype == "")
                                {
                                    tempjob.postype = CommonFunctions.MapIDtoPosition[positioncode].ToString();
                                }
                                else
                                {
                                    tempjob.postype = tempjob.postype + "," + CommonFunctions.MapIDtoPosition[positioncode].ToString();
                                }
                            }
                        }
                    }
                    catch { tempjob.postype = CommonFunctions.MapIDtoPosition[sjob.positiontype].ToString();  }

                    try
                    {
                        executionprocess += "Before retrieving job applications object ;  ";
                        List<JobApplication> applications = GetJobApplicants(sjob.jobid, System.Web.HttpContext.Current.Session["companyid"].ToString());
                        executionprocess += "job applications object";
                        tempjob.applications = applications;
                        executionprocess += "assigning applicationa to job done";
                        jobslist.Add(tempjob);
                        executionprocess += "assigning job to job list done";
                    }
                    catch
                    {
                        throw (new Exception(executionprocess + "exception at jobs applications list"));
                    }
                }
                return jobslist.OrderByDescending(x => x.createddate).ToList();
            }
            catch
            {
                throw (new Exception(executionprocess + "exception at top level"));
            }
        }
 public ActionResult Edit()
 {
     string jobid = Request.QueryString["jobid"].ToString();
     JobPosting jobpost = new JobPosting().GetJobPosting(jobid, Session["companyid"].ToString(), Session["usertoken"].ToString());
     List<string> lstPostionTypes = new List<string>();
     List<string> lstJobCatgs = new List<string>();
     List<string> lstExps = new List<string>();
     List<string> lstPartners = new List<string>();
     Business.CommonFunctions cf = new CommonFunctions();
     foreach (string item in CommonFunctions.m_listJobPosition)
     {
         lstPostionTypes.Add(item);
     }
     ViewData["PostTypes"] = lstPostionTypes;
     foreach (string item in CommonFunctions.m_listJobCategoires)
     {
         lstJobCatgs.Add(item);
     }
     ViewData["JobCatgs"] = new SelectList(lstJobCatgs);
     foreach (string item in CommonFunctions.m_listJobExperience)
     {
         lstExps.Add(item);
     }
     ViewData["Exps"] = new SelectList(lstExps);
     jobpost.postedjob.payratemax = jobpost.postedjob.PayRate.Split('-')[1].ToString();
     jobpost.postedjob.PayRate = jobpost.postedjob.PayRate.Split('-')[0].ToString();
     return View(jobpost.postedjob);
 }