コード例 #1
0
ファイル: JobsController.cs プロジェクト: TsvetiZlateva/wBees
        public async Task <IActionResult> PublishJob(JobFullInfoViewModel jobFullInfo)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View());
            }

            var position       = jobFullInfo.Job.Position;
            var employer       = jobFullInfo.Job.Employer;
            var location       = jobFullInfo.Job.Location;
            var description    = jobFullInfo.Job.Description;
            var salary         = jobFullInfo.Job.Salary;
            var subIndustry    = jobFullInfo.Job.SubIndustry;
            var keywords       = jobFullInfo.Job.Keywords;
            var employmentType = jobFullInfo.Job.EmploymentType;
            var seniorityLevel = jobFullInfo.Job.SeniorityLevel;
            var publishedBy    = await this.userManager.GetUserAsync(this.User);

            var industries = jobFullInfo.Industries;


            await this.jobsService.PublishJobAsync(position, employer, location, description, salary, subIndustry, keywords, employmentType, seniorityLevel, publishedBy);

            return(this.RedirectToAction("ListAllJobs"));
        }
コード例 #2
0
        public IActionResult ListJobs(JobFullInfoViewModel jobFullInfo)
        {
            var position        = jobFullInfo.Job.Position;
            var location        = jobFullInfo.Job.Location;
            var salary          = jobFullInfo.Job.Salary;
            var keywords        = jobFullInfo.Job.Keywords;
            var x               = this.Request.Query["EmploymentTypes"].ToString();
            var employmentTypes = this.Request.Query["EmploymentTypes"].ToString() == "" ? null : this.Request.Query["EmploymentTypes"].ToString().Split(',').ToList();
            var seniorityLevels = this.Request.Query["SeniorityLevels"].ToString() == "" ? null : this.Request.Query["SeniorityLevels"].ToString().Split(',').ToList();
            var subIndustries   = new List <string>();
            var industries      = jobFullInfo.Industries;

            var jobs = this.searchService.SearchInJobs(position, location, salary, subIndustries, keywords, employmentTypes, seniorityLevels);

            var jobsViewModel = jobs
                                .Select(jobs => new EditJobViewModel
            {
                Id             = jobs.Id,
                PublishedOn    = jobs.PublishedOn.ToString("dd.MM.yyyy"),
                Position       = jobs.Position,
                Employer       = jobs.Employer,
                EmploymentType = jobs.EmploymentType.Name
            })
                                .ToList();

            return(View(jobsViewModel));
        }
コード例 #3
0
        public async Task <ActionResult> Edit(Guid id, JobFullInfoViewModel model)
        {
            if (id != model.Job.Id)
            {
                return(this.NotFound());
            }

            if (this.ModelState.IsValid)
            {
                var job = new EditJobDTO
                {
                    Position    = model.Job.Position,
                    Employer    = model.Job.Employer,
                    Location    = model.Job.Location,
                    Description = model.Job.Description,
                    Salary      = model.Job.Salary,
                    SubIndustry = model.Job.SubIndustry,
                    //Keywords= model.Job.Keywords?.Split(',').ToList(),
                    EmploymentType = model.Job.EmploymentType,
                    SeniorityLevel = model.Job.SeniorityLevel
                };

                try
                {
                    await this.jobsService.UpdateJobAsync(id, job);
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }

                return(RedirectToAction(nameof(JobsList)));
            }

            return(View());
        }
コード例 #4
0
ファイル: JobsController.cs プロジェクト: TsvetiZlateva/wBees
        public IActionResult PublishJob()
        {
            var locationsFromDTO            = this.locationsService.GetAllLocations();
            List <SelectListItem> locations = new List <SelectListItem>();

            foreach (var location in locationsFromDTO)
            {
                SelectListItem l = new SelectListItem()
                {
                    Value = location.Id.ToString(),
                    Text  = location.Name
                };
                locations.Add(l);
            }

            var employmentTypesFromDTO            = this.jobsService.GetEmploymentTypes();
            List <SelectListItem> employmentTypes = new List <SelectListItem>();

            foreach (var et in employmentTypesFromDTO)
            {
                SelectListItem e = new SelectListItem()
                {
                    Value = et.Id.ToString(),
                    Text  = et.Name
                };
                employmentTypes.Add(e);
            }

            var seniorityLevelsFromDTO            = this.jobsService.GetSeniorityLevels();
            List <SelectListItem> seniorityLevels = new List <SelectListItem>();

            foreach (var sl in seniorityLevelsFromDTO)
            {
                SelectListItem s = new SelectListItem()
                {
                    Value = sl.Id.ToString(),
                    Text  = sl.Name
                };
                seniorityLevels.Add(s);
            }

            var industriesFromDTO = this.industriesService.GetAllIndustries();
            List <IndustryViewModel> industries = new List <IndustryViewModel>();

            foreach (var industry in industriesFromDTO)
            {
                IndustryViewModel i = new IndustryViewModel();
                i.Id   = industry.Id;
                i.Name = industry.Name;

                foreach (var job in industry.Jobs)
                {
                    i.Jobs.Add(new EditJobViewModel
                    {
                        Id             = job.Id,
                        Position       = job.Position,
                        Location       = job.Location.Name,
                        Description    = job.Description,
                        Salary         = job.Salary,
                        SubIndustry    = job.SubIndustry.Name,
                        EmploymentType = job.EmploymentType.Name,
                        SeniorityLevel = job.SeniorityLevel.Name
                    });
                }

                foreach (var subIndustry in industry.SubIndustries)
                {
                    i.SubIndustries.Add(new SubIndustryViewModel
                    {
                        Id   = subIndustry.Id,
                        Name = subIndustry.Name
                    });
                }

                industries.Add(i);
            }

            var viewModel = new JobFullInfoViewModel
            {
                Job             = new EditJobViewModel(),
                Industries      = industries,
                Locations       = locations,
                EmploymentTypes = employmentTypes,
                SeniorityLevels = seniorityLevels
            };

            return(this.View(viewModel));
        }
