Пример #1
0
        public IActionResult ProcessAddJobForm(AddJobViewModel viewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job job = new Job(viewModel.Name)
                {
                    EmployerId = viewModel.EmployerId
                };


                foreach (var selectedSkill in selectedSkills)
                {
                    JobSkill jobSkill = new JobSkill()
                    {
                        Job     = job,
                        SkillId = int.Parse(selectedSkill)
                    };
                    context.JobSkills.Add(jobSkill);
                }
                context.Jobs.Add(job);
                context.SaveChanges();
                return(Redirect("Index"));
            }
            viewModel.populateSelectListItems(context.Employers.ToList(), context.Skills.ToList());
            return(View("AddJob", viewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Id         = addJobViewModel.Id,
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId,
                    Employer   = context.Employers.Find(addJobViewModel.EmployerId),
                    JobSkills  = new List <JobSkill>()
                };

                foreach (string skill in selectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        JobId   = newJob.Id,
                        SkillId = int.Parse(skill),
                    };
                    newJob.JobSkills.Add(newJobSkill);
                }
                context.Jobs.Add(newJob);
                context.SaveChanges();
                return(Redirect("/Home"));
            }
            return(View(addJobViewModel));
        }
Пример #3
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job job = new Job()
                {
                    Name       = addJobViewModel.JobName,
                    EmployerId = addJobViewModel.EmployerId,
                };
                job.JobSkills = new List <JobSkill>();
                //looping selected skills
                foreach (string selectSkill in selectedSkills)
                {
                    JobSkill jobSkill = new JobSkill
                    {
                        JobId   = job.Id,
                        SkillId = int.Parse(selectSkill),
                    };
                    //context.JobSkills.Add(jobSkill);
                    job.JobSkills.Add(jobSkill);
                    context.Jobs.Add(job);
                    context.JobSkills.Add(jobSkill);
                }


                context.SaveChanges();

                return(Redirect("/Home"));
            }

            return(View("Add", addJobViewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Employer theEmployer = context.Employers.Find(addJobViewModel.EmployerId);
                Job      newJob      = new Job
                {
                    Name     = addJobViewModel.Name,
                    Employer = theEmployer
                };
                context.Jobs.Add(newJob);
                foreach (var skill in selectedSkills)
                {
                    JobSkill jobSkill = new JobSkill()
                    {
                        Job     = newJob,
                        JobId   = newJob.Id,
                        SkillId = Int32.Parse(skill)
                    };
                    context.JobSkills.Add(jobSkill);
                }

                context.SaveChanges();

                return(Redirect("/Home"));
            }
            return(View("AddJob", addJobViewModel));
        }
Пример #5
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId,
                };
                foreach (string selectedSkill in selectedSkills)
                {
                    JobSkill SkillId = new JobSkill
                    {
                        Job     = newJob,
                        SkillId = int.Parse(selectedSkill)
                    };
                }
                ;
                context.Jobs.Add(newJob);

                context.SaveChanges();
                return(Redirect("/Detail"));
            }
            return(View());
        }
