예제 #1
0
        public async Task <HttpResponseMessage> UpdateStatus(HttpRequestMessage request, [FromBody] StatusUpdateInDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var e = await eventService.RegisterCandidateStatusUpdate(value.EntityId, value.Status, userId);

                var candidate = await candidateService.UpdateStatus(value.EntityId, value.Status, userId);

                unitOfWork.Save();

                await candidateElasticService.UpdateStatusElastic(value.EntityId, value.Status).ConfigureAwait(false);

                var notification = await notificationService.CreateNotification(candidate.HRM,
                                                                                NotificationTypes.Update, new List <Event> {
                    e
                });

                if (NotificationsHub.IsConnected(candidate.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
예제 #2
0
        public async Task <HttpResponseMessage> UnassignVacancy(HttpRequestMessage request, int candidateId, int vacancyId)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var e = await eventService.RegisterCandidateFromVacancyUnassignment(vacancyId, candidateId, userId);

                var updatedCandidate = await candidateService.UnassignVacancy(candidateId, vacancyId, userId);

                unitOfWork.Save();

                var notification = await notificationService.CreateNotification(updatedCandidate.HRM,
                                                                                NotificationTypes.Update, new List <Event> {
                    e
                });

                if (NotificationsHub.IsConnected(updatedCandidate.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(new { candidateId, vacancyId }));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
예제 #3
0
        public async Task <HttpResponseMessage> AssignVacancies(HttpRequestMessage request, CandidatesVacanciesInDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var result = await candidateService.AssignVacancies(value.Vacancies, value.Candidates, userId);

                unitOfWork.Save();

                foreach (var item in result.Events)
                {
                    var notification = await notificationService.CreateNotification(item.Key,
                                                                                    NotificationTypes.Update, item.Value);

                    if (NotificationsHub.IsConnected(item.Key))
                    {
                        await NotificationsHub.PushNotification(notification);
                    }
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
예제 #4
0
        public async Task <HttpResponseMessage> AddGeneralInterview(HttpRequestMessage request, [FromBody] GeneralInterviewInDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var interview = Mapper.Map <GeneralInterviewInDTO, GeneralInterview>(value);

                interview.HRM = userId;

                var createdInterview = await interviewService.AddGeneralInterview(interview);

                var e = await eventService.RegisterGeneralInterview(createdInterview, userId);

                unitOfWork.Save();

                if (createdInterview.Interviewer.HasValue)
                {
                    var notification = await notificationService.CreateNotification(createdInterview.Interviewer.Value,
                                                                                    NotificationTypes.Interview, new List <Event> {
                        e
                    });

                    if (NotificationsHub.IsConnected(createdInterview.Interviewer.Value))
                    {
                        await NotificationsHub.PushNotification(notification);
                    }
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
예제 #5
0
        public async Task <HttpResponseMessage> Update(HttpRequestMessage request, [FromBody] CandidateInputDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var candidate = Mapper.Map <CandidateInputDTO, Candidate>(value);

                candidate.LastModifier = userId;

                var events = await eventService.RegisterCandidateUpdate(candidate, userId);

                var updatedCandidate = await candidateService.Update(candidate, value.VacanciesIds)
                                       .ConfigureAwait(false);

                unitOfWork.Save();

                var candidateElasticModel = Mapper.Map <Candidate, CandidateElasticModel>(updatedCandidate);
                await candidateElasticService.UpdateCandidateElastic(candidateElasticModel);

                var notification = await notificationService.CreateNotification(updatedCandidate.HRM,
                                                                                NotificationTypes.Update, events);

                if (NotificationsHub.IsConnected(updatedCandidate.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
예제 #6
0
        public async Task <HttpResponseMessage> UpdateTech(HttpRequestMessage request, [FromBody] InterviewUpdateDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var techInterview = Mapper.Map <InterviewUpdateDTO, TechInterview>(value);

                techInterview.HRM = userId;

                var eventsForNotification = await eventService.RegisterTechInterviewUpdate(techInterview, userId);

                var updatedInterview = await interviewService.UpdateTechInterview(techInterview);

                unitOfWork.Save();

                if (updatedInterview.Interviewer.HasValue)
                {
                    var notification = await notificationService.CreateNotification(updatedInterview.Interviewer.Value,
                                                                                    NotificationTypes.Update, eventsForNotification);

                    if (NotificationsHub.IsConnected(updatedInterview.Interviewer.Value))
                    {
                        await NotificationsHub.PushNotification(notification);
                    }
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
예제 #7
0
        public async Task <HttpResponseMessage> SetFeedbackGeneral(HttpRequestMessage request, [FromBody] GeneralInterviewFeedbackInDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var generalInterview = Mapper.Map <GeneralInterviewFeedbackInDTO, GeneralInterview>(value);

                var updatedInterview = await interviewService.SetGeneralInterviewFeedback(generalInterview);

                var events = await eventService.RegisterGeneralInterviewFeedback(updatedInterview, userId);

                unitOfWork.Save();

                await notificationService.MarkAsRead(userId, new List <int> {
                    value.NotificationId
                });

                var notification = await notificationService.CreateNotification(updatedInterview.HRM,
                                                                                NotificationTypes.Update, events);

                if (NotificationsHub.IsConnected(updatedInterview.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
예제 #8
0
        public async Task <HttpResponseMessage> Update(HttpRequestMessage request, [FromBody] VacancyInputDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var vacancy = Mapper.Map <VacancyInputDTO, Vacancy>(value);

                var e = await eventService.RegisterVacancyUpdate(vacancy, userId);

                var updatedVacancy = await vacancyService.Update(vacancy, value.Candidates, userId)
                                     .ConfigureAwait(false);

                unitOfWork.Save();

                var elasticVacancy = Mapper.Map <Vacancy, VacancyElasticModel>(updatedVacancy);
                await vacancyElasticService.UpdateVacancyElastic(elasticVacancy);

                var notification = await notificationService.CreateNotification(updatedVacancy.HRM,
                                                                                NotificationTypes.Update, e);

                if (NotificationsHub.IsConnected(updatedVacancy.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }