Exemplo n.º 1
0
        public ActionResult Addnotice(FormCollection fc, noticetable n1)
        {
            //if (ModelState.IsValid)
            //{
            noticetable n = new noticetable();

            n.author = (string)Session["userid"];
            n.title  = fc["title"];
            string k = fc["kind"];

            if (k == "")
            {
                n.kind = "all";
            }
            else
            {
                n.kind = k;
            }
            n.content    = fc["content"];
            n.isApproved = 0;
            n.submitTime = DateTime.Now;
            n.id         = Convert.ToInt32((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds);
            db.noticetable.Add(n);
            db.SaveChanges();
            return(RedirectToAction("Index"));
            //}
            //else
            //{
            //    return RedirectToAction("Addnotice");
            //}
        }
Exemplo n.º 2
0
        public ActionResult noticemodified(FormCollection fc, noticetable n1)
        {
            var n = db.noticetable.Find(n1.id);
            //UpdateModel(n);
            string title = fc["title"], content = fc["content"], kind = fc["kind"];

            n.title = title; n.content = content; string k = kind;
            if (k == "")
            {
                n.kind = "all";
            }
            else
            {
                n.kind = k;
            }
            db.SaveChanges();
            db.SaveChanges();
            return(RedirectToAction("noticeMag"));
        }
Exemplo n.º 3
0
        public ActionResult Modified(noticetable n, FormCollection fc)
        {
            var n1 = db.noticetable.Find(n.id);
            //UpdateModel(n);
            string title = fc["title"], content = fc["content"], kind = fc["kind"];

            n1.title = title; n1.content = content;
            string k = kind;

            if (k == "")
            {
                n.kind = "all";
            }
            else
            {
                n.kind = k;
            }
            //db.Entry(n).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }