public ActionResult Create([Bind(Include = "ArticleID, Id, Text")] ArticleKoment articleKoment)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    articleKoment.SendDate = DateTime.Now;
                    articleKoment.Profile  = db.Profiles
                                             .Where(p => p.UserName == User.Identity.Name).FirstOrDefault();
                    articleKoment.Article = db.Articles
                                            .Where(a => a.Id == articleKoment.ArticleID).FirstOrDefault();

                    db.ArticleKoments.Add(articleKoment);
                    db.SaveChanges();
                    int id         = articleKoment.ArticleID;
                    var routeValue = new RouteValueDictionary
                                         (new { action = "Details", controller = "Article", id });
                    return(RedirectToRoute(routeValue));
                }
            }
            catch (DataException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            var routeValue2 = new RouteValueDictionary
                                  (new { action = "Details", controller = "Article", id = articleKoment.ArticleID });

            return(RedirectToRoute(routeValue2));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ArticleKoment articleKoment = db.ArticleKoments.Find(id);

            db.ArticleKoments.Remove(articleKoment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,ArticleID,Text,SendDate")] ArticleKoment articleKoment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(articleKoment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ArticleID = new SelectList(db.Articles, "Id", "Title", articleKoment.ArticleID);
     return(View(articleKoment));
 }
        // GET: ArticleKoment/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleKoment articleKoment = db.ArticleKoments.Find(id);

            if (articleKoment == null)
            {
                return(HttpNotFound());
            }
            return(View(articleKoment));
        }
        // GET: ArticleKoment/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleKoment articleKoment = db.ArticleKoments.Find(id);

            if (articleKoment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ArticleID = new SelectList(db.Articles, "Id", "Title", articleKoment.ArticleID);
            return(View(articleKoment));
        }