public ActionResult Create(IdeaPostViewModel idea)
        {
            var userManager = new UserManager<User>(new UserStore<User>(new UserVoiceSystemDbContext()));
            var newIdea = new Idea()
            {
                Title = new HtmlSanitizer().Sanitize(idea.Title),
                Description = new HtmlSanitizer().Sanitize(idea.Description)
            };

            var userId = this.User.Identity.GetUserId();
            if (userId != null)
            {
                var user = userManager.FindById(userId);
                newIdea.AuthorIpAddress = user.IpAddress;
            }
            else
            {
                newIdea.AuthorIpAddress = this.GetRandomIpAddress();
            }

            this.ideas.Add(newIdea);
            this.ideas.SaveChanges();

            return this.RedirectToAction("Index", "Home");
        }
示例#2
0
        public void I_can_set_the_idea_creator()
        {
            var idea = new Idea("set the creator");
            idea.Creator = "vquaiato";

            Assert.AreEqual("vquaiato", idea.Creator);
        }
示例#3
0
        public void I_can_add_actions_to_accomplish()
        {
            var idea = new Idea("to accomplish");
            idea.AddActionToAccomplish("some action");

            Assert.IsTrue(idea.HasActionsToAccomplish);
        }
示例#4
0
        public void Idea_InvalidNullStringConstructorTest()
        {
            string guid1 = String.Empty;
            Idea idea1 = new Idea(guid1);

            string guid2 = null;
            Idea idea2 = new Idea(guid2);
        }
示例#5
0
 public static TreeItemDto FromBase(Idea idea, AllDb db)
 {
     return new IdeaDto(db)
     {
         Id = idea.Id,
         Caption = idea.Caption,
         IsClosed = true
     };
 }
示例#6
0
        public IdeaViewModel(Idea idea)
        {
            Id = idea.Id;
            Title = idea.Title;
            Description = MarkdownHelper.Markdown(idea.Description);

            TotalVotes = idea.Votes.Count;

            Features = idea.Features.Select(f => new FeatureViewModel(f)).ToList();
            Activities = idea.Activities.Select(f => new ActivityViewModel(f)).ToList();
        }
示例#7
0
        public void Idea_InvalidBadStringConstructorTest()
        {
            string guid1 = Guid.NewGuid().ToString().Remove(0, 10);
            Idea idea1 = new Idea(guid1);

            string guid2 = "Random test to init a guid";
            Idea idea2 = new Idea(guid2);

            string guid3 = "This-is-a-test-to-see-if-the-idea-will-initialize";
            Idea idea3 = new Idea(guid3);
        }
示例#8
0
        public void Delete(Idea idea)
        {
            var databaseIdea = this.GetById(idea.Id);

            foreach (var item in databaseIdea.Comments)
            {
                this.comments.Delete(item);
            }

            this.ideas.Delete(databaseIdea);
        }
示例#9
0
        public IActionResult Create(Idea idea)
        {
            if (ModelState.IsValid)
            {
                idea.UserId = int.Parse(User.GetUserId());

                _context.Ideas.Add(idea);
                _context.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(idea);
        }
示例#10
0
        public IActionResult AddComment(Idea idea)
        {
            if (ModelState.IsValid)
            {
                idea.UserId = int.Parse(User.GetUserId());

                _context.Ideas.Add(idea);
                _context.SaveChanges();

            }

            return RedirectToAction("Details");
        }
示例#11
0
        public void Add(string title, string description, string ip, string userId)
        {
            Idea idea = new Idea();
            if (userId != null)
            {
                idea.AuthorId = userId;
            }

            idea.Title = title;
            idea.Description = description;
            idea.AuthorIP = ip;

            this.ideas.Add(idea);
            this.ideas.Save();
        }
示例#12
0
        public IdeaViewModel(Idea idea)
        {
            Id = idea.Id;
            Title = idea.Title;
            Time = idea.Time;
            Description = MarkdownHelper.Markdown(idea.Description);
            UserHasVoted = idea.UserHasVoted;
            TotalVotes = idea.Votes.Count;
            Author = idea.Author;
            GravatarUrl = (string.IsNullOrEmpty(Author.AvatarUrl)) ? Author.Email.ToGravatarUrl(40) : Author.AvatarUrl;
            Features = idea.Features.Select(f => new FeatureViewModel(f)).ToList();
            Activities = idea.Activities.Select(f => new ActivityViewModel(f)).ToList();

            Images = idea.Images.ToList();
        }
示例#13
0
文件: BoxTest.cs 项目: Zensar/IdeaBox
        public void AddIdea_Add_Items_Test()
        {
            Box target = new Box();

            Idea idea1 = new Idea();
            Idea idea2 = new Idea();
            Idea idea3 = new Idea();
            Idea idea4 = null;

            target.AddIdea(idea1);
            target.AddIdea(idea2);
            target.AddIdea(idea3);
            target.AddIdea(idea4);

            Assert.AreEqual(3, target.Ideas.Count);
        }
示例#14
0
        public IdeaViewModel(Idea idea)
        {
            Id = idea.Id;
            Title = idea.Title;
            Status = idea.Status;
            Time = idea.Time.ToFriendly();
            Description = MarkdownHelper.Markdown(idea.Description.ConvertingLinksToMarkdownUrls());
            UserHasVoted = idea.UserHasVoted;
            TotalVotes = idea.Votes.Count;
            Author = idea.Author;
            GravatarUrl = (string.IsNullOrEmpty(Author.AvatarUrl)) ? Author.Email.ToGravatarUrl(40) : Author.AvatarUrl;

            Features = idea.Features.Select(f => new FeatureViewModel(f)).ToList();

            Activities = idea.Activities.Select(f => new ActivityViewModel(f)).ToList();

            if (idea.Images != null)
            {
                Images = idea.Images.ToList();
            }
        }
示例#15
0
        public IActionResult Delete(int postId)
        {
            if (HttpContext.Session.GetInt32("UserId") == null)
            {
                return(RedirectToAction("Index"));
            }
            int  userId = HttpContext.Session.GetInt32("UserId") ?? default(int);
            Idea post   = dbContext.idea.FirstOrDefault(x => x.IdeaId == postId);

            if (post.UserId != userId)
            {
                return(RedirectToAction("Ideas"));
            }
            List <Like> delete = dbContext.like.Where(x => x.IdeaId == postId).ToList();

            foreach (var x in delete)
            {
                dbContext.like.Remove(x);
            }
            dbContext.idea.Remove(post);
            dbContext.SaveChanges();
            return(RedirectToAction("Ideas"));
        }
示例#16
0
        public void SetDetailsSource(Idea SourceIdea, VisualSymbol SourceSymbol, IList <DetailEditingCard> Source,
                                     bool IsLocal, bool AccessOnlyTables = false, DetailDesignator InitialDesignatorToEdit = null)
        {
            General.ContractRequires(SourceSymbol == null || SourceIdea == SourceSymbol.OwnerRepresentation.RepresentedIdea);

            this.SourceIdea              = SourceIdea;
            this.SourceSymbol            = SourceSymbol;
            this.DetailsSource           = Source;
            this.IsLocal                 = IsLocal;
            this.AccessOnlyTables        = AccessOnlyTables;
            this.InitialDesignatorToEdit = InitialDesignatorToEdit;

            this.SourceEngine = SourceIdea.EditEngine as CompositionEngine;

            this.DetailsListBox.ItemsSource     = Source;
            this.DetailsToolPanel.TargetListBox = this.DetailsListBox;

            // Notice that selection is made (see applied style), but focus highlight is only applied when it happens.
            if (this.DetailsSource.Count > 0)
            {
                this.DetailsListBox.SelectedIndex = 0;
            }
        }
示例#17
0
        public ActionResult <IdeaDTO> CreateIdeaItem(IdeaDTO ideacRecToCreate)
        {
            try
            {
                var rec  = new Idea();
                var user = (User)this.HttpContext.Items["User"];
                rec.Confidence   = ideacRecToCreate.confidence;
                rec.Content      = ideacRecToCreate.content;
                rec.Ease         = ideacRecToCreate.ease;
                rec.Impact       = ideacRecToCreate.ease;
                rec.CreationDate = DateTime.Now;
                rec.CreatedById  = user.Id;
                rec = _repo.Add(rec);
                _logger.LogInformation($" about to send ==>{rec.Id}");
                return(CreatedAtAction(nameof(GetIdeaItem), new { id = rec.Id }, new IdeaDTO(rec)));
            }
            catch (System.Exception ex)
            {
                _logger.LogInformation($"Buen Perro fallo==>{ex}");

                return(NotFound());
            }
        }
示例#18
0
        private string ShowForm(Idea idea)
        {
            TextBox input = new TextBox
            {
                Left      = 16,
                Top       = 45,
                Width     = 320,
                Height    = 250,
                TabIndex  = 0,
                TabStop   = true,
                Multiline = true,
                Text      = idea.Description
            };

            using (var form = new DialogForm(new FormInfo("Edit Idea", 400, 400)))
            {
                Label label = new Label()
                {
                    Left = 16, Top = 20, Width = 240, Text = "Please Enter Changes"
                };
                Button confirmation = new Button()
                {
                    Text = "Save", Left = 16, Width = 80, Top = 300, TabIndex = 1, TabStop = true
                };
                confirmation.Click += (sender, e) => { form.Close(); };
                form.Controls.Add(label);
                form.Controls.Add(confirmation);
                form.Controls.Add(input);
                //TODO build form
                form.FormBorderStyle = FormBorderStyle.FixedDialog;
                form.StartPosition   = FormStartPosition.CenterScreen;
                form.ControlBox      = false;
                form.ShowDialog();
            }

            return(input.Text);
        }
 public ActionResult DeclineIdea(Status_log statusLogParam)
 {
     using (var context = new ENSE496Entities())
     {
         Idea       idea      = context.Ideas.Where(x => x.Id == statusLogParam.Idea_id).FirstOrDefault();
         Status_log statusLog = new Status_log();
         statusLog.Current_status  = "Declined";
         statusLog.Previous_status = idea.Status;
         statusLog.Idea_id         = statusLogParam.Idea_id;
         statusLog.User_id         = Convert.ToInt32(Session["UserID"]);
         statusLog.Description     = statusLogParam.Description;
         context.Ideas.Where(x => x.Id == statusLogParam.Idea_id).FirstOrDefault().Status = "Declined";
         context.Status_log.Add(statusLog);
         if (idea.User_id != statusLog.User_id) //checks to see if status change was made by someone other than who submitted the idea
         {
             Notification notification = new Notification();
             notification.Recipient_id = idea.User_id;
             notification.Message      = Session["Username"].ToString() + " has declined your idea. (Idea #" + statusLog.Idea_id.ToString() + ")";
             notification.Active       = true;
             context.Notifications.Add(notification);
         }
         if (context.Subscriptions.Where(x => x.Idea_id == statusLog.Idea_id).Any())
         {
             var subs = context.Subscriptions.Where(x => x.Idea_id == statusLog.Idea_id).ToList();
             foreach (Subscription sub in subs)
             {
                 Notification notification = new Notification();
                 notification.Recipient_id = sub.User_id;
                 notification.Message      = Session["Username"].ToString() + " has declined an idea you are subscribed to. (Idea #" + statusLog.Idea_id.ToString() + ")";
                 notification.Active       = true;
                 context.Notifications.Add(notification);
             }
         }
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
示例#20
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "bookmarks.json");
            base.OnCreate(savedInstanceState);
            ideaTitleLbl       = FindViewById <TextView>(Resource.Id.itemTitle);
            ideaDescriptionLbl = FindViewById <TextView>(Resource.Id.itemDescription);
            detailsView        = FindViewById <LinearLayout>(Resource.Id.detailsView);
            addNoteFab         = FindViewById <FloatingActionButton>(Resource.Id.addNotefab);
            editNoteBtn        = FindViewById <Button>(Resource.Id.editNoteBtn);
            noteHolder         = FindViewById <CardView>(Resource.Id.noteHolder);
            noteContentLbl     = FindViewById <TextView>(Resource.Id.noteContent);

            addNoteFab.Click           += AddNoteFab_Click;
            SwipeListener               = new OnSwipeListener(this);
            SwipeListener.OnSwipeRight += SwipeListener_OnSwipeRight;
            SwipeListener.OnSwipeLeft  += SwipeListener_OnSwipeLeft;
            ideaDescriptionLbl.SetOnTouchListener(SwipeListener);
            detailsView.SetOnTouchListener(SwipeListener);

            editNoteBtn.Click += delegate
            {
                var dialog = new AddNoteDialog(ideasList[Global.ItemScrollPosition].Note);
                dialog.Show(FragmentManager, "ADDNOTEFRAG");
                dialog.OnNoteSave += (Note note) => HandleNoteSave(note);
            };

            bookmarkedItems = await DBAssist.DeserializeDBAsync <List <Idea> >(path);

            bookmarkedItems = bookmarkedItems ?? new List <Idea>();
            idea            = Global.Categories[Global.CategoryScrollPosition].Items[Global.ItemScrollPosition];
            ideasList       = Global.Categories[Global.CategoryScrollPosition].Items;
            notes           = await DBAssist.DeserializeDBAsync <List <Note> >(notesdb);

            notes = notes ?? new List <Note>();

            SetupUI();
        }
        public IActionResult UpdateIdea(int id, NewIdeaDto updatedValues)
        {
            try
            {
                _unitOfWorkManager.StartUnitOfWork();
                Idea updatedIdea = _ideationManager.ChangeIdea(
                    id,
                    updatedValues.Title,
                    updatedValues.IdeationId);
                _unitOfWorkManager.EndUnitOfWork();

                if (updatedIdea == null)
                {
                    return(BadRequest("Something went wrong while updating the idea."));
                }

                return(Ok(_mapper.Map <IdeaMinDto>(updatedIdea)));
            }
            catch (ValidationException ve)
            {
                return(UnprocessableEntity($"Invalid input data: {ve.ValidationResult.ErrorMessage}"));
            }
            catch (ArgumentException e)
            {
                switch (e.ParamName)
                {
                case "id":
                    return(NotFound(e.Message));

                case "ideationId":
                    return(UnprocessableEntity(e.Message));

                default:
                    return(BadRequest(e.Message));
                }
            }
        }
示例#22
0
        public IHttpActionResult PutIdea(int id, Idea idea)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != idea.Id)
            {
                return(BadRequest());
            }

            if (idea.UserId != User.Identity.GetUserId())
            {
                return(StatusCode(HttpStatusCode.Conflict));
            }

            db.Entry(idea).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IdeaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#23
0
        public async Task TestEditIdeaInvalidId()
        {
            ACMDbContext    context         = ACMDbContextInMemoryFactory.InitializeContext();
            HomeownerSevice homeownerSevice = new HomeownerSevice(context);
            ACMUser         user            = new ACMUser {
                Email = "*****@*****.**", FullName = "gosho"
            };
            Idea idea1 = new Idea {
                Id = "1", User = user, Text = "idea1"
            };
            Idea idea2 = new Idea {
                Id = "2", User = user, Text = "idea2"
            };
            await context.Users.AddAsync(user);

            await context.Ideas.AddAsync(idea1);

            await context.Ideas.AddAsync(idea2);

            await context.SaveChangesAsync();

            await Assert.ThrowsAsync <ACMException>(() => homeownerSevice
                                                    .EditIdea(idea1.Id + "Random string", user.Email, "Edited text"));
        }
示例#24
0
        public async Task <IActionResult> Post(IdeaPostResourceModel idea)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var ideaToInsert = new Idea
            {
                IdeaName                = idea.IdeaName,
                OwnerId                 = idea.OwnerId,
                Description             = idea.Description,
                SumRequired             = idea.SumRequired,
                BankAccountForTransfers = new BankAccount()
                {
                    AccountOwnerId = idea.OwnerId,
                    AccountNumber  = idea.BankAccountNumber
                },
                DateOfPublishing           = DateTime.Now,
                DeadlineForMoneyCollecting = DateTime.Parse(idea.DeadlineForMoneyCollecting),
                IsStillCollectingMoney     = true,
                CollectedTheMoney          = false,
                InnerAccountForTransfers   = new InnerMoneyAccount()
                {
                    //IdeaId = idea.Id,
                    SumTransferredToRealBankAccount = false,
                    SumAvailable = 0
                }
            };

            unitOfWork.IdeaRepository.Insert(ideaToInsert);
            await addMediaToIdeaService.AddMediaToIdea(ideaToInsert, idea.MainPhoto, idea.MainVideo, idea.Photos, idea.Videos, idea.Audios, idea.Documents);

            await unitOfWork.CompleteAsync();

            return(CreatedAtAction("Get", new { id = ideaToInsert.Id }, ideaToInsert));
        }
        public void ArchiveIdea(RestAPIArchiveIdeaResponse response, int UserID, int IdeaId, string Description, bool isArchive = false)
        {
            IdeaArchiveHistory ideaArchiveHistory = null;

            DatabaseWrapper.databaseOperation(response,
                                              (context, query) =>
            {
                Idea idea = query.GetIdeaArchive(context, IdeaId);

                if (idea != null)
                {
                    idea.IsActive      = !isArchive;
                    ideaArchiveHistory = new IdeaArchiveHistory()
                    {
                        IdeaId = IdeaId, Description = Description, UserId = UserID, ArchiveDate = DateTime.UtcNow
                    };

                    query.AddIdeaArchiveHistory(context, ideaArchiveHistory);
                    response.Status = Success;
                }
                else
                {
                    response.ErrorList.Add(Faults.IdeaNotFound);
                    response.Status = Failure;
                    return;
                }
                context.SubmitChanges();
            }
                                              , readOnly: false
                                              );

            if (response == null && response.ErrorList.Count != 0)
            {
                response.ErrorList.Add(Faults.ServerIsBusy);
            }
        }
