public async Task <IActionResult> AddAnswer([FromForm(Name = "questionID")] int questionID, [FromForm(Name = "content")] string content, [FromServices] IHubContext <NotificationUserHub> notifyUser) { try { var user = await usersRepository.GetUserByUserName(User.Identity.Name); if (user == null) { throw new Exception(); } await answersRepository.AddAnswer(questionID, content, user.Id); if (content.Length > 20) { content = content.Substring(0, 17); content += "..."; } await notificationRepository.SendNotification(user.Id, questionID, Models.NotificationType.QUESTION, content, notifyUser); return(Ok()); } catch (Exception) { return(BadRequest()); } }