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 <ActionResult <VacancyDto> > Update(int id, VacancyRequest model)
        {
            var vacancy = await _repository.GetById(id);

            if (vacancy == null)
            {
                return(NotFound(VacancyNotFound));
            }

            var result = await _repository.Update(id, model);

            return(result != null
                ? Accepted(nameof(Update), result)
                : StatusCode(StatusCodes.Status500InternalServerError, null));
        }
        public async Task <VacancyDto> Update(int id, VacancyRequest model)
        {
            var vacancy = await _db.Vacancies.FindAsync(id);

            vacancy.Description   = model.Description;
            vacancy.Employee      = model.Employee;
            vacancy.Location      = model.Location;
            vacancy.Title         = model.Title;
            vacancy.JobCategoryId = model.JobCategoryId;
            vacancy.JobTypeId     = model.JobTypeId;

            _db.Vacancies.Update(vacancy);
            await _db.SaveChangesAsync();

            return(await GetById(vacancy.Id));
        }
        public async Task <VacancyDto> Create(VacancyRequest model)
        {
            var vacancy = new Data.Models.Vacancy
            {
                Description   = model.Description,
                Employee      = model.Employee,
                Location      = model.Location,
                Title         = model.Title,
                JobCategoryId = model.JobCategoryId,
                JobTypeId     = model.JobTypeId
            };

            _db.Vacancies.Add(vacancy);
            await _db.SaveChangesAsync();

            return(await GetById(vacancy.Id));
        }