public IActionResult CreateLink(IoTDTO iot, [FromServices] IFormManager formManager, [FromServices] IIdeationManager ideationManager, [FromServices] IIoTManager ioTManager, [FromServices] UnitOfWorkManager unitOfWorkManager) { IotLink link = null; Location location = new Location() { Longitude = iot.Location.Longitude, Latitude = iot.Location.Latitude, ZoomLevel = iot.Location.ZoomLevel }; if (iot.IsForm) { Form form = formManager.GetForm(iot.FormId); if (form == null) { return(NotFound()); } link = ioTManager.CreateIotLink(form, null, form.Project, location); } else { Ideation ideation = ideationManager.GetIdeationWithReplies(iot.IdeationId); IdeationReply reply = ideationManager.GetIdeationReply(ideation.Replies[0].IdeationReplyId); if (reply == null) { return(NotFound()); } link = ioTManager.CreateIotLink(null, reply, ideation.Project, location); } unitOfWorkManager.Save(); return(Created("", new { id = link.IotLinkId })); }
public IActionResult ChangeIdeation(int id) { Ideation i = _moduleMgr.GetIdeation(id); ViewData["Project"] = i.Project.Id; List <Phase> allPhases = (List <Phase>)_projMgr.GetAllPhases(i.Project.Id); List <Phase> availablePhases = new List <Phase>(); foreach (Phase phase in allPhases) { if (_moduleMgr.GetIdeation(phase.Id, i.Project.Id) == null) { availablePhases.Add(phase); } } ViewData["Phases"] = availablePhases; ViewData["PhaseCount"] = availablePhases.Count; ViewData["Ideation"] = id; AlterIdeationModel aim = new AlterIdeationModel() { Title = i.Title, ExtraInfo = i.ExtraInfo, ParentPhase = _projMgr.GetPhase(i.ParentPhase.Id) }; return(View(aim)); }
/// <summary> /// Helper for reducing duplicate code /// </summary> /// <param name="id"></param> /// <param name="newState"></param> /// <returns></returns> private IActionResult ChangeIdeationState(int id, bool newState) { try { _unitOfWorkManager.StartUnitOfWork(); Ideation updatedIdeation = _ideationManager.ChangeIdeationState(id, newState); _unitOfWorkManager.EndUnitOfWork(); if (updatedIdeation == null) { return(BadRequest("Something went wrong while updating the ideation state.")); } return(Ok(_mapper.Map <IdeationDto>(updatedIdeation))); } catch (ValidationException ve) { return(UnprocessableEntity($"Invalid input data: {ve.ValidationResult.ErrorMessage}")); } catch (ArgumentException e) { switch (e.ParamName) { case "id": return(NotFound(e.Message)); default: return(BadRequest(e.Message)); } } }
public Ideation EditIdeation(Ideation ideation, int ideationId) { ideation.IdeationId = ideationId; //ideation.Phase = GetIdeation(ideationId).Phase; ideationsRepository.EditIdeation(ideation); unitOfWorkManager.Save(); return(ideation); }
public void CreateIdeation(Ideation ideation, int phaseId) { ProjectsManager projectsManager = new ProjectsManager(unitOfWorkManager); Phase phase = projectsManager.GetPhase(phaseId); ideation.Phase = phase; ideationsRepository.CreateIdeation(ideation); unitOfWorkManager.Save(); }
public IActionResult AddIdeation(Ideation ideation, int phaseId) { if (ModelState.IsValid) { ideationsManager.CreateIdeation(ideation, phaseId); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }
public IActionResult EditIdeation(Ideation ideation, int ideationId) { if (ModelState.IsValid) { Ideation editIdeation = ideationsManager.EditIdeation(ideation, ideationId); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }
public IActionResult GetIdeation(int ideationId) { Ideation ideation = _ideationManager.GetIdeationWithQuestions(ideationId); if (ideation == null) { return(NoContent()); } return(Ok(ideation)); }
public IEnumerable <Question> GetIdeationQuestions(int ideationId) { Ideation ideation = _ideationRepository.ReadIdeationWithQuestions(ideationId); if (ideation == null || !ideation.Questions.Any()) { return(new List <Question>()); } ideation.Questions.Sort(); return(ideation.Questions); }
public IActionResult Details(int id) { string userId = null; if (_signInManager.IsSignedIn(User)) { userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; } Ideation ideation = _ideationManager.GetIdeation(id); var ideas = _ideasHelper.GetIdeas(userId, ideation.IdeationId); Dictionary <int, SAVotes> ideaVotes = new Dictionary <int, SAVotes>(); foreach (var idea in ideas) { var anVotes = 0; var veVotes = 0; var usVotes = 0; var realIdea = _ideationManager.GetIdea(idea.IdeaId); foreach (var vote in realIdea.Votes) { if (vote.User != null) { usVotes += vote.Value; } else if (vote.Email != null) { veVotes += vote.Value; } else { anVotes += vote.Value; } } ideaVotes.Add(realIdea.IdeaId, new SAVotes() { anVotes = anVotes, veVotes = veVotes, usVotes = usVotes }); } var model = new IdeationUserVote { ideas = ideas, ideation = ideation, ideaVotes = ideaVotes }; return(View(model)); }
public static TModel FromIdeation <TModel>(Ideation ideation) where TModel : IdeationApiModel, new() { var model = new TModel(); model.Id = ideation.Id; model.TenantId = ideation.TenantId; model.Name = ideation.Name; model.Start = ideation.Start; model.End = ideation.End; model.MaxiumIdeasPerUser = ideation.MaxiumIdeasPerUser; model.MaxiumumVotesPerUser = ideation.MaxiumumVotesPerUser; return(model); }
public IActionResult PostIdeation(IdeationDTO ideationDto, [FromServices] IProjectManager projectManager) { Project project = projectManager.GetProject(ideationDto.ProjectId); Phase phase = project.Phases.FirstOrDefault(p => p.PhaseId == ideationDto.PhaseId); Ideation newIdeation = new Ideation() { CentralQuestion = ideationDto.CentralQuestion, Description = ideationDto.Description, Url = ideationDto.Url, Questions = new List <Question>(), Replies = new List <IdeationReply>(), IdeationType = ideationDto.IdeationType, Project = project, Phase = phase }; int index = 0; foreach (QuestionDTO question in ideationDto.Questions) { Question newQuestion = new Question() { FieldType = question.Type, Options = new List <string>(), QuestionString = question.Question, Required = question.Required, LongAnswer = question.LongAnswer, OrderIndex = index, Location = question.Location }; foreach (var option in question.Options) { newQuestion.Options.Add(option.String); } newIdeation.Questions.Add(newQuestion); index++; } _ideationManager.AddIdeation(newIdeation); _unitOfWorkManager.Save(); return(Created("/ideation/reply/" + newIdeation.IdeationId, newIdeation)); }
public async Task <AddOrUpdateIdeationResponse> Handle(AddOrUpdateIdeationRequest request) { var entity = await _context.Ideations .SingleOrDefaultAsync(x => x.Id == request.Ideation.Id && x.TenantId == request.TenantId); if (entity == null) { _context.Ideations.Add(entity = new Ideation()); } entity.Name = request.Ideation.Name; entity.TenantId = request.TenantId; entity.Start = request.Ideation.Start; entity.End = request.Ideation.End; entity.MaxiumIdeasPerUser = request.Ideation.MaxiumIdeasPerUser; entity.MaxiumumVotesPerUser = request.Ideation.MaxiumumVotesPerUser; await _context.SaveChangesAsync(); return(new AddOrUpdateIdeationResponse()); }
public IActionResult Reply(int id) { var tenant = Util.Util.GetSubdomain(HttpContext.Request.Host.ToString()); Ideation ideation = _ideationManager.GetIdeationWithReplies(id); if (ideation == null) { return(RedirectToAction("NotFound", "Home")); } var subdomain = Util.Util.GetSubdomain(HttpContext.Request.Host.ToString()); var ideationSubDomain = ideation.Project.Platform.Tenant; if (subdomain != ideationSubDomain) { return(RedirectToAction("NotFound", "Home")); } ViewBag.ProjectId = ideation.Project.ProjectId; if (ideation.IdeationType == IdeationType.Admin) { User user = _userManager.GetUserAsync(User).Result; bool isAdmin = _userManager.IsUserAdminOrAbove(user, tenant); if (!isAdmin) { return(Unauthorized()); } } var ideationViewModel = new IdeationViewModel() { IdeationId = ideation.IdeationId, CentralQuestion = ideation.CentralQuestion, Description = ideation.Description, Url = ideation.Url, UserId = _userManager.GetUserAsync(User).Result.Id }; return(View(ideationViewModel)); }
public IActionResult AddIdeation(CreateIdeationModel cim, int project, string user) { if (cim == null) { return(BadRequest("Ideation can't be null")); } Ideation i = new Ideation() { Project = new Project() { Id = project }, ParentPhase = new Phase() { Id = Int32.Parse(Request.Form["Parent"].ToString()) }, User = new UimvcUser() { Id = user }, ModuleType = ModuleType.Ideation, Title = cim.Title, OnGoing = true }; if (cim.ExtraInfo != null) { i.ExtraInfo = cim.ExtraInfo; } if (cim.MediaLink != null) { i.MediaLink = cim.MediaLink; } _moduleMgr.MakeIdeation(i); return(RedirectToAction("CollectProject", "Platform", new { Id = project })); }
public void DeleteIdeation(int ideationId) { Ideation ideation = GetIdeation(ideationId); if (ideation.Ideas != null) { foreach (var idea in ideation.Ideas.ToList()) { this.DeleteIdea(idea.IdeaId); } } if (ideation.Reactions != null) { foreach (var reaction in ideation.Reactions.ToList()) { this.DeleteReaction(reaction.ReactionId); } } ideationsRepository.RemoveIdeation(ideation); unitOfWorkManager.Save(); }
public IActionResult UpdateIdeation(int id, NewIdeationDto updatedIdeationValues) { try { _unitOfWorkManager.StartUnitOfWork(); Ideation updatedIdeation = _ideationManager.ChangeIdeation( id, updatedIdeationValues.Title, updatedIdeationValues.ProjectPhaseId); _unitOfWorkManager.EndUnitOfWork(); if (updatedIdeation == null) { return(BadRequest("Something went wrong while updating the ideation.")); } return(Ok(_mapper.Map <IdeationDto>(updatedIdeation))); } catch (ValidationException ve) { return(UnprocessableEntity($"Invalid input data: {ve.ValidationResult.ErrorMessage}")); } catch (ArgumentException e) { switch (e.ParamName) { case "id": return(NotFound(e.Message)); case "projectPhaseId": return(UnprocessableEntity(e.Message)); default: return(BadRequest(e.Message)); } } }
public IActionResult ConfirmChangeIdeation(int ideation) { Ideation i = new Ideation() { Id = ideation, Title = Request.Form["Title"].ToString(), ExtraInfo = Request.Form["ExtraInfo"].ToString(), MediaLink = Request.Form["MediaFile"].ToString() }; try { if (Int32.Parse(Request.Form["ParentPhase"].ToString()) != 0) { i.ParentPhase = _projMgr.GetPhase(Int32.Parse(Request.Form["ParentPhase"].ToString())); _moduleMgr.EditIdeation(i); } }catch (FormatException e) { _moduleMgr.EditIdeation(i); } return(RedirectToAction("CollectIdeation", "Platform", new { Id = ideation })); }
public IActionResult DestroyIdeation(int id) { Ideation i = _moduleMgr.GetIdeation(id); List <IdeationQuestion> iqs = _ideaMgr.GetAllByModuleId(i.Id); foreach (IdeationQuestion iq in iqs) { List <Idea> ideas = _ideaMgr.GetIdeas(iq.Id); foreach (Idea idea in ideas) { _ideaMgr.RemoveFields(idea.Id); _ideaMgr.RemoveReports(idea.Id); _ideaMgr.RemoveVotes(idea.Id); _ideaMgr.RemoveIdea(idea.Id); } _ideaMgr.RemoveQuestion(iq.Id); } _moduleMgr.RemoveModule(id, false); return(RedirectToAction("CollectProject", "Platform", new { Id = i.Project.Id })); }
public void EditIdeation(Ideation ideation) { IdeationRepo.Update(ideation); }
public void MakeIdeation(Ideation ideation) { IdeationRepo.Create(ideation); }
public IEnumerable <Reaction> GetReactionsOnIdeation(Ideation ideation) { return(ctx.Reactions.Where(reaction => reaction.Ideation == ideation).AsEnumerable()); }
//Idea methods public IEnumerable <Idea> GetIdeas(Ideation ideation) { return(ctx.Ideas.Where(idea => idea.Ideation == ideation).AsEnumerable()); }
public IActionResult ViewIdeationReply(int id) { IdeationReply reply = _ideationManager.GetIdeationReply(id); Ideation ideation = reply.Ideation; if (reply == null) { return(NotFound()); } if (ideation == null) { return(StatusCode(500)); } var vm = new IdeationReplyViewModel() { IdeationReplyId = reply.IdeationReplyId, CentralQuestion = ideation.CentralQuestion, DateTime = reply.Created, Answers = new List <AnswerViewModel>(), UserDisplayName = reply.User.GetDisplayName(), UpVotes = reply.Upvotes, Title = reply.Title, DownVotes = reply.Downvotes, }; foreach (Answer answer in reply.Answers) { Question question = ideation.Questions.Find(q => q.OrderIndex == answer.QuestionIndex); if (question != null) { AnswerViewModel answervm = new AnswerViewModel { FieldType = question.FieldType, QuestionString = question.QuestionString, }; switch (question.FieldType) { case FieldType.OpenText: answervm.OpenAnswer = (string)answer.GetValue(); break; case FieldType.Image: case FieldType.Video: answervm.FileAnswer = (Media)answer.GetValue(); break; case FieldType.SingleChoice: case FieldType.DropDown: int singleAnswer = (int)answer.GetValue(); string singleAnswerAsString = question.Options[singleAnswer]; answervm.SingleAnswer = singleAnswerAsString; break; case FieldType.MultipleChoice: List <bool> multiAnswer = (List <bool>)answer.GetValue(); List <string> multiAnswerAsStrings = new List <string>(); for (int i = 0; i < question.Options.Count; i++) { if (multiAnswer[i]) { multiAnswerAsStrings.Add(question.Options[i]); } } answervm.MultipleAnswer = multiAnswerAsStrings; break; case FieldType.Location: answervm.LocationAnswer = (Location)answer.GetValue(); break; default: throw new ArgumentOutOfRangeException(); } vm.Answers.Add(answervm); } } return(Ok(vm)); }
public IActionResult PostIdeationReplyApp([FromBody] IdeationReplyAppDto ideationReplyApp) { Ideation ideation = _ideationManager.GetIdeationWithReplies(ideationReplyApp.IdeationId); User user = _usermanager.FindByEmailAsync(HttpContext.User.Claims.FirstOrDefault(c => c.Type == "Email").Value).Result; IdeationReply newReply = new IdeationReply() { Ideation = ideation, Title = ideationReplyApp.Title, Answers = new List <Answer>(), Votes = new List <Vote>(), Created = DateTime.Now, Comments = new List <Comment>(), User = user, Reports = new List <IdeationReport>() }; int index = 0; foreach (var dto in ideationReplyApp.Answers) { Answer newAnswer = null; switch (dto.FieldType) { case FieldType.OpenText: newAnswer = new OpenTextAnswer() { QuestionIndex = dto.QuestionIndex, Value = dto.Reply }; break; case FieldType.SingleChoice: case FieldType.DropDown: newAnswer = new SingleChoiceAnswer() { QuestionIndex = dto.QuestionIndex, SelectedChoice = dto.SelectedChoice }; 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); } // Create activity var activity = CreateActivity(ActivityType.IdeationReply, user, ideation.Project.Platform); activity.IdeationReply = newReply; _activityManager.AddActivity(activity); // Save everything _unitOfWorkManager.Save(); // Push activity var activityVm = new ActivityViewModel(activity); PushWebsockets(activityVm).Wait(); return(Ok()); }
public IActionResult Ideation(int ideationId) { Ideation ideation = ideationsManager.GetIdeation(ideationId); return(View("/UI/Views/Project/Ideation.cshtml", ideation)); }
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 })); }
public Ideation EditIdeation(Ideation ideation) { ctx.Ideations.Update(ideation); ctx.SaveChanges(); return(ideation); }
public Ideation CreateIdeation(Ideation ideation) { _ctx.Ideations.Add(ideation); _ctx.SaveChanges(); return(ideation); }
public void RemoveIdeation(Ideation ideation) { ctx.Ideations.Remove(ideation); ctx.SaveChanges(); }