public ActionResult Add(UI.Models.Job jobdata)
 {
     UI.Models.Job job = new Models.Job();
     jobdata.PayRate = jobdata.PayRate + "-" + jobdata.payratemax;
     job.InsertJobDetials(jobdata);
     return(RedirectToAction("index", "jobs", null));
 }
        public ActionResult post(UI.Models.Job job)
        {
            //string jobid = Request.QueryString["jobid"].ToString();
            //JobPosting jobpost = new JobPosting().GetJobPosting(jobid, Session["companyid"].ToString(), Session["usertoken"].ToString());
            //return View(jobpost);
            string jobid   = Request.QueryString["jobid"].ToString();
            Job    jobinfo = new Job().getPublicJobById(jobid);

            return(View(jobinfo));
        }
        public ActionResult Edit(UI.Models.Job editedjob)
        {
            Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();
            int CompID    = 1;
            int CatId     = 1;
            int stateId   = 1;
            int Expcodeid = 1;

            Expcodeid = Convert.ToInt32(CommonFunctions.MapExperiencetoID[editedjob.Exp].ToString());


            // string PositionTypeId = CommonFunctions.MapPositiontoID[editedjob.postype].ToString();

            string[] postypearray   = editedjob.postype.Split(',');
            string   PositionTypeId = "";

            if (postypearray.Length > 0)
            {
                foreach (string postype in postypearray)
                {
                    if (PositionTypeId == "")
                    {
                        PositionTypeId = CommonFunctions.MapPositiontoID[postype].ToString();
                    }
                    else
                    {
                        PositionTypeId = PositionTypeId + "," + CommonFunctions.MapPositiontoID[postype].ToString();
                    }
                }
            }


            editedjob.ModifiedDate = DateTime.Now;

            editedjob.StartDate = DateTime.Now;
            //string[] startdatearray = DateTime.Now.ToString().Split('/');
            // string startdate = new DateTime(Convert.ToInt32(startdatearray[2]), Convert.ToInt32(startdatearray[0]), Convert.ToInt32(startdatearray[1])).ToString("yyyy-MM-dd HH:mm:ss");
            string[] expdatearray = editedjob.ExpDate.Split('/');
            string   expdt        = new DateTime(Convert.ToInt32(expdatearray[2]), Convert.ToInt32(expdatearray[0]), Convert.ToInt32(expdatearray[1])).ToString("yyyy-MM-dd HH:mm:ss");

            editedjob.jobdata = Newtonsoft.Json.JsonConvert.SerializeObject(editedjob);
            editedjob.Publish = 1;
            editedjob.PayRate = editedjob.PayRate + "-" + editedjob.payratemax;
            bool stat = appclient.UpdateJob(editedjob.JobId, editedjob.CatId, editedjob.SubId, editedjob.JobName, editedjob.JobDesc, editedjob.PayRate, editedjob.PrefSkills, PositionTypeId, editedjob.State,
                                            editedjob.StartDate.Day.ToString(), editedjob.StartDate.Month.ToString(), editedjob.StartDate.Year.ToString(), expdatearray[1], expdatearray[0], expdatearray[2],
                                            Expcodeid, (int)editedjob.Publish, Session["companyid"].ToString(), "jobpost", editedjob.Email, editedjob.Phone, "", editedjob.jobdata, editedjob.additionaldetails);

            return(RedirectToAction("show", "jobs", new { jobid = editedjob.JobId }));
        }
 public JobPosting GetJobPosting(string jobid, string companyid, string accesstoken)
 {
     JobPosting appliedjob = new JobPosting();
     List<Job> jobinfo = new Job().getJobDetailsByJobId(jobid, companyid);
     appliedjob.postedjob = jobinfo[0];
     List<JobApplication> applications = new List<JobApplication>();
     Business.ApplicantActions ObjApplicantActions = new ApplicantActions();
     List<Business.ApplicationService.applicant> candidatesCollection = ObjApplicantActions.GetApplicantsinjob(System.Web.HttpContext.Current.Session["userid"].ToString(), companyid, jobid,"applicant");
     foreach (Business.ApplicationService.applicant dr in candidatesCollection)
     {
         JobApplication tempjobapplication = new JobApplication();
         tempjobapplication.applicationid = dr.transactionid.ToString();
         portalcandidate tempcandidate = new portalcandidate();
         tempcandidate.id = dr.candidateid.ToString();
         tempcandidate.resumeid = dr.resumeid.ToString();
         if (tempcandidate.resumeid == "" || tempcandidate.resumeid == null)
         {
             tempcandidate.resumeurl = "";
         }
         else
         {
             AmazonFile af = new AmazonFile();
             tempcandidate.resumeurl = af.GetFileUrl(dr.resumeid.ToString(), accesstoken);
         }
         tempcandidate.contactid = dr.contactid.ToString();
         tempcandidate.data = dr.data.ToString();
         tempjobapplication.candidate = tempcandidate;
         tempjobapplication.appliedon = dr.createddate.ToString();
         try
         {
             tempjobapplication.applicationstatus = dr.status.ToString();
         }
         catch
         {
             tempjobapplication.applicationstatus = "0";
         }
         applications.Add(tempjobapplication);
     }
     appliedjob.applications = applications;
     return appliedjob;
 }
        public string InsertJobDetials(Job job)
        {
            try
            {
                Business.ApplicationService.AppServiceClient appclient = new Business.ApplicationService.AppServiceClient();

                int CompID = 1;
                int CatId = 1;
                int stateId = 1;
                int Expcodeid = 1;
                Expcodeid = Convert.ToInt32(CommonFunctions.MapExperiencetoID[job.Exp].ToString());

                string[] postypearray = job.postype.Split(',');
                string PositionTypeId = "";
                if (postypearray.Length > 0)
                {
                    foreach (string postype in postypearray)
                    {
                        if (PositionTypeId == "")
                        { PositionTypeId = CommonFunctions.MapPositiontoID[postype].ToString(); }
                        else
                        {
                            PositionTypeId = PositionTypeId + "," + CommonFunctions.MapPositiontoID[postype].ToString();
                        }
                    }
                }
                job.StartDate = DateTime.Now;
                job.ModifiedDate = DateTime.Now;

                string[] expdatearray = job.ExpDate.Split('/');

                string expdt = new DateTime(Convert.ToInt32(expdatearray[2]), Convert.ToInt32(expdatearray[0]), Convert.ToInt32(expdatearray[1])).ToString("yyyy-MM-dd HH:mm:ss");

                job.Publish = 1; //inhouse

                job.jobdata = Newtonsoft.Json.JsonConvert.SerializeObject(job);
                appclient.CreateJob("", "", job.JobName, job.JobDesc, job.PayRate, job.PrefSkills, PositionTypeId, job.City, job.StartDate.Day.ToString(), job.StartDate.Month.ToString(), job.StartDate.Year.ToString(), Convert.ToInt32(expdatearray[1]).ToString(), Convert.ToInt32(expdatearray[0]).ToString(), Convert.ToInt32(expdatearray[2]).ToString(), Expcodeid, (int)job.Publish, System.Web.HttpContext.Current.Session["companyid"].ToString(), "jobpost", job.Email, job.Phone, "", job.jobdata, job.additionaldetails);

                return m_nJobId;
            }

            catch { throw; }
        }
        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 post(UI.Models.Job job)
 {
     //string jobid = Request.QueryString["jobid"].ToString();
     //JobPosting jobpost = new JobPosting().GetJobPosting(jobid, Session["companyid"].ToString(), Session["usertoken"].ToString());
     //return View(jobpost);
     string jobid = Request.QueryString["jobid"].ToString();
     Job jobinfo = new Job().getPublicJobById(jobid);
     return View(jobinfo);
 }
 public ActionResult Multiadd(UI.Models.Job jobdata)
 {
     UI.Models.Job job = new Models.Job();
     job.InsertJobDetials(jobdata);
     return(View());
 }