Ejemplo n.º 1
0
        public ViewResult Edit(int id)
        {
            Vacancy employee      = _empRepo.GetVacancy(id);
            Vacancy employeeModel = new Vacancy
            {
                Description = employee.Description,
                Date        = employee.Date,
                Time        = employee.Time
            };

            return(View(employeeModel));
        }
Ejemplo n.º 2
0
        public Vacancy GetVacancy(long id)
        {
            if (id <= 0)
            {
                return(new Vacancy());
            }

            return(_vacancyRepository.GetVacancy(id));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> UpdateVacancy(int id, [FromBody] PostVacancyDto vacancyDto)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(BadRequest("Please signed in to your account."));
            }

            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            if (string.IsNullOrEmpty(userId))
            {
                return(Unauthorized());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest("Something went wrong..."));
            }

            var validateModel = _repo.ValidateVacancy(vacancyDto);

            if (validateModel == null)
            {
                return(BadRequest("Something went wrong..."));
            }

            var currentlyLoginUserName = User.Identity.Name;
            var loggedInUser           = await _user.FindByEmailAsync(currentlyLoginUserName);

            var vacancy = await _repo.GetVacancy(id, loggedInUser);

            if (vacancy == null)
            {
                return(NotFound("No such Job post available."));
            }

            var updatedVacancy = _mapper.Map <PostVacancyDto, Vacancy>(vacancyDto, vacancy);
            await _sharedRepo.SaveAll();

            var returnUpdatedVacancy = _mapper.Map <DetailedVacancyDto>(updatedVacancy);

            return(Ok(returnUpdatedVacancy));
        }
Ejemplo n.º 4
0
    public async Task <Vacancy> Get(int id)
    {
        var key = $"vacancy_{id}";

        var result = _cache.Get(key) as Vacancy;

        if (result == null)
        {
            result = await _repository.GetVacancy(id);

            _cache.Set(key, result, GetMemoryCacheEntryOptions());
        }

        return(result);
    }
Ejemplo n.º 5
0
        public IActionResult EditVacancy(int id)
        {
            Vacancy vacancy = vacancyRepository.GetVacancy(id);

            if (vacancy != null)
            {
                VacancyViewModel model = new VacancyViewModel
                {
                    Id          = vacancy.Id,
                    JobTitle    = vacancy.JobTitle,
                    JobType     = vacancy.JobType,
                    JobPeriod   = vacancy.JobPeriod,
                    Salary      = vacancy.Salary,
                    PayInterval = vacancy.PayInterval,
                    Description = vacancy.Description
                };

                return(View(model));
            }

            return(RedirectToAction("Vacancies", "Home"));
        }