public ActionResult CreateNewVacancy(Vacancy model)
        {
            string result = "";

            try
            {
                List <JOB> output = new List <JOB>();
                output = (from c in db.JOBs
                          where c.JobTitle == model.publishedBy
                          select c).ToList();
                if (output.Count != 0)
                {
                    model.publishedDate = DateTime.Now;
                    model.job           = output[0];
                    model.publishedBy   = User.Identity.Name;
                    db.Vacancies.Add(model);
                    db.SaveChanges();

                    if (CreateVacancyFolder(model.job.JobTitle, model.VacancyId.ToString()) == "New_VacancyFolderCreated" || CreateVacancyFolder(model.job.JobTitle, model.VacancyId.ToString()) == "VacancyFolderExist")
                    {
                        result = "NewVacancyCreated_Successfully";
                    }
                    else
                    {
                        result = "NewVacancyCeated";
                    }
                }
                else
                {
                    result = "JobTitle_Not_Exsist";
                }
            }
            catch (Exception ex)
            {
                result = "ErrorOccured";
                ErrorLog.CreateLog(ex);
            }
            return(Json(result));
        }
        //----------------------------------------------------------------------//


        //------------- Create JOB Folder ---------------------------------------------//
        public string CreateJobFolder(string folderName)
        {
            string result = "";

            try
            {
                string pathString = Path.Combine(Server.MapPath("~/UploadCV/"), folderName);
                if (!Directory.Exists(pathString))
                {
                    Directory.CreateDirectory(pathString);
                    result = "New_JOBFolderCreated";
                }
                else
                {
                    result = "JOBFolderExist";
                }
            }
            catch (Exception ex) {
                ErrorLog.CreateLog(ex);
                result = "ExceptionOccured";
            }
            return(result);
        }
        public ActionResult FilterVacancy(Vacancy model)
        {
            List <Vacancy> vacancy = new List <Vacancy>();

            try
            {
                if (model.publishedBy != null)
                {
                    vacancy = (from c in db.Vacancies
                               where c.job.JobTitle.StartsWith(model.publishedBy)
                               select c).ToList();
                }
                else
                {
                    vacancy = (from c in db.Vacancies
                               select c).ToList();
                }
            }
            catch (Exception ex)
            {
                ErrorLog.CreateLog(ex);
            }
            return(Json(vacancy));
        }
        //------------- Delete Vacancy Folder ---------------------------------------------//
        public string DeleteVacancyFolder(string JobFolderName, string folderName)
        {
            string result = "";

            try
            {
                string pathString = Path.Combine(Server.MapPath("~/UploadCV/"), JobFolderName, folderName);
                if (Directory.Exists(pathString))
                {
                    Directory.Delete(pathString, true);
                    result = "VacancyFolderDeleted";
                }
                else
                {
                    result = "VacancyFolderNotExist";
                }
            }
            catch (Exception ex)
            {
                ErrorLog.CreateLog(ex);
                result = "ExceptionOccured";
            }
            return(result);
        }
        public ActionResult FilterJOB(JOB model)
        {
            List <JOB> jobs = new List <JOB>();

            try
            {
                if (model.JobTitle != null)
                {
                    jobs = (from c in db.JOBs
                            where c.JobTitle.StartsWith(model.JobTitle)
                            select c).ToList();
                }
                else
                {
                    jobs = (from c in db.JOBs
                            select c).ToList();
                }
            }
            catch (Exception ex)
            {
                ErrorLog.CreateLog(ex);
            }
            return(Json(jobs));
        }
 private void LogError(Exception ex)
 {
     ErrorLog.CreateLog(ex);
 }