public ActionResult Index() { List <Eventos> eventos = new List <Eventos>(); for (int i = 0; i < 5; i++) { var evento = new Eventos(); evento.nombre = "User" + i; evento.descripcion = "Economía Nacional"; evento.fechaInico = new DateTime(2016, 11, 30); evento.fechaClausura = new DateTime(2016, 11, 30); var idea = new Ideas(); idea.agregarLike("20093278"); idea.agregarLike("20093918"); idea.agregarLike("20086787"); idea.agregarLike("20096787"); evento.ideas.Add(idea); eventos.Add(evento); } if (eventos == null) { return(HttpNotFound()); } // ideas.Count(); ViewBag.Eventos = eventos; return(View(eventos)); }
static void Main(string[] args) { Ideas i = new Ideas(); Ideas.triggerMany(); Console.ReadLine(); }
// GET api/<controller> public IEnumerable <Ideas.Idea> Get() { var returnIdeas = new List <Ideas.Idea>(); var ideas = Ideas.Get(); var votes = Votes.Get(); foreach (var idea in ideas) { var hasVoted = false; foreach (var vote in votes) { if (vote.IdeaId == idea.Id && vote.CreatedBy == "M104203") //User.Identity.Name.Replace("MYL\\", "")) { hasVoted = true; break; } } if (!hasVoted) { returnIdeas.Add(idea); } } returnIdeas.Sort((x, y) => DateTime.Compare(x.Created, y.Created)); return(returnIdeas); }
[HttpPost("Home/createNewAct")]////////////////////////////////// creating new avtivity public IActionResult IdeaDetails(Ideas ide) { string Email = HttpContext.Session.GetString("Email"); User logUser = _context.users.SingleOrDefault(usr => usr.Email == Email); if (!ModelState.IsValid) { List <Ideas> allIdeas = _context.ideas.Include(a => a.Likes).OrderByDescending(a => a.NumOfLikes).ToList(); List <User> allUsers = _context.users.Include(u => u.Likes).ToList(); ViewBag.allUsers = allUsers; ViewBag.user = logUser; ViewBag.allActs = allIdeas; return(View("Dashboard")); } ide.UserId = logUser.UserId; logUser.Ideas.Add(ide); _context.SaveChanges(); Ideas idea = _context.ideas.Include(a => a.Likes).FirstOrDefault(a => a.LikesId == ide.LikesId); ViewBag.user = logUser; ViewBag.idea = idea; return(RedirectToAction("Dashboard")); // return RedirectToAction("ViewActDetails",new {act.ActivitiesId}); }
void WriteToc() { bool first = true; foreach (var s in Program.Sections) { List <Idea> areaIdeas; if (!Ideas.TryGetValue(s.Key, out areaIdeas)) { continue; } if (first) { first = false; } else { WriteLine(""); } WriteLine($"**[{s.Title}](#{Linkify (s.Title)})**"); WriteLine(""); WriteLine(s.Description.TrimEnd()); WriteLine(""); foreach (var idea in areaIdeas) { WriteLine($"* [{idea.Title}](#{Linkify (idea.Title)})"); } } }
async Task MakeFavoriteItem(Ideas item) { item.IsFavorite = !item.IsFavorite; await _manager.UpdateIdeaAsync(item); Ideas.ItemsSource = await _manager.GetTodoItemsAsync(); }
public IActionResult bright_ideas(int IdeaId) { if (isLoggedIn()) { setSessionViewData(); Ideas idea = _context.ideas.Include(l => l.Likes).ThenInclude(u => u.LikedUser).Include(c => c.IdeaCreator).SingleOrDefault(i => i.IdeaId == IdeaId); if (idea != null) { if (idea.Likes != null) { idea.Likes = idea.Likes.GroupBy(a => a.LikedUser.Alias).Select(g => g.First()).ToList(); } return(View("like_status", idea)); } else { return(View("bright_ideas", new IdeaBundleModel(_context))); } } else { return(RedirectToAction(_action, _controller)); } }
public IActionResult Delete(int id) { Ideas toDelete = _context.ideas.SingleOrDefault(item => item.ideasId == id); _context.ideas.Remove(toDelete); _context.SaveChanges(); return(RedirectToAction("List")); }
[HttpGet("Home/Delete/{id}")] ////////////////////// deleting event public IActionResult Delete(int id) { Ideas ide = _context.ideas.FirstOrDefault(a => a.IdeasId == id); _context.Remove(ide); _context.SaveChanges(); return(RedirectToAction("Dashboard")); }
public IActionResult delete(int id) { Ideas toremove = _context.ideas.SingleOrDefault(detail => detail.ideasid == id); _context.ideas.Remove(toremove); _context.SaveChanges(); // Other code return(RedirectToAction("activity", "idea")); }
private async Task LoadIdeas() { var r = await DataService.GetIdeas(); foreach (var idea in r.ideas) { Ideas.Add(idea); } }
public EditPage(Ideas idea) { InitializeComponent(); _manager = IdeaManager.DefaultManager; _idea = idea; newIdeaName.Text = idea.Name; newIdeaDescription.Text = idea.Description; BindingContext = new EditPageViewModel(idea); }
// GET api/<controller>/5 public Ideas.Idea Get(string id) { foreach (var idea in Ideas.Get()) { if (idea.Id.Equals(id, System.StringComparison.InvariantCultureIgnoreCase)) { return(idea); } } return(null); }
public IActionResult AddIdea(IdeaViewModel incoming) { if (ModelState.IsValid) { Ideas newIdea = new Ideas(); newIdea.usersId = (int)HttpContext.Session.GetInt32("currentUserId"); newIdea.creator = _context.users.FirstOrDefault(item => item.usersId == HttpContext.Session.GetInt32("currentUserId")); newIdea.text = incoming.text; _context.Add(newIdea); _context.SaveChanges(); } return(RedirectToAction("List")); }
public void InsertChild(int index, IdeaNote idea) { if (idea.RootSaveFile != null) { idea.RootSaveFile.Ideas.Remove(idea); idea.RootSaveFile = null; } if (idea.Parent != null) { idea.Parent.Ideas.Remove(idea); } idea.Parent = this; Ideas.Insert(index, idea); }
public Ideas CreateIdea(Ideas idea) { if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { context.tbl_ideas.Add(idea); context.SaveChanges(); } return(idea); }
public void AddIdea(IdeaNote idea) { if (idea.RootSaveFile != null) { idea.RootSaveFile.Ideas.Remove(idea); } if (idea.Parent != null) { idea.Parent.Ideas.Remove(idea); idea.Parent = null; } idea.RootSaveFile = this; Ideas.Add(idea); }
// GET: Ideas public ActionResult Ideas() { var idea = new Ideas(); idea.fld_id = 1; idea.fld_title = "Faster work idea"; idea.fld_description = "I have come up with this amazing idea to work better, faster, and longer without any cost for the company"; idea.fld_effortScale = 1; idea.fld_impactScale = 5; idea.fld_employeeNo = 521452; return(View(idea)); }
public Ideas EnsureIdeas(string title) { var ideas = this.ideass.All().FirstOrDefault(x => x.Title == title); if (ideas != null) { return(ideas); } ideas = new Ideas { Title = title }; this.ideass.Add(ideas); this.ideass.Save(); return(ideas); }
public void AddChild(IdeaNote idea) { if (idea == this) { throw new Exception("Cannot add an IdeaNote as its own child."); } if (idea.RootSaveFile != null) { idea.RootSaveFile.Ideas.Remove(idea); idea.RootSaveFile = null; } if (idea.Parent != null) { idea.Parent.Ideas.Remove(idea); } idea.Parent = this; Ideas.Add(idea); }
// POST api/<controller> public void Post([FromBody] Ideas.Idea request) { if (string.IsNullOrEmpty(request.Name)) { return; } if (string.IsNullOrEmpty(request.CreatedBy)) { request.CreatedBy = "M104203"; } var foundUser = Utils.FindAccountByType("(samAccountName={0})", request.CreatedBy); if (foundUser != null) { request.CreatedByName = foundUser.Properties["displayName"][0].ToString(); } Ideas.Save(request); }
public ActionResult Index() { List <Ideas> ideas = new List <Ideas>(); for (int i = 0; i < 5; i++) { var idea = new Ideas(); idea.autor = "User" + i; idea.problema = "Problema" + i; idea.titulo = "Titulo" + i; idea.solucion = "Solucion" + i; ideas.Add(idea); } if (ideas == null) { return(HttpNotFound()); } // ideas.Count(); ViewBag.Ideas = ideas; return(View(ideas)); }
public IActionResult CreateIdea(Ideas idea) { if (isLoggedIn()) { setSessionViewData(); if (ModelState.IsValid) { User user = _context.users.Include(j => j.Likes).ThenInclude(p => p.LikedIdea).SingleOrDefault(u => u.UserId == (int)ViewData["UserId"]); idea.IdeaCreator = user; _context.ideas.Add(idea); _context.SaveChanges(); } } else { return(RedirectToAction(_action, _controller)); } return(View("bright_ideas", new IdeaBundleModel(_context))); }
public IActionResult details(int id) { int?userid = HttpContext.Session.GetInt32("userId"); if (userid != null) { Ideas Details = _context.ideas.Include(user => user.author).Include(attending => attending.liked).ThenInclude(user => user.User).SingleOrDefault(detail => detail.ideasid == id); ViewBag.Details = Details; // List<Liked> error = new List<object>(); List <Liked> AllLikes = _context.liked.Where(like => like.ideasid == id).Include(user => user.User).ToList(); var groupedlikes = from Liked in AllLikes group Liked by Liked.User into g select g; ViewBag.AllLikes = groupedlikes; // List<Liked> AllLikes = new List<Liked>(); // AllLikes = _context.liked.GroupBy(likes=>likes.userid).ToList(); // Other code ViewBag.User = (int)userid; return(View("details")); } return(RedirectToAction("index", "login")); }
public IActionResult create(IdeasValidate idea1) { int?id = HttpContext.Session.GetInt32("userId"); if (TryValidateModel(idea1)) { Ideas nw = new Ideas { idea = idea1.idea, userid = (int)id, }; _context.Add(nw); _context.SaveChanges(); TempData["id"] = nw.ideasid; return(RedirectToAction("activity")); } else { ViewBag.errors = ModelState.Values; return(View("activity")); } }
public IActionResult usersLikes(int id) { Ideas idea = _context.ideas.Include(i => i.Likes).SingleOrDefault(i => i.IdeasId == id); List <User> likedUsers = new List <User>(); List <Likes> postLikes = _context.likes.Include(l => l.User).Include(l => l.Ideas).Where(l => l.IdeasId == idea.IdeasId).ToList(); foreach (var u in postLikes) { if (!likedUsers.Contains(u.User)) { likedUsers.Add(u.User); } } User creator = _context.users.SingleOrDefault(u => u.UserId == idea.UserId); ViewBag.creator = creator; ViewBag.idea = idea; ViewBag.likedUsers = likedUsers; return(View("UsersLikes")); }
[HttpGet("Home/join/{id}")] ////////////////// joining Event public IActionResult join(int id) { string Email = HttpContext.Session.GetString("Email"); User logUser = _context.users.Include(u => u.Ideas).SingleOrDefault(usr => usr.Email == Email); Ideas idea = _context.ideas.Include(i => i.Likes).SingleOrDefault(i => i.IdeasId == id); Likes like = new Likes() { User = logUser, Ideas = idea }; idea.NumOfLikes++; logUser.Likes.Add(like); idea.Likes.Add(like); _context.Add(like); _context.SaveChanges(); return(RedirectToAction("Dashboard")); }
public ActionResult Create(IdeasInputModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var ideas = new Ideas() { Description = model.Description, Title = model.Title }; if (this.User.Identity.IsAuthenticated) { ideas.AuthorIP = this.User.Identity.GetUserId(); } this.ideas.Add(ideas); this.ideas.Save(); this.TempData["Notification"] = "Thank you for your idea!"; return(this.Redirect("/")); }
public IActionResult Delete(int IdeaId) { if (isLoggedIn()) { setSessionViewData(); Ideas idea = _context.ideas.SingleOrDefault(u => u.IdeaId == IdeaId); if (idea != null) { if (idea.IdeaCreatorId == (int)ViewData["UserId"]) { _context.ideas.Remove(idea); _context.SaveChanges(); } } return(View("bright_ideas", new IdeaBundleModel(_context))); } else { return(RedirectToAction(_action, _controller)); } }
public Idea GetIdeaById(int id) { return(Ideas.Single(i => i.Id == id)); }