public ActionResult Edit(Models.User acc)
 {
     //加上 using System.Data.Entity;
     db.Entry(acc).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("MyIndexList", "Goods"));
 }
        public ActionResult Create(SysUser sysUser)
        {
            db.SysUsers.Add(sysUser);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Example #3
0
 public ActionResult Register(Models.Account acc)
 {
     if (ModelState.IsValid)            //执行服务端的验证
     {
         db.Accounts.Add(acc);          //增加数据
         db.SaveChanges();              //保存
     }
     return(RedirectToAction("Index")); //跳转
 }
        public ActionResult EditState(int?id, int?state)
        {
            Models.Goods art    = db.Goodss.Find(id);
            int          state1 = state ?? 0;

            art.State           = state1;
            db.Entry(art).State = EntityState.Modified;
            db.SaveChanges();
            return(Content("ok"));
        }
 public ActionResult Detail(int?id)
 {
     Models.Article art = db.Articles.Find(id);
     if (art != null)
     {
         art.clickCount      = art.clickCount + 1; //修改点击率
         art.lastClickTime   = DateTime.Now;       //修改点击时间
         db.Entry(art).State = EntityState.Modified;
         db.SaveChanges();                         //保存修改
     }
     return(View(art));
 }
 [Filter.IsPostFromThisSite] //验证是否本机提交
 public ActionResult Add(Models.Want model)
 {
     model.ClickNum  = 0;
     model.CreatDate = DateTime.Now;
     model.State     = 0;
     if (Session["UserID"] == null)
     {
         model.UserID = 1;
     }
     else
     {
         model.UserID = int.Parse(Session["UserID"].ToString());//获取作者id
     }
     if (ModelState.IsValid)
     {
         db.Wants.Add(model); //增加
         db.SaveChanges();    //保y
         return(RedirectToAction("Index"));
     }
     else
     {
         ModelState.AddModelError("Error", "添加失败,请重填");//
         return(View());
     }
 }
Example #7
0
 public ActionResult Add(int?Goodsid, string content)
 {
     Models.Tran model = new Models.Tran();
     model.Content    = content;
     model.CreateDate = DateTime.Now;
     model.GoodsID    = Goodsid;
     model.Star       = 5;
     model.State      = 1;
     model.UserID     = 1;//匿名
     if (Session["UserID"] != null)
     {
         model.UserID = int.Parse(Session["UserID"].ToString());
     }
     try
     {
         db.Trans.Add(model); //增加数据
         db.SaveChanges();    //保存
     }
     catch (Exception aa)
     {
         string sss = aa.Message;
     }
     return(Content("ok"));
 }
Example #8
0
       // [ValidateAntiForgeryToken]
        public  ActionResult Register(RegisterViewModel model)
        {
           AccountContext acContext=new DAL.AccountContext();
            if (ModelState.IsValid)
            {
               // var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
               // var result = await UserManager.CreateAsync(user, model.Password);
                //if (result.Succeeded)
                //{
                //   // await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
                acContext.Users.Add(new DAL.User { Email = model.Email, Password = model.Password });
                acContext.SaveChanges();
                  
                    return RedirectToAction("Index", "Home");
               // }
           
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return View(model);
        }