示例#26
0
        public IActionResult Like(int id)
        {
            if (HttpContext.Session.GetInt32("UserId") == null)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                List <Liker> validLike = dbContext.likers.Where(l => (l.IdeaId == id) && (l.UserId == HttpContext.Session.GetInt32("UserId"))).ToList();


                Liker newLiker = new Liker();
                User  user     = dbContext.users.SingleOrDefault(u => u.UserId == (int)HttpContext.Session.GetInt32("UserId"));
                Idea  idea     = dbContext.ideas.SingleOrDefault(i => i.IdeaId == id);
                newLiker.Idea = idea;
                newLiker.User = user;
                dbContext.Add(newLiker);
                dbContext.SaveChanges();



                return(Redirect("/bright_ideas"));
            }
        }
示例#27
0
        public ActionResult Assign(int?id, int?schools, int?ambassadors)
        {
            if (!Request.IsAuthenticated || HttpContext.Session["userLoggedIn"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (schools != null && ambassadors != null)
            {
                Assigned_Idea assignedIdea = new Assigned_Idea();
                assignedIdea.Idea_num      = (int)id;
                assignedIdea.Ambassador_id = (int)ambassadors;
                assignedIdea.School_id     = (int)schools;
                assignedIdea.Status        = "Assigned";
                db.Assigned_Idea.Add(assignedIdea);

                //after assigned, mark the main idea as assigned.
                Idea idea = db.Ideas.Find(assignedIdea.Idea_num);
                idea.Assigned = true;

                db.SaveChanges();
                return(RedirectToAction("AssignedIdeas", "Home", new { id = id }));
            }
            return(RedirectToAction("Assign", "Home", new { id = id }));
        }
示例#28
0
        public IActionResult Add(IndexModel modelData)
        {
            Idea newIdea = modelData.NewIdea;
            User current = dbContext.Users.FirstOrDefault(u => u.UserId == int.Parse(HttpContext.Session.GetString("ID")));

            if (ModelState.IsValid)
            {
                // Idea NewIdea = new Idea();
                // NewIdea.Content = newidea.Content;
                newIdea.UserId = current.UserId;
                dbContext.Add(newIdea);
                dbContext.SaveChanges();
                return(RedirectToAction("home"));
            }
            else
            {
                ViewBag.Name = current.Name;
                ViewBag.ID   = current.UserId;

                IndexModel ideas = new IndexModel();
                ideas.Ideas = dbContext.Ideas.Include(e => e.Creator).Include(e => e.Likes).ThenInclude(u => u.User).ToList();
                return(View("Home", ideas));
            }
        }
示例#29
0
        public IActionResult NewIdea(string newidea)
        {
            Idea idea = new Idea
            {
                content   = newidea,
                Creator   = _context.Users.SingleOrDefault(u => u.UserId == (int)HttpContext.Session.GetInt32("id")),
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now,
            };

            _context.Ideas.Add(idea);
            _context.SaveChanges();
            Liked liked = new Liked
            {
                UserId    = (int)HttpContext.Session.GetInt32("id"),
                IdeaId    = idea.IdeaId,
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now
            };

            _context.Likeds.Add(liked);
            _context.SaveChanges();
            return(RedirectToAction("Dashboard"));
        }
示例#30
0
        public IActionResult Like(int IdeaId)
        {
            if (HttpContext.Session.GetInt32("UserId") == null)
            {
                return(RedirectToAction("LoginReg"));
            }
            User LoggedUser = dbContext.Users.SingleOrDefault(user => user.UserId == HttpContext.Session.GetInt32("UserId"));
            Idea ThisIdea   = dbContext.Ideas
                              .Include(idea => idea.likeThis)
                              .ThenInclude(liker => liker.User)
                              .SingleOrDefault(idea => idea.IdeaId == IdeaId);
            Like MakeLike = new Like
            {
                UserId = LoggedUser.UserId,
                User   = LoggedUser,
                IdeaId = ThisIdea.IdeaId,
                Idea   = ThisIdea
            };

            ThisIdea.likeThis.Add(MakeLike);
            dbContext.SaveChanges();

            return(RedirectToAction("Dashboard"));
        }
示例#31
0
        public IActionResult delete(int id)
        {
            int?UserId = HttpContext.Session.GetInt32("UserId");

            if (UserId == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Idea idea = _context.ideas.Where(i => i.IdeaId == id).ToList().First();

            if (idea.UserId != (int)UserId)
            {
                return(RedirectToAction("Main"));
            }
            List <Subscribtion> subscribtions = _context.subscribtions.Where(s => s.IdeaId == id).ToList();

            foreach (Subscribtion subscribtion in subscribtions)
            {
                _context.subscribtions.Remove(subscribtion);
            }
            _context.ideas.Remove(idea);
            _context.SaveChanges();
            return(RedirectToAction("Main"));
        }
 public ActionResult CreateIdea(Idea ideaParam)
 {
     using (var context = new ENSE496Entities()) {
         if (Session["UserID"] != null)
         {
             if ((String.IsNullOrEmpty(ideaParam.Title)) || (String.IsNullOrEmpty(ideaParam.Description)))
             {
                 TempData["UserMessage"] = new MessageViewModel()
                 {
                     CssClassName = "alert-danger", Message = "You have left either the title or description empty"
                 };
                 return(RedirectToAction("CreateIdea"));
             }
             else if (ideaParam.Title.Length > 255)
             {
                 TempData["UserMessage"] = new MessageViewModel()
                 {
                     CssClassName = "alert-danger", Message = "The title must be less than 256 characters"
                 };
                 return(RedirectToAction("CreateIdea"));
             }
             else
             {
                 Idea newIdea = new Idea();
                 newIdea.Title       = ideaParam.Title;
                 newIdea.Description = ideaParam.Title;
                 newIdea.User_id     = Convert.ToInt32(Session["UserID"]);
                 newIdea.Status      = "Pending";
                 context.Ideas.Add(newIdea);
                 context.SaveChanges();
                 return(RedirectToAction("Index"));
             }
         }
         return(View());
     }
 }
        public VisualRepresentation AppendShortcut(View TargetView, Idea OriginalIdea, Point Position)
        {
            VisualRepresentation Result = null;

            if (OriginalIdea is Concept)
            {
                var RefConcept = (Concept)OriginalIdea;
                Result = ConceptCreationCommand.CreateConceptVisualRepresentation(RefConcept, TargetView, Position, true, true);
            }
            else
            {
                var RefRelationship = (Relationship)OriginalIdea;
                if (RefRelationship.RelationshipDefinitor.Value.IsSimple && RefRelationship.RelationshipDefinitor.Value.HideCentralSymbolWhenSimple)
                {
                    Console.WriteLine("Shortcut omitted for simple Relationship with its Symbol hidden.");
                }
                else
                {
                    Result = RelationshipCreationCommand.CreateRelationshipVisualRepresentation(RefRelationship, TargetView, Position, true);
                }
            }

            return(Result);
        }
        public IActionResult delete(int id)
        {
            int?UserId = HttpContext.Session.GetInt32("UserId");

            if (UserId == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Idea idea = _context.Ideas.Where(i => i.IdeaId == id).ToList().First();

            if (idea.UserId != (int)UserId)
            {
                return(RedirectToAction("Main"));
            }
            List <Like> Likes = _context.Likes.Where(i => i.IdeaId == id).ToList();

            foreach (Like Like in Likes)
            {
                _context.Likes.Remove(Like);
            }
            _context.Ideas.Remove(idea);
            _context.SaveChanges();
            return(RedirectToAction("Main"));
        }
        public string getImagePath(Idea idea)
        {
            string folderName, path, fileName, hostName, AWSIdeaAttachmentFolder, portNumber;
            string Awsip, ITGIP;

            string domain = HttpContext.Current.Request.Url.Scheme;

            hostName = Environment.MachineName;

            portNumber = WebConfigurationManager.AppSettings["AWSHostPort"];

            AWSIdeaAttachmentFolder = WebConfigurationManager.AppSettings["AWSIdeaAttachmentFolder"];

            folderName = idea.IdeaAttachments.FirstOrDefault(x => x.IdeaId == idea.IdeaId && x.FolderName == (folderNames.DefaultImage.ToString())).FolderName;
            fileName   = idea.IdeaAttachments.FirstOrDefault(x => x.IdeaId == idea.IdeaId && x.FolderName == (folderNames.DefaultImage.ToString())).AttachedFileName;

            if (IsS3Enabled)
            {
                Awsip = WebConfigurationManager.AppSettings["AWSHost"];
                return(path = new Uri(string.Format(@"{0}/{1}/{2}/{3}/{4}", Awsip, AWSIdeaAttachmentFolder, idea.IdeaId, folderName, fileName)).ToString());
            }
            ITGIP = WebConfigurationManager.AppSettings["ITGIP"];
            return(path = string.Format(@"{0}://{1}:{2}/{3}/{4}/{5}/{6}", domain, ITGIP, portNumber, AWSIdeaAttachmentFolder, idea.IdeaId, folderName, fileName));
        }
示例#36
0
        public TemplateTester(Type ExpectedSourceIdeaKind, IdeaDefinition ExpectedSourceIdeaDefinition,
                              string SourceTemplateText, Composition SourceComposition,
                              Idea SourceIdea = null, bool CanSelectSource = true)
            : this()
        {
            this.ExpectedSourceIdeaKind       = ExpectedSourceIdeaKind;
            this.ExpectedSourceIdeaDefinition = ExpectedSourceIdeaDefinition;
            this.SourceTemplateText           = SourceTemplateText;
            this.SourceComposition            = SourceComposition;
            this.SourceIdea = SourceIdea;

            this.TisSourceSelector.CompositesSource           = this.SourceComposition.IntoEnumerable();
            this.TisSourceSelector.Value                      = this.SourceIdea.NullDefault(this.SourceComposition);
            this.TisSourceSelector.HideSelectNullItemActioner = true;

            if (CanSelectSource)
            {
                this.TisSourceSelector.EditingAction = (source => this.GeneratePreview(source as Idea));
            }
            else
            {
                this.TisSourceSelector.IsEnabled = false;
            }
        }
示例#37
0
        public IActionResult bright_ideas(int IdeaID)
        {
            int?LoggedInUser = HttpContext.Session.GetInt32("LoggedInUser");

            if (LoggedInUser == null)
            {
                return(Redirect("/"));
            }
            else
            {
                Idea SelectedIdea = dbContext.Ideas
                                    .Include(i => i.Creator)
                                    .Include(i => i.Users)
                                    .ThenInclude(a => a.User)
                                    .FirstOrDefault(i => i.IdeaID == IdeaID);
                ViewBag.SelectedIdea = SelectedIdea;
                ViewBag.LoggedInUser = (int)LoggedInUser;

                User LIU = dbContext.Users.FirstOrDefault(user => user.UserID == (int)LoggedInUser);
                ViewBag.LoggedInUser = LIU;

                return(View("bright_ideas"));
            }
        }
示例#38
0
        public async Task <IActionResult> Create([Bind("ID,OwnerID,Title,Description,Members,RequiredMembers," +
                                                       "FacebookContact,InstagramContact,TwitterContact,GitHubContact,EmailContact,LinkedinContact,OtherContact,AvatarImage")] Idea idea, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                var actualUserId = User.GetUserId();
                idea.OwnerID     = actualUserId;
                idea.AvatarImage = new byte[0];
                if (file != null && file.Length > 0)
                {
                    using (var memoryStream = new MemoryStream())
                    {
                        await file.CopyToAsync(memoryStream);

                        idea.AvatarImage = memoryStream.ToArray();
                    }
                }
                _context.Add(idea);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(idea));
        }
示例#39
0
        public IActionResult AddIdea(string IdeaText)
        {
            // ViewBag.SessionId = new List<string>();

            int?SessionId = HttpContext.Session.GetInt32("UserId");

            // ViewBag.SessionId = (int)SessionId;

            if (IdeaText == null)
            {
                TempData["ideaerror"] = "That's not much of an idea! Think a little harder.";
            }
            else
            {
                Idea NewIdea = new Idea {
                    UserId   = (int)SessionId,
                    IdeaText = IdeaText
                };
                _context.ideas.Add(NewIdea);
                _context.SaveChanges();
            }

            return(RedirectToAction("BrightIdeas"));
        }
        public CreateRelationDlgViewModel(IParticlesManager particlesManager, IIdeaManager ideaManager,
            IRelationManager relationManager, IBlockManager blockManager, IEventAggregator eventAggregator)
        {
            _particlesManager = particlesManager;
            _ideaManager = ideaManager;
            _relationManager = relationManager;
            _blockManager = blockManager;
            _eventAggregator = eventAggregator;
            AddParticleVm = new AddParticleViewViewModel(_particlesManager);

            SelectIdea1Command = new DelegateCommand(() =>
            {
                var dlg = new SelectTagDlg(typeof (Idea));
                var res = dlg.ShowDialog();
                if (res.HasValue && res.Value && dlg.Id.HasValue)
                {
                    _idea1 = _ideaManager.GetIdeaById(dlg.Id.Value);
                    Idea1Caption = _idea1.Caption;
                    OnPropertyChanged("Idea1Caption");
                }
                OkCommand.RaiseCanExecuteChanged();
            });

            SelectIdea2Command = new DelegateCommand(() =>
            {
                var dlg = new SelectTagDlg(typeof (Idea));
                var res = dlg.ShowDialog();
                if (res.HasValue && res.Value && dlg.Id.HasValue)
                {
                    _idea2 = _ideaManager.GetIdeaById(dlg.Id.Value);
                    Idea2Caption = _idea2.Caption;
                    OnPropertyChanged("Idea2Caption");
                }
                OkCommand.RaiseCanExecuteChanged();
            });

            AddRelationTypeCommand = new DelegateCommand<RoutedEventArgs>(e =>
            {
                var text = ((ButtonEdit) e.Source).Text;
                var rt = _relationManager.AddRelationType(text);
                var relationDto = new RelationTypeDto() {Id = rt.Id, Name = text};
                Relations.Add(relationDto);
                Relation = relationDto;
            });

            OkCommand = new DelegateCommand<Window>(wnd =>
            {
                var relation = _relationManager.CreateRelation(Relation.Id, _idea1.Id, _idea2.Id);

                if (AddParticleVm.AddParticle)
                    if (AddParticleVm.UseNewParticle)
                    {
                        var particle = _particlesManager.CreateParticle(AddParticleVm.NewParticle.Material,
                            AddParticleVm.NewParticle.Begin, AddParticleVm.NewParticle.End);
                        _blockManager.AddParticleToBlock(relation, particle);
                    }
                    else if (AddParticleVm.UseExistParticle && AddParticleVm.ExistParticle.HasValue)
                    {
                        var particle = _particlesManager.GetParticleById(AddParticleVm.ExistParticle.Value);
                        _blockManager.AddParticleToBlock(relation, particle);
                    }

                _eventAggregator.GetEvent<BlockAddedEvent>().Publish(relation.Id);
                wnd.DialogResult = true;
                wnd.Close();
            }, wnd => Relation != null && _idea1 != null && _idea2 != null);

            Relations =
                new ObservableCollection<RelationTypeDto>(
                    _relationManager.GetRelationTypes()
                        .Select(rt => new RelationTypeDto() {Id = rt.Id, Name = rt.Caption}));
        }
示例#41
0
        public IActionResult Edit(Idea idea)
        {
            if (ModelState.IsValid)
            {
                _context.Attach(idea);

                _context.Entry(idea).Property(_ => _.Name).IsModified = true;
                _context.Entry(idea).Property(_ => _.Description).IsModified = true;

                _context.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewData["UserId"] = new SelectList(_context.Users, "Id", "Author", idea.UserId);
            return View(idea);
        }
示例#42
0
        public void Idea_ValidStringConstructorTest()
        {
            int count = new Random().Next(1, 20);

            for (int i = 0; i < count; i++)
            {
                string guid = Guid.NewGuid().ToString();
                Idea idea = new Idea(guid);
                Assert.IsInstanceOfType(idea, typeof(Idea));
                Assert.IsNotNull(idea);
            }
        }
        private void NavTree_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            this.PreviousPointingPosition = default(Point);
            Idea PointedIdea = null;

            if (e.OriginalSource is FrameworkElement)
            {
                var SourceItem = Display.GetNearestVisualDominantOfType <TreeViewItem>(e.OriginalSource as FrameworkElement);

                if (SourceItem != null)
                {
                    var PointedView = SourceItem.Header as View;

                    if (PointedView == null)
                    {
                        PointedIdea = SourceItem.Header as Idea;
                    }
                    else
                    if (PointedView == this.CurrentView)
                    {
                        CompositionEngine.EditViewProperties(PointedView);
                        return;
                    }
                }
            }

            if (PointedIdea != null && PointedIdea == this.TargetIdea)
            {
                // Is clicking for jump...
                this.IsNavigating = true;

                var PointingShortcut = (this.CurrentView.Manipulator.CurrentTargetedObject is VisualElement &&
                                        ((VisualElement)this.CurrentView.Manipulator.CurrentTargetedObject).OwnerRepresentation.IsShortcut &&
                                        ((VisualElement)this.CurrentView.Manipulator.CurrentTargetedObject).OwnerRepresentation.RepresentedIdea == TargetIdea);

                if (PointingShortcut)
                {
                    ApplicationProduct.ProductDirector.EditorInterrelationsControl.SetTarget(TargetIdea);
                    // Do not "jump", it could interfere with resizing/moving of shortcut symbols
                }
                else
                if (TargetIdea.OwnerContainer != null)
                {
                    if (TargetIdea.OwnerContainer.CompositeActiveView == this.CurrentView &&
                        this.WorkspaceDirector.ActiveDocument.ActiveDocumentView == this.CurrentView)
                    {
                        var SelectableSymbols = this.CurrentView.ViewChildren
                                                .Where(child => child.Key is VisualSymbol &&
                                                       ((VisualSymbol)child.Key).OwnerRepresentation
                                                       .RepresentedIdea == TargetIdea)
                                                .Select(child => (VisualSymbol)child.Key);

                        if (SelectableSymbols.Any() && !SelectableSymbols.Any(symb => symb.OwnerRepresentation.RepresentedIdea.IsSelected))
                        {
                            this.CurrentView.Manipulator.ApplySelection(SelectableSymbols.First(), false,
                                                                        (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)));
                        }

                        ApplicationProduct.ProductDirector.EditorInterrelationsControl.SetTarget(TargetIdea);
                        this.CurrentView.Presenter.BringIntoView(
                            TargetIdea.VisualRepresentators.First(vrep => vrep.DisplayingView == this.CurrentView).MainSymbol.BaseArea);
                    }
                    else
                    {
                        var Representator = TargetIdea.MainRepresentator;

                        if (Representator != null && !CompositionEngine.IsSelectingByRectangle
                            /*- && this.IsMouseOver && Mouse.LeftButton == MouseButtonState.Pressed*/)
                        {
                            Representator.DisplayingView.Engine.ShowView(Representator.DisplayingView);

                            Representator.DisplayingView.Presenter.PostCall(
                                vpres =>
                            {
                                vpres.OwnerView.Manipulator.ApplySelection(Representator.MainSymbol);
                                vpres.OwnerView.Presenter.BringIntoView(Representator.MainSymbol.BaseArea);
                            });
                        }
                    }
                }

                this.TargetIdea   = null;
                this.IsNavigating = false;
            }
        }
示例#44
0
 /// <summary>
 /// Unegisters the supplied Idea as undeclared from this Composition.
 /// </summary>
 public void UnregisterIdea(Idea Idea)
 {
     this.RegisteredIdeas.Remove(Idea);
 }
示例#45
0
 public void Create(Idea idea)
 {
     this.Add(idea);
 }
示例#46
0
 public void Add(Idea newIdea)
 {
     this.ideas.Add(newIdea);
 }
示例#47
0
 public void IdTest()
 {
     Guid id = Guid.NewGuid();
     Idea target = new Idea(id);
     Guid actual;
     actual = target.Id;
     Assert.IsTrue(id.Equals(target.Id));
 }
示例#48
0
        public void IsSameIdentityTest()
        {
            Guid id1 = Guid.NewGuid();
            Idea target1 = new Idea(id1);
            Idea target2 = null;
            bool expected1 = false;
            bool actual1;
            actual1 = target1.IsSameIdentity(target2);
            Assert.AreEqual(expected1, actual1);

            Guid id2 = Guid.NewGuid();
            Idea target3 = new Idea(id2);
            Idea target4 = new Idea(id2);
            bool expected2 = true;
            bool actual2;
            actual2 = target3.IsSameIdentity(target4);
            Assert.AreEqual(expected2, actual2);

            Guid id3 = Guid.NewGuid();
            Guid id4 = Guid.NewGuid();
            Idea target5 = new Idea(id3);
            Idea target6 = new Idea(id4);
            bool expected3 = false;
            bool actual3;
            actual3 = target5.IsSameIdentity(target6);
            Assert.AreEqual(expected3, actual3);
        }
示例#49
0
        public void Idea_initial_insight_should_be_setted_in_the_property()
        {
            var idea = new Idea("create tests");

            Assert.AreEqual("create tests", idea.Insight);
        }
示例#50
0
 public void CreateIdea(Idea idea)
 {
     throw new NotImplementedException();
 }
示例#51
0
 // ---------------------------------------------------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Registers the supplied Idea as declared on this Composition.
 /// </summary>
 public void RegisterIdea(Idea Idea)
 {
     this.RegisteredIdeas.AddNew(Idea);
 }
示例#52
0
 public void AddTagToIdea(Idea idea, Tag tag)
 {
     idea.Tags.Add(tag);
     _dbInterop.SaveChanges();
 }
示例#53
0
 public void DeleteIdea(Idea idea)
 {
     using (IBusinessProvider provider = base.CreateBusinessProvider())
         using (IIdeaBusinessProvider prov = provider.CreateIdeaBusinessProvider())
             prov.DeleteIdea(idea);
 }
示例#54
0
 public void Update(Idea idea)
 {
     throw new NotImplementedException();
 }
示例#55
0
 public async Task Create(Idea idea)
 {
     _context.Add(idea);
     await _context.SaveChangesAsync();
 }
示例#56
0
 public static void RegisterIdea(Idea idea)
 {
     idea.token_Id = _ideaGenesis.Count;
     _ideaGenesis.Add (idea.token_Id, idea);
 }