Пример #6
0
        public ActionResult AddJobSkills(JobSkill js)
        {
            string viewBagJobId = Request["JobId"].ToString();

            //ViewBag.Trigger = Request.Form["JobId"];
            ViewBag.SkillId           = new SelectList(db.Skills, "Id", "SkillName", js.SkillId);
            ViewBag.SkillExperienceId = new SelectList(db.SkillExperiences, "Id", "Experience", js.Experience);

            if (ModelState.IsValid)
            {
                try
                {
                    js.JobId = Convert.ToInt32(viewBagJobId);
                    if (js.Id > 0)
                    {
                        db.Entry(js).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        db.JobSkills.Add(js);
                        db.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }
            }
            return(View(js));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills) //added instance of AddJobViewModel
        {
            if (ModelState.IsValid)
            {
                Job job = new Job
                {
                    Name       = addJobViewModel.JobName,
                    EmployerId = addJobViewModel.EmployerId,
                    JobSkills  = new List <JobSkill>()
                };

                foreach (string skillId in selectedSkills)
                {
                    JobSkill jobSkill = new JobSkill()
                    {
                        //JobId = job.Id,
                        Job     = job,
                        SkillId = int.Parse(skillId)
                    };

                    context.JobSkills.Add(jobSkill);
                }

                context.Jobs.Add(job);
                context.SaveChanges();
                return(Redirect("/"));
            }

            return(View(addJobViewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, String[] selectedSkills)
        {
            //String[] selectedSkills = new String[];
            if (ModelState.IsValid)
            {
                Job job = new Job

                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId,
                    Employer   = context.Employers.Find(addJobViewModel.EmployerId)
                };

                for (int i = 0; i < selectedSkills.Length; i++)
                {
                    JobSkill newjobSkill = new JobSkill
                    {
                        JobId   = job.Id,
                        Job     = job,
                        SkillId = Int32.Parse(selectedSkills[i])
                    };
                    context.JobSkills.Add(newjobSkill);
                }

                context.Jobs.Add(job);

                context.SaveChanges();
                return(Redirect("Index"));
            }
            return(View("Add", addJobViewModel));
        }
Пример #9
0
        public IActionResult AddJob(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid == false)
            {
                return(View(addJobViewModel));
            }

            Job job = new Job
            {
                Name       = addJobViewModel.Name,
                Employer   = _context.Employers.Find(addJobViewModel.EmployerId),
                EmployerId = addJobViewModel.EmployerId
            };

            for (int i = 0; i < selectedSkills.Length; i++)
            {
                JobSkill puppy = new JobSkill {
                    SkillId = int.Parse(selectedSkills[i]), JobId = job.Id, Job = job
                };
                _context.JobSkills.Add(puppy);
            }

            _context.Jobs.Add(job);

            _context.SaveChanges();

            return(Redirect("Index"));
        }
Пример #10
0
        public IActionResult ProcessAddJobForm(AddJobViewModel viewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name     = viewModel.Name,
                    Employer = context.Employers.Find(viewModel.Id),
                };
                context.Jobs.Add(newJob);
                context.SaveChanges();

                foreach (string skill in selectedSkills)
                {
                    JobSkill jobSkill = new JobSkill
                    {
                        JobId = newJob.Id,

                        /*                        Job = newJob,
                         */
                        SkillId = int.Parse(skill),
                        Skill   = context.Skills.Find(int.Parse(skill))
                    };
                    context.JobSkills.Add(jobSkill);
                }
                context.SaveChanges();

                return(Redirect("/home"));
            }
            AddJobViewModel anotherViewModel = new AddJobViewModel(context.Employers.ToList(), context.Skills.ToList());

            return(View("AddJob", anotherViewModel));
        }
Пример #11
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job job = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId
                };

                foreach (string skill in selectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        Job     = job,
                        SkillId = Convert.ToInt32(skill)
                    };

                    context.JobSkills.Add(newJobSkill);
                }

                context.Jobs.Add(job);
                context.SaveChanges();
            }
            return(View("AddJob", addJobViewModel));
        }
Пример #12
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId
                };

                context.Jobs.Add(newJob);

                foreach (var skillId in selectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        Job     = newJob,
                        SkillId = int.Parse(skillId)
                    };
                    context.JobSkills.Add(newJobSkill);
                }

                context.SaveChanges();

                return(Redirect("/"));
            }
            List <Employer> possibleEmployer = context.Employers.ToList();
            List <Skill>    possibleSkill    = context.Skills.ToList();

            addJobViewModel.addEmployerAndSkill(possibleEmployer, possibleSkill);

            return(View("Add", addJobViewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel viewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                string name       = viewModel.Name;
                int    employerId = viewModel.EmployerId;



                Job job = new Job
                {
                    Name       = name,
                    EmployerId = employerId
                };
                context.Jobs.Add(job);

                foreach (string skill in selectedSkills)
                {
                    JobSkill jobSkill = new JobSkill
                    {
                        Job     = job,
                        SkillId = int.Parse(skill)
                    };
                    context.JobSkills.Add(jobSkill);
                }


                context.SaveChanges();
                return(Redirect("/Home"));
            }

            return(View(viewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name     = viewModel.Name,
                    Employer = context.Employers.Find(viewModel.EmployerId)
                };

                foreach (var selectedskill in viewModel.SelectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        Job   = newJob,
                        Skill = context.Skills.Find(int.Parse(selectedskill))
                    };
                    context.JobSkills.Add(newJobSkill);
                }

                context.Jobs.Add(newJob);
                context.SaveChanges();
                return(Redirect("/Home"));
            }

            return(View("AddJob", viewModel));
        }
