Пример #1
0
        public ActionResult Index([Bind(Include = "ID,Message,Yes,No,UserID")] MugonMessage mugonMessage, string YesNoButton)
        {
            if (YesNoButton == "Yes")
            {
                if (User.Identity.GetUserId() == null)
                {
                    return(RedirectToAction("Yes"));//null);
                }

                mugonMessage.Yes++;
                db.Entry(mugonMessage).State = EntityState.Modified;
                db.SaveChanges();
                TempData["YesNoCount"] = mugonMessage.Yes;
                return(RedirectToAction("Yes")); //Yes();//mugonMessage.Yes);
            }
            else if (YesNoButton == "No")
            {
                if (User.Identity.GetUserId() == null)
                {
                    return(RedirectToAction("No"));;
                }

                mugonMessage.No++;
                db.Entry(mugonMessage).State = EntityState.Modified;
                db.SaveChanges();
                TempData["YesNoCount"] = mugonMessage.No;
                return(RedirectToAction("No"));
            }

            return(Index());
        }
Пример #2
0
        // POST: MugonMessages/Edit/5
        // 過多ポスティング攻撃を防止するには、バインド先とする特定のプロパティを有効にしてください。
        // 詳細については、http://go.microsoft.com/fwlink/?LinkId=317598 を参照してください。
        public ActionResult SetMessage2([Bind(Include = "ID,Message,Yes,No,UserID")] MugonMessage mugonMessage, bool YesNoClear = false)
        {
            //System.Diagnostics.Trace.WriteLine(mugonMessage.UserID);
            if (ModelState.IsValid)
            {
                var mugonMessages = db.MugonMessages.Where(x => x.UserID == User.Identity.Name);

                if (mugonMessages.Count() == 0)
                {
                    mugonMessage.UserID = User.Identity.Name;
                    db.MugonMessages.Add(mugonMessage);
                }
                else
                {
                    if (YesNoClear == true)
                    {
                        mugonMessage.Yes = 0;
                        mugonMessage.No  = 0;
                    }
                    db.Entry(mugonMessage).State = EntityState.Modified;
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            MugonMessage mugonMessage = db.MugonMessages.Find(id);

            db.MugonMessages.Remove(mugonMessage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "ID,Message,Yes,No,UserID")] MugonMessage mugonMessage)
 {
     if (ModelState.IsValid)
     {
         db.Entry(mugonMessage).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(mugonMessage));
 }
Пример #5
0
        public ActionResult Create([Bind(Include = "ID,Message,Yes,No,UserID")] MugonMessage mugonMessage)
        {
            if (ModelState.IsValid)
            {
                db.MugonMessages.Add(mugonMessage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mugonMessage));
        }
Пример #6
0
        // GET: MugonMessages/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MugonMessage mugonMessage = db.MugonMessages.Find(id);

            if (mugonMessage == null)
            {
                return(HttpNotFound());
            }
            return(View(mugonMessage));
        }