public ActionResult Create([Bind(Include = "ID,Title,Body,Date")] Suggestion suggestion)
        {
            if (ModelState.IsValid)
            {
                GroupView groupview = new GroupView();
                string userid = User.Identity.GetUserId();
                var currentuser = db.Users.SingleOrDefault(u => u.Id == userid);
                int group = (int)Session["id"];
                var currentgroup = db.Groups.FirstOrDefault(s => s.ID == group);

                suggestion.User = currentuser;
                suggestion.Group = currentgroup;

                suggestion.Date = DateTime.Now;

                db.Suggestions.Add(suggestion);
                db.SaveChanges();
                return RedirectToAction("Index", "Group");
            }

            return View(suggestion);
        }
Beispiel #2
0
        // GET: Group/Details/5
        public ActionResult Details(int? id)
        {
            GroupView groupview = new GroupView();
            //var groupview = new GroupView();

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Group group = db.Groups.Find(id);

            groupview.Group = group;

            if (groupview.Group == null)
            {
                return HttpNotFound();
            }

            groupview.Suggestions = db.Suggestions.ToList();
            //groupview.Tutorials = db.Tutorials.ToList();

            //if (id != null)
            //{
            //    ViewBag.ID = id.Value;
            //    groupview.SubCategories = viewModel.Categories.FirstOrDefault(c => c.ID == id).SubCategory;
            //}

            //if (subcatID != null)
            //{
            //    ViewBag.SubCategoryID = subcatID.Value;
            //    viewModel.Posts = db.Posts.Include(p => p.FilesPost).Where(x => x.SubCategoryID == subcatID);
            //}
            Session["id"] = id;

            return View(groupview);
        }