Пример #15
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Employer theEmployer = context.Employers.Find(addJobViewModel.EmployerId);

                Job newJob = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId,
                    Employer   = theEmployer
                };

                //Iterate a Loop that sends the numbers
                for (int i = 0; i < selectedSkills.Length; i++)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        JobId   = newJob.Id,
                        Job     = newJob,
                        SkillId = int.Parse(selectedSkills[i])
                    };
                    context.JobSkills.Add(newJobSkill);
                }

                context.Jobs.Add(newJob);
                context.SaveChanges();
                return(Redirect("Index"));
            }
            return(View("Add", addJobViewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    EmployerId = addJobViewModel.Employer_Id,
                    Name       = addJobViewModel.Name,
                };
                foreach (string skill in selectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        JobId = newJob.Id,
                        Job   = newJob,

                        SkillId = int.Parse(skill),
                        Skill   = context.Skills.Find(int.Parse(skill)),
                    };

                    context.JobSkills.Add(newJobSkill);
                }
                ;
                context.Jobs.Add(newJob);
                context.SaveChanges();
                return(Redirect("/"));
            }

            addJobViewModel.Skills    = context.Skills.ToList();
            addJobViewModel.Employers = context.Employers.ToList();

            return(View("AddJob", addJobViewModel));
        }
Пример #17
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string [] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId
                };


                for (int i = 0; i < selectedSkills.Length; i++)
                {
                    JobSkill jobSkill = new JobSkill
                    {
                        //Skill = selectedSkills.Skill,
                        SkillId = int.Parse(selectedSkills[i]),
                        JobId   = newJob.Id,
                        Job     = newJob
                    };

                    context.JobSkills.Add(jobSkill);
                }
                context.Jobs.Add(newJob);
                context.SaveChanges();
                return(Redirect("/List"));
            }
            return(View("AddJob", addJobViewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                // Create job object.
                Job newJob = new Job()
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId,
                    Employer   = context.Employers.Find(addJobViewModel.EmployerId),
                    JobSkills  = new List <JobSkill>()
                };

                // Add selected skills.
                foreach (string skill in selectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        Job = newJob,

                        Skill = context.Skills.Find(int.Parse(skill))
                    };

                    context.JobSkills.Add(newJobSkill);
                }

                // Update info.
                context.Jobs.Add(newJob);
                context.SaveChanges();

                return(Redirect("/Home"));
            }

            return(View("Add", addJobViewModel));
        }
Пример #19
0
        public String CreateJob(Job job, List <Question> questions, List <Guid> skillIds)
        {
            if (Session["PersonId"] == null || questions.Count > 5)
            {
                return("");
            }

            job.ClientId   = (Guid)Session["PersonId"];
            job.PostedDate = DateTime.Now;
            if (JobRepository.Instance.SetItem(job))
            {
                foreach (var item in questions)
                {
                    item.Job = job;
                    QuestionRepository.Instance.SetItem(item);
                }
                foreach (var id in skillIds)
                {
                    JobSkill js = new JobSkill();
                    js.Job     = job;
                    js.SkillId = id;
                    JobSkillRepository.Instance.SetItem(js);
                }
                return("/Client/PostedJobs");
            }
            return("");
        }
Пример #20
0
 public static void DeserializeSkills(this List <Job> jobs, string rawData)
 {
     foreach (var dataJob in rawData.Split('|'))
     {
         var jobId = (JobIdEnum)Convert.ToInt32(dataJob.Split(';')[0]);
         var job   = jobs.Find(x => x.Id == jobId);
         if (job == null)
         {
             job    = new Job();
             job.Id = jobId;
             jobs.Add(job);
         }
         foreach (var dataSkill in dataJob.Split(';')[1].Split(','))
         {
             var data    = dataSkill.Split('~');
             var skillId = (SkillIdEnum)Convert.ToInt32(data[0]);
             var skill   = job.Skills.Find(x => x.Id == skillId);
             if (skill == null)
             {
                 skill = new JobSkill();
             }
             skill.Id          = skillId;
             skill.QuantityMin = Convert.ToInt32(data[1]);
             skill.QuantityMax = Convert.ToInt32(data[2]);
             skill.Time        = Convert.ToDouble(data[3]);
             job.Skills.Add(skill);
         }
     }
 }
