Beispiel #1
0
        /// <summary>
        /// UPDATE DEPARTMENT [GET]
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dept_id"></param>
        /// <returns></returns>
        public async Task <IActionResult> UpdateDept(int id, int dept_id)
        {
            DepartmentViewModel model = new DepartmentViewModel();

            try
            {
                model = await _departmentPageservices.getDepartmentById(id);

                model.DegreeId = dept_id;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(View(model));
        }
        public async Task <IActionResult> Index(CandidateViewModel model)
        {
            //checking if already applied for same job
            candidateList = await _candidatePageServices.getCandidates();

            try
            {
                List <CandidateViewModel> list = new List <CandidateViewModel>();
                list = candidateList.ToList();
                foreach (var item in list)
                {
                    var job_ID = _dbContext.JobPostCandidate.AsNoTracking().FirstOrDefault(x => x.candidate_Id == item.ID).job_Id;
                    if (item.email == model.email && model.jobpostID == job_ID)
                    {
                        TempData["msg1"] = model.email;
                        return(RedirectToAction("Index", "Home", new { s = TempData["msg1"] }));
                    }
                }


                //------------------------------------------------------------------------------------
                //receiving dropdown value of degree
                if (model.degree == "Select Degree")
                {
                    ModelState.AddModelError("", "Select Degree");
                }
                //getting data from database
                List <Degree> DegreeList = new List <Degree>();
                DegreeList = (from element in _dbContext.Degree select element).ToList();

                //inserting into dropdown list
                DegreeList.Insert(0, new Degree {
                    ID = 0, degree_name = "Select Degree"
                });

                //assigning degreelist to viewbag.listofdegree
                ViewBag.ListOfDegree = DegreeList;
                //------------------------------------------------------------------------------------


                //getting selected value for degree
                DegreeViewModel selectedDegree = await _degreePageServices.getDegreeById(model.selectedDegree);

                string degreename = selectedDegree.degree_name;


                DepartmentViewModel selectedDept = await _departmentPageservices.getDepartmentById(model.selectDept);

                string deptename = selectedDept.dept_name;

                model.degree = degreename + "(" + deptename + ")";


                //Resume details fetching
                //create a place in wwwroot for storing uploaded images
                var uploads = Path.Combine(_environment.WebRootPath, "Resume");
                if (model.File != null)
                {
                    using (var fileStream = new FileStream(Path.Combine(uploads, model.File.FileName), FileMode.Create))
                    {
                        await model.File.CopyToAsync(fileStream);
                    }
                    model.resume = model.File.FileName;
                }

                model.emailConfirmed = false;
                var latestRecord = await _candidatePageServices.AddNewCandidate(model);

                //add to jobpostcandidate
                JobPostCandidateViewModel newModel = new JobPostCandidateViewModel()
                {
                    job_Id       = model.jobpostID,
                    candidate_Id = latestRecord.ID
                };
                await _jobPostCandidatePage.AddNewJobPostCandidate(newModel);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(RedirectToAction("SendOTPToMail", model));
        }