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)); } }