public IActionResult PostIdeationReply([FromForm] IdeationReplyDTO ideationReplyDto) { // return Created("/ideation/overview/1", null); //log test 1 Ideation ideation = _ideationManager.GetIdeationWithQuestions(ideationReplyDto.IdeationId); //log test 2 User user = _usermanager.GetUserAsync(User).Result; //log test 3 if (ideation == null || user == null) { return(NotFound()); } //log test 4 IdeationReply newReply = new IdeationReply() { Ideation = ideation, Title = ideationReplyDto.Title, Answers = new List <Answer>(), Votes = new List <Vote>(), Comments = new List <Comment>(), Created = DateTime.Now, User = user, Reports = new List <IdeationReport>() }; //log test 5 int index = 0; ideationReplyDto.Answers.ForEach(dto => { Answer newAnswer = null; switch (dto.FieldType) { case FieldType.OpenText: newAnswer = new OpenTextAnswer() { QuestionIndex = dto.QuestionIndex, Value = dto.OpenAnswer }; break; case FieldType.Image: case FieldType.Video: string fileName = Util.Util.GenerateDataStoreObjectName(dto.FileAnswer.FileName); string pathName = _fileUploader.UploadFile(fileName, "ideationReply", dto.FileAnswer).Result; newAnswer = new MediaAnswer() { QuestionIndex = dto.QuestionIndex, Value = new Media() { Name = dto.FileAnswer.FileName, Url = pathName } }; break; case FieldType.SingleChoice: case FieldType.DropDown: newAnswer = new SingleChoiceAnswer() { QuestionIndex = dto.QuestionIndex, SelectedChoice = dto.SingleAnswer }; break; case FieldType.MultipleChoice: newAnswer = new MultipleChoiceAnswer() { QuestionIndex = dto.QuestionIndex, SelectedChoices = dto.MultipleAnswer }; break; case FieldType.Location: newAnswer = new LocationAnswer() { QuestionIndex = dto.QuestionIndex, Value = new Location() { Latitude = dto.LocationAnswer.Latitude, Longitude = dto.LocationAnswer.Longitude, ZoomLevel = dto.LocationAnswer.ZoomLevel, } }; break; default: throw new ArgumentOutOfRangeException(); } newAnswer.OrderIndex = index++; newReply.Answers.Add(newAnswer); }); //log test 6 _ideationManager.AddIdeationReply(newReply); //log test 7 // Create activity var activity = CreateActivity(ActivityType.IdeationReply, user); activity.IdeationReply = newReply; _activityManager.AddActivity(activity); //log test 8 // Save everything _unitOfWorkManager.Save(); //log test 9 // Push activity var activityVm = new ActivityViewModel(activity); //log test 10 PushWebsockets(activityVm).Wait(); //log test 11 return(Created("/ideation/view/" + newReply.IdeationReplyId, new { id = newReply.IdeationReplyId })); }