Beispiel #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()
            }));
        }
Beispiel #2
0
        public virtual async Task <ActionResult> Create(AddWorkExperienceViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                await _workExperienceService.FillAddViewModel(viewModel, IranCitiesPath);

                return(new JsonNetResult
                {
                    Data = new
                    {
                        success = false,
                        View = this.RenderPartialViewToString(MVC.WorkExperience.Views._Create, viewModel)
                    }
                });
            }
            var newWork = await _workExperienceService.Create(viewModel);

            return(new JsonNetResult
            {
                Data = new
                {
                    success = true,
                    View = this.RenderPartialViewToString(MVC.WorkExperience.Views._WorkExperienceItem, newWork)
                }
            });
        }