Пример #1
0
        public IActionResult Create(JobSeekerAddExperienceViewModel jobSeekerAddExperienceViewModel)
        {
            var seekerId = HttpContext.Session.Get <string>("JobSeekerId");
            var f**k     = workExperienceService.IsJobSeekerEmployed(seekerId);

            //If user has already existing job, throw an error
            if (workExperienceService.IsJobSeekerEmployed(seekerId) == false && jobSeekerAddExperienceViewModel.JobSeekerExperienceViewModel.IsCurrentCompany)
            {
                ModelState.AddModelError("CompanyName", "You can't have more than two current companies");
            }

            //https://www.findanaccountant.co.za/content_company-name-criteria

            //call create method.
            if (ModelState.IsValid)
            {
                TempData["WorkExperienceCreate"] = "Work Experience Created Successfully";
                jobSeekerAddExperienceViewModel.JobSeekerExperienceViewModel.JobSeekerId = seekerId;
                workExperienceService.Create(jobSeekerAddExperienceViewModel.JobSeekerExperienceViewModel);
                //Redirect to success page
                logger.LogInformation("Created Experience successfully");
                return(View("Index", new JobSeekerAddExperienceViewModel {
                    JobCategories = jobCategoryService.GetAll()
                }));
            }

            return(View("Index", new JobSeekerAddExperienceViewModel {
                JobCategories = jobCategoryService.GetAll()
            }));
        }