コード例 #5
0
        // GET: AdminController/Create
        //public ActionResult Create()
        //{
        //    return View();
        //}

        // POST: AdminController/Create
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create(IFormCollection collection)
        //{
        //    try
        //    {
        //        return RedirectToAction(nameof(Index));
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        // GET: AdminController/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(this.NotFound());
            }

            var locationsFromDTO            = this.locationsService.GetAllLocations();
            List <SelectListItem> locations = new List <SelectListItem>();

            foreach (var location in locationsFromDTO)
            {
                SelectListItem l = new SelectListItem()
                {
                    Value = location.Id.ToString(),
                    Text  = location.Name
                };
                locations.Add(l);
            }

            var employmentTypesFromDTO            = this.jobsService.GetEmploymentTypes();
            List <SelectListItem> employmentTypes = new List <SelectListItem>();

            foreach (var et in employmentTypesFromDTO)
            {
                SelectListItem e = new SelectListItem()
                {
                    Value = et.Id.ToString(),
                    Text  = et.Name
                };
                employmentTypes.Add(e);
            }

            var seniorityLevelsFromDTO            = this.jobsService.GetSeniorityLevels();
            List <SelectListItem> seniorityLevels = new List <SelectListItem>();

            foreach (var sl in seniorityLevelsFromDTO)
            {
                SelectListItem s = new SelectListItem()
                {
                    Value = sl.Id.ToString(),
                    Text  = sl.Name
                };
                seniorityLevels.Add(s);
            }

            var industriesFromDTO = this.industriesService.GetAllIndustries();
            List <IndustryViewModel> industries = new List <IndustryViewModel>();

            foreach (var industry in industriesFromDTO)
            {
                IndustryViewModel i = new IndustryViewModel();
                i.Id   = industry.Id;
                i.Name = industry.Name;

                foreach (var j in industry.Jobs)
                {
                    i.Jobs.Add(new EditJobViewModel
                    {
                        Id             = j.Id,
                        Position       = j.Position,
                        Location       = j.Location.Name,
                        Description    = j.Description,
                        Salary         = j.Salary,
                        SubIndustry    = j.SubIndustry.Name,
                        EmploymentType = j.EmploymentType.Name,
                        SeniorityLevel = j.SeniorityLevel.Name
                    });
                }

                foreach (var subIndustry in industry.SubIndustries)
                {
                    i.SubIndustries.Add(new SubIndustryViewModel
                    {
                        Id   = subIndustry.Id,
                        Name = subIndustry.Name
                    });
                }

                industries.Add(i);
            }

            var job = this.jobsService.GetJobInfo((Guid)id, null);

            if (job == null)
            {
                return(this.NotFound());
            }
            var jobViewModel = new EditJobViewModel
            {
                Id             = job.Id,
                Position       = job.Position,
                Employer       = job.Employer,
                Location       = job.Location,
                Description    = job.Description,
                Salary         = job.Salary,
                Keywords       = String.Join(',', job.Keywords),
                SubIndustry    = job.SubIndustry,
                EmploymentType = job.EmploymentType,
                SeniorityLevel = job.SeniorityLevel
            };

            var viewModel = new JobFullInfoViewModel
            {
                Job             = jobViewModel,
                Industries      = industries,
                Locations       = locations,
                EmploymentTypes = employmentTypes,
                SeniorityLevels = seniorityLevels
            };

            return(this.View(viewModel));
        }