Пример #21
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId
                };

                foreach (string skill in selectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        JobId   = newJob.Id,
                        Job     = newJob,
                        SkillId = Int32.Parse(skill)
                    };
                    context.JobSkills.Add(newJobSkill);
                }
                context.Jobs.Add(newJob);
                context.SaveChanges();
                return(Redirect("Index"));
            }
            return(View("Add", addJobViewModel));
        }
        public IActionResult AddJob(AddJobSkillViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                int jobId   = viewModel.JobId;
                int skillId = viewModel.SkillId;

                List <JobSkill> existingItems = context.JobSkills
                                                .Where(js => js.JobId == jobId)
                                                .Where(js => js.SkillId == skillId)
                                                .ToList();

                if (existingItems.Count == 0)
                {
                    JobSkill jobSkill = new JobSkill
                    {
                        JobId   = jobId,
                        SkillId = skillId
                    };
                    context.JobSkills.Add(jobSkill);
                    context.SaveChanges();
                }

                return(Redirect("/Home/Detail/" + jobId));
            }

            return(View(viewModel));
        }
Пример #23
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                int      employerId = int.Parse(addJobViewModel.Employers.ElementAt(0).Value);
                Employer employer   = (Employer)context.Employers.Where(e => e.Id == employerId);

                Job newJob = new Job
                {
                    Name       = addJobViewModel.Name,
                    Employer   = employer,
                    EmployerId = employerId
                };

                foreach (string skill in selectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill();

                    newJobSkill.JobId = newJob.Id;
                    newJobSkill.Job   = newJob;

                    newJobSkill.SkillId = int.Parse(skill);
                    newJobSkill.Skill   = (Skill)context.Skills.Where(s => s.Id == int.Parse(skill));

                    context.JobSkills.Add(newJobSkill);
                }

                context.Jobs.Add(newJob);
                context.SaveChanges();

                return(Redirect("/Index"));
            }
            return(View(addJobViewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job job = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId
                };

                context.Jobs.Add(job);
                context.SaveChanges();

                foreach (string sk in selectedSkills)
                {
                    Skill foundSkill = context.Skills.Find(int.Parse(sk));

                    JobSkill jobSkill = new JobSkill
                    {
                        SkillId = foundSkill.Id,
                        JobId   = job.Id
                    };

                    context.JobSkills.Add(jobSkill);
                }

                context.SaveChanges();

                return(Redirect("/Home"));
            }

            return(View("/Add", addJobViewModel));
        }
Пример #25
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,JobId,Name,Content")] JobSkill jobSkill)
        {
            if (id != jobSkill.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(jobSkill);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!JobSkillExists(jobSkill.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(jobSkill));
        }
Пример #26
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job job = new Job
                {
                    Name = addJobViewModel.Name,
                    //EmployerId = addJobViewModel.EmployerId,
                    Employer = context.Employers.Find(addJobViewModel.EmployerId)
                };

                foreach (var skill in selectedSkills)
                {
                    JobSkill jobSkill = new JobSkill
                    {
                        SkillId = int.Parse(skill),
                        Job     = job
                    };

                    context.JobSkills.Add(jobSkill);
                }

                context.Jobs.Add(job);
                context.SaveChanges();
                return(Redirect("Index"));
            }

            return(View("AddJob", addJobViewModel));
        }
Пример #27
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId,
                    Employer   = context.Employers.Find(addJobViewModel.EmployerId),
                };

                foreach (string item in selectedSkills)
                {
                    JobSkill newJobSkill = new JobSkill
                    {
                        JobId   = newJob.Id,
                        Job     = newJob,
                        SkillId = int.Parse(item),
                        Skill   = context.Skills.Find(int.Parse(item)) //Do I need this?
                    };
                    context.JobSkills.Add(newJobSkill);
                }

                context.Jobs.Add(newJob);
                context.SaveChanges();

                return(Redirect("Index"));
            }

            return(View("Add", addJobViewModel));
        }
