Пример #1
0
        public ActionResult Index(RegisterModel model)
        {
            var    id   = Session["userAccounts"];
            Users  list = conn.Users.FirstOrDefault(a => a.Accounts == id);
            string ss;

            ss = "P" + System.DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + Path.GetExtension(Request.Files["file"].FileName);



            Users user = (from a in conn.Users
                          where a.Accounts == id
                          select a).Single();

            user.Nickname = model.Nickname;
            user.UserLogo = img(ss);
            conn.Entry <Users>(user).State = System.Data.EntityState.Modified;
            conn.SaveChanges();
            return(Content("<script>alert('修改成功');history.go(-1)</script>"));
        }
Пример #2
0
        public ActionResult aNotice(aWrite write, int noticeID)
        {
            var    id   = noticeID;
            NOTICE list = conn.NOTICE.FirstOrDefault(a => a.N_ID == id);
            string ss;

            ss = "N" + System.DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + Path.GetExtension(Request.Files["file"].FileName);

            NOTICE notice = (from a in conn.NOTICE
                             where a.N_ID == id
                             select a).Single();

            notice.N_Title    = write.N_Title;
            notice.N_CONTENTS = write.N_CONTENTS;
            notice.N_PICTURE  = img(ss, id);
            conn.Entry <NOTICE>(notice).State = System.Data.EntityState.Modified;
            conn.SaveChanges();
            return(Content("<script>alert('修改成功');history.go(-1)</script>"));
        }
Пример #3
0
        public ActionResult boardMod([System.Web.Http.FromBody] boardManager model, int id)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    BOARD aa = conn.BOARD.First(r => r.B_NAME == model.B_NAME);
                    return(Content("<script>alert('有重复的名字');history.go(-1)</script>"));
                }
                catch (Exception ex)
                {
                    BOARD board = (from a in conn.BOARD
                                   where a.B_ID == id
                                   select a).Single();
                    board.B_NAME     = model.B_NAME;
                    board.B_CONTENTS = model.B_CONTENTS;
                    conn.Entry <BOARD>(board).State = System.Data.EntityState.Modified;
                    conn.SaveChanges();

                    return(Content("<script>alert('修改成功');history.go(-1)</script>"));
                }
            }
            return(View());
        }