示例#1
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));
            }
        }