Esempio n. 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Komment komment = db.Komments.Find(id);

            db.Komments.Remove(komment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include = "Body,AccountId")] Komment komment)
        {
            komment.Created   = DateTime.UtcNow.AddHours(8);
            komment.AccountId = ((Account)Session["Account"]).AccountId;
            if (ModelState.IsValid)
            {
                db.Komments.Add(komment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.AccountId = new SelectList(db.Accounts, "AccountId", "Name", komment.AccountId);
            return(View(komment));
        }
Esempio n. 3
0
        // GET: Komments/Details/5
        public ActionResult Details(int?id)
        {
            Komment nowAccount = db.Komments.Find(id);

            if (nowAccount == null || ((Account)Session["Account"]).AccountId != nowAccount.AccountId)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Komment komment = db.Komments.Find(id);

            if (komment == null)
            {
                return(HttpNotFound());
            }
            return(View(komment));
        }
Esempio n. 4
0
        // GET: Komments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Komment nowAccount = db.Komments.Find(id);

            if (nowAccount == null || ((Account)Session["Account"]).AccountId != nowAccount.AccountId)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Komment komment = db.Komments.Find(id);

            if (komment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AccountId = new SelectList(db.Accounts, "AccountId", "Name", komment.AccountId);
            return(View(komment));
        }