Esempio n. 1
0
        public VacancyDto CreateForUser(Int32 userId, CreateVacancyDto vacancyData)
        {
            User user = _userRepository.Get(userId);

            if (user.Type != UserType.Recruiter)
            {
                throw new ArgumentException($"Unable to create recruiter for not candidate user with id {userId}!");
            }
            if (_vacancyRepository.IsHaveForUser(userId))
            {
                throw new ArgumentException($"Vacancy for user with id {userId} have already created!");
            }

            var vacancy = new Vacancy(
                user,
                _specializationRepository.GetByName(vacancyData.Specialization),
                vacancyData.Skills
                .Select(s => _skillRepository.GetByName(s))
                .ToList(),
                vacancyData.Information);

            vacancy = _vacancyRepository.Create(vacancy);

            return(VacancyDto.Create(vacancy));
        }
Esempio n. 2
0
        public ActionResult Create(VacancyVM model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                var Employer = _empManager.GetUserAsync(User).Result;

                model.EmployerId = Employer.Id;

                var vacancy  = _mapper.Map <vacancy>(model);
                var isSucess = _repo.Create(vacancy);

                if (!isSucess)
                {
                    ModelState.AddModelError("", "Something went wrong...");
                    return(View(model));
                }



                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something went wrong...");
                return(View(model));
            }
        }
        public async Task <ActionResult <VacancyDto> > Create(VacancyRequest model)
        {
            var vacancy = await _repository.Create(model);

            return(vacancy != null
                ? Created(nameof(Create), vacancy)
                : StatusCode(StatusCodes.Status500InternalServerError, null));
        }
        public async Task <IActionResult> Create([Bind("Id,FunctionDescription,VacancySince")] Vacancy vacancy)
        {
            if (ModelState.IsValid)
            {
                vacancy.Enabled = true;
                await _vacancyRepository.Create(vacancy);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vacancy));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(VacancyDTO vacancyDto)
        {
            var vacancy = _mapper.Map <Vacancy>(vacancyDto);

            await _repo.Create(vacancy);

            if (await _repo.SaveAll())
            {
                return(CreatedAtRoute("CreateVacancy", new { id = vacancy.Id }, vacancy));
            }

            return(BadRequest("creation unsuccessful"));
        }
Esempio n. 6
0
        public Task <Vacancy> Post(Vacancy vacancy, ICollection <int> candidates, int userId)
        {
            return(Task.Run(async() =>
            {
                await Task.Run(() =>
                {
                    AttachNewCandidates(vacancy, candidates);

                    SetUpNulls(vacancy);

                    vacancy.HRM = userId;

                    vacancy.LastModifier = userId;
                }).ConfigureAwait(false);

                return await Task.Run(() => vacancyRepository.Create(vacancy)).ConfigureAwait(false);
            }));
        }
Esempio n. 7
0
 public Vacancy Create(Vacancy vacancy)
 {
     return(vacancyRepository.Create(vacancy));
 }
 public void Create(Guid vacancyId, string userId)
 {
     _vacancyRepository.Create(vacancyId, userId);
 }