Пример #28
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string [] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name     = addJobViewModel.Name,
                    Employer = context.Employers.Find(addJobViewModel.EmployerId)
                };
                for (int i = 0; i < selectedSkills.Length; i++)
                {
                    JobSkill jobSkill = new JobSkill
                    {
                        SkillId = Int32.Parse(selectedSkills[i]),
                        JobId   = newJob.Id,
                        Job     = newJob,
                        Skill   = context.Skills.Find(Int32.Parse(selectedSkills[i]))
                    };
                    context.JobSkills.Add(jobSkill);
                }

                context.Jobs.Add(newJob);

                context.SaveChanges();

                return(Redirect("/Add"));
            }
            List <Skill>    skills    = context.Skills.ToList();
            List <Employer> employers = context.Employers.ToList();
            AddJobViewModel rainbow   = new AddJobViewModel(employers, skills);

            addJobViewModel.Employers = rainbow.Employers;
            addJobViewModel.Skills    = rainbow.Skills;
            return(View("AddJob", addJobViewModel));
        }
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            Employer employer = context.Employers.Find(addJobViewModel.EmployerId);

            if (ModelState.IsValid)
            {
                Job job = new Job
                {
                    Name     = addJobViewModel.Name,
                    Employer = employer
                };
                foreach (string theSkill in selectedSkills)
                {
                    int Id = int.Parse(theSkill);

                    JobSkill theskill = new JobSkill
                    {
                        Job     = job,
                        SkillId = Id
                    };
                    context.JobSkills.Add(theskill);
                }


                context.Jobs.Add(job);
                context.SaveChanges();
                return(Redirect("/Home"));
            }
            return(View("Add", addJobViewModel));
        }
Пример #30
0
        public IActionResult ProcessAddJobForm(AddJobViewModel addJobViewModel, string[] selectedSkills)
        {
            if (ModelState.IsValid)
            {
                Job newJob = new Job
                {
                    Name       = addJobViewModel.Name,
                    EmployerId = addJobViewModel.EmployerId,
                    Employer   = context.Employers.Find(addJobViewModel.EmployerId)
                };

                foreach (string skill in selectedSkills)
                {
                    JobSkill jobSkill = new JobSkill
                    {
                        Job   = newJob,
                        Skill = context.Skills.Find(int.Parse(skill))
                    };

                    context.JobSkills.Add(jobSkill);
                }

                context.Jobs.Add(newJob);
                context.SaveChanges();

                return(Redirect("/Home"));
            }

            return(View("/Add, addJobViewModel"));
        }
        public dynamic postJD(JdDTO jddto)
        {
            TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
            DateTime currentTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);

            JobDescription jd = new JobDescription();
            int jdId = 0;
            int retVal = -1;
            jd.JobTitle = jddto.JobTitle;
            jd.JobShortName = jddto.JobShortName;
            jd.CleintId = jddto.CleintId;
            jd.JobLocation = jddto.JobLocation;
            jd.Openings = jddto.Openings;
            jd.JobNotes = jddto.JobNotes;

            jd.ExpFrom = jddto.ExpFrom;
            jd.ExpTo = jddto.ExpTo;
            jd.RExpFrom = jddto.RExpFrom;
            jd.RExpTo = jddto.RExpTo;
            jd.Salary = jddto.Salary;
            jd.SalaryTo = jddto.SalaryTo;

            jd.CreatedDate = currentTime;
            jd.CreatedBy = jddto.CreatedBy;

            db.JobDescriptions.Add(jd);

            if (db.SaveChanges() == 1) {

                jdId = jd.Id;
                retVal = 0;

                JArray skillList = JArray.Parse(jddto.skillList);

                foreach (string skillId in skillList)
                {
                    JobSkill jobSkill = new JobSkill();
                    jobSkill.JobId = jdId;
                    jobSkill.SkillId = Int32.Parse(skillId);
                    db.JobSkills.Add(jobSkill);
                }

                try
                {
                        JArray certification = JArray.Parse(jddto.certification);
                        foreach(string certificate in certification)
                        {
                            JobCertification jobcerti = new JobCertification();
                            jobcerti.CertificationId = Int32.Parse(certificate);
                            jobcerti.JobId = jdId;
                            db.JobCertifications.Add(jobcerti);
                        }
                }
                catch (Exception ex) { }

                try
                {
                    JArray qualification = JArray.Parse(jddto.qualification);
                        foreach(string degree in qualification)
                        {
                            JobQualification jobqual = new JobQualification();
                            jobqual.DegreeId = Int32.Parse(degree);
                            jobqual.JobId = jdId;
                            db.JobQualifications.Add(jobqual);
                        }
                }
                catch (Exception ex) { }

                try
                {
                    JArray beneifts = JArray.Parse(jddto.benefit);
                        foreach(string benefit in beneifts)
                        {
                            JObject benefitObject = JObject.Parse(benefit);
                            JobBenefit jobBenefit = new JobBenefit();
                            jobBenefit.JobId = jdId;
                            jobBenefit.BenefitId = Int32.Parse((string)benefitObject["benefitId"]);
                            jobBenefit.BenefitDesc = (string)benefitObject["benefitRem"];
                            db.JobBenefits.Add(jobBenefit);
                        }
                }
                catch (Exception ex) { }

                retVal = db.SaveChanges();
            }
            return retVal;
        }
