Esempio n. 1
0
        public ActionResult Register(string name, string password)
        {
            if (string.IsNullOrEmpty(name) || name.Length > 16 || name.Length < 3)
            {
                return(Content("账号密码错误!"));
            }
            if (string.IsNullOrEmpty(password) || password.Length > 16 || password.Length < 6)
            {
                return(Content("账号密码错误!"));
            }
            var user = dal.GetModel(name);

            if (user != null)
            {
                ModelState.AddModelError("name", name + "账号已存在");
                return(View());
            }

            var model = new Models.User();

            model.ID         = dal.GetMaxId() + 1;
            model.name       = name;
            model.password   = password;
            model.Modifytime = DateTime.Now;
            model.AddTime    = DateTime.Now;
            model.status     = 1;
            var isSuccess = dal.Add(model);

            if (isSuccess)
            {
                return(Redirect("/"));
            }
            else
            {
                return(Content("注册失败"));
            }
        }
 /// <summary>
 /// 执行新增操作
 /// </summary>
 /// <param name="model">实体对象</param>
 /// <param name="newID">返回新记录的主键值</param>
 /// <returns></returns>
 public bool Add(MODEL.User model, out int newID)
 {
     return(dal.Add(model, out newID) > 0);
 }
Esempio n. 3
0
 /// <summary>
 /// 添加一个用户
 /// </summary>
 public void Add(EasyLife.Model.User model)
 {
     dal.Add(model);
 }
Esempio n. 4
0
        /*
         * public void UsingTransaction()
         * {
         *  using(var scope = dal.GetTransactionScope())
         *  {
         *      //TODO.....dal.method1();dal.method2();dal1.method();
         *      scope.Complete();
         *  }
         *
         * }
         */

        public Model.User Add(Model.User mUser)
        {
            return(dal.Add(mUser));
        }
Esempio n. 5
0
 public int Add(Model.User model)
 {
     DAL.User userDal = new DAL.User();
     return(userDal.Add(model));
     //记录日志
 }