Exemplo n.º 1
0
        public async Task <BaseResponseMessageResult> DeleteVacancyAsync(Guid id)
        {
            var response = new BaseResponseMessageResult();

            var vacancy = await _vacancyRepository.GetAsync(id);

            if (vacancy == null)
            {
                response.SetStatus(HttpStatusCode.NotFound, $"Vacancy [{id}] was not found!");
                return(response);
            }

            await _vacancyRepository.RemoveAsync(id);

            await _unitOfWork.SaveChangesAsync();

            response.Message = $"Vacancy [{id}] was removed!";
            return(response);
        }
        public async Task <BaseResponseMessageResult> DeleteCandidateAsync(Guid id)
        {
            var response = new BaseResponseMessageResult();

            var candidate = await GetCandidateByIdAsync(id);

            if (candidate == null)
            {
                response.SetStatus(HttpStatusCode.NotFound, $"Candidate [{id}] was not found!");
                return(response);
            }

            await _candidateRepository.RemoveAsync(id);

            await _unitOfWork.SaveChangesAsync();

            response.Message = $"Candidate [{id}] was removed!";
            return(response);
        }
        public async Task <BaseResponseMessageResult> UpdateCandidateAsync(Guid id, CandidateViewModel candidate)
        {
            var response = new BaseResponseMessageResult();

            var oldCandidate = await _candidateRepository.GetAsync(id);

            if (oldCandidate == null)
            {
                response.SetStatus(HttpStatusCode.NotFound, $"Candidate [{id}] was not found!");
                return(response);
            }

            var updatedCandidate = _mapper.Map(candidate, oldCandidate);

            _candidateRepository.Update(updatedCandidate);
            await _unitOfWork.SaveChangesAsync();

            response.Message = $"Candidate [{id}] was updated!";
            return(response);
        }
Exemplo n.º 4
0
        public async Task <BaseResponseMessageResult> DeleteUserAsync(string id)
        {
            var response = new BaseResponseMessageResult();

            var user = await _context.Users
                       .Where(u => u.Id == id)
                       .SingleOrDefaultAsync();

            if (user == null)
            {
                response.SetStatus(HttpStatusCode.NotFound, $"User [{id}] was not found!");
                return(response);
            }

            _context.Users.Remove(user);
            await _unitOfWork.SaveChangesAsync();

            response.Message = $"User [{id}] was removed!";
            return(response);
        }
Exemplo n.º 5
0
        public async Task <BaseResponseMessageResult> UpdateVacancyAsync(Guid id, VacancyViewModel vacancy)
        {
            var response = new BaseResponseMessageResult();

            var oldVacancy = await _vacancyRepository.GetAsync(id);

            if (vacancy == null)
            {
                response.SetStatus(HttpStatusCode.NotFound, $"Vacancy [{id}] was not found!");
                return(response);
            }

            var updatedVacancy = _mapper.Map(vacancy, oldVacancy);

            _vacancyRepository.Update(updatedVacancy);
            await _unitOfWork.SaveChangesAsync();

            response.Message = $"Vacancy [{id}] was updated!";
            return(response);
        }
Exemplo n.º 6
0
        public async Task <BaseResponseMessageResult> UpdateDepartmentAsync(Guid id, DepartmentViewModel department)
        {
            var response = new BaseResponseMessageResult();

            var oldDepartment = await _departmentRepository.GetAsync(id);

            if (oldDepartment == null)
            {
                response.SetStatus(HttpStatusCode.NotFound, $"Department [{id}] was not found!");
                return(response);
            }

            var updatedDepartment = _mapper.Map(department, oldDepartment);

            _departmentRepository.Update(updatedDepartment);
            await _unitOfWork.SaveChangesAsync();

            response.Message = $"Department [{id}] was updated!";

            return(response);
        }
Exemplo n.º 7
0
        public async Task <BaseResponseMessageResult> UpdateUserAsync(string id, UserViewModel user)
        {
            var response = new BaseResponseMessageResult();

            var oldUser = await _context.Users
                          .Where(u => u.Id == id)
                          .SingleOrDefaultAsync();

            if (oldUser == null)
            {
                response.SetStatus(HttpStatusCode.NotFound, $"User [{id}] was not found!");
                return(response);
            }

            var updatedUser = _mapper.Map <User>(user);

            _context.Users.Update(updatedUser);
            await _unitOfWork.SaveChangesAsync();

            response.Message = $"User [{id}] was updated!";
            return(response);
        }