Пример #32
0
        //Create new job
        public bool UpdateJob(Job job, int[] citiesidlist, int[] categoriesidlist, string skill1, string skill2, string skill3, string recruiterID)
        {
            if (job != null && job.JobID > 0 && citiesidlist != null && categoriesidlist != null
                && recruiterID != null && job.RecruiterID == recruiterID)
            {
                Job oldJob = this.JobRepository.GetByID(job.JobID);

                if (oldJob != null)
                {
                    oldJob.JobTitle = job.JobTitle;
                    oldJob.MinSalary = job.MinSalary;
                    oldJob.MaxSalary = job.MaxSalary;
                    oldJob.JobDescription = job.JobDescription;
                    oldJob.JobRequirement = job.JobRequirement;
                    oldJob.JobLevel_ID = job.JobLevel_ID;
                    oldJob.MinSchoolLevel_ID = job.MinSchoolLevel_ID;

                    this.JobRepository.Update(oldJob);
                    this.Save();

                    //Add city
                    IEnumerable<JobCity> oldJobcities = this.JobCityRepository.Get(s => s.JobID == oldJob.JobID).AsEnumerable();
                    foreach (JobCity item in oldJobcities)
                    {
                        this.JobCityRepository.Delete(item);
                    }
                    this.Save();
                    foreach (int index in citiesidlist)
                    {
                        JobCity item = new JobCity();
                        item.JobID = oldJob.JobID;
                        item.CityID = index;
                        this.JobCityRepository.Insert(item);
                        this.Save();
                    }

                    //Add category
                    IEnumerable<JobCategory> oldJobcategories = this.JobCategoryRepository.Get(s => s.JobID == oldJob.JobID).AsEnumerable();
                    foreach (JobCategory item in oldJobcategories)
                    {
                        this.JobCategoryRepository.Delete(item);
                    }
                    this.Save();
                    foreach (int index in categoriesidlist)
                    {
                        JobCategory item = new JobCategory();
                        item.JobID = oldJob.JobID;
                        item.CategoryID = index;
                        this.JobCategoryRepository.Insert(item);
                        this.Save();
                    }

                    //Skill part
                    IEnumerable<JobSkill> oldJobSkill = this.JobSkillRepository.Get(s => s.JobID == oldJob.JobID).AsEnumerable();
                    foreach (JobSkill item in oldJobSkill)
                    {
                        this.JobSkillRepository.Delete(item);
                    }
                    this.Save();

                    if (!String.IsNullOrEmpty(skill1))
                    {
                        Skill s1 = this.SkillRepository.Get(skill => skill.SkillTag == skill1).SingleOrDefault();
                        if (s1 != null)
                        {
                            JobSkill tempjs1 = new JobSkill();
                            tempjs1.JobID = oldJob.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 = oldJob.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 = oldJob.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 = oldJob.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 = oldJob.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 = oldJob.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;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
Пример #33
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;
            //}
        }
        public JobUserSkillModel(User u, Job j)
        {
            User = u;
            Job = j;
            Skills = new List<JobSkill>();
            AdditionalSkill = new JobSkill();
            AppliedUsers = new List<Models.User>();
            PinnedUsers = new List<User>();
            var dataContext = new Models.LinqModelHelperDataContext();

            var dbskills = from s in dataContext.JobSkills
                           where s.JobID == j.JobID
                           select s;

            foreach (var s in dbskills)
            {
                Skills.Add(s);
            }

            GetAppliedUsers(dataContext);
            //GetPinnedUsers(dataContext);
        }