Пример #1
0
        public IDataShell <AccountDBModel> Insert(AccountDBModel user)
        {
            var res = _userDAL.Insert(user);

            return(res);
        }
Пример #2
0
        //public DataShell<IEnumerable<UserAccount>> GetList(UserAccount user)
        //{
        //    var res = ReqResTransShell<UserAccount, UserAccountDBModel, IEnumerable<UserAccountDBModel>, IEnumerable<UserAccount>>(user, (rq) => _userDAL.GetList(rq));
        //    return res;
        //}


        #region --注册和创建--
        /// <summary>
        /// 插入新 用户帐号
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public IDataShell <AccountModel> Insert(AccountModel user)
        {
            user.CoreID = "";

            #region --数据验证--
            Dictionary <string, Func <bool> > check = new Dictionary <string, Func <bool> >()
            {
                ["帐号,手机号,电子邮件不可同时为空"] = () => user.Account.NullEmpty() && user.Email.NullEmpty() && user.Mobile.NullEmpty(),
                ["帐号格式不合法"]           = () => user.Account.NotNullEmpty() && user.Account.LegalAccount().IsFalse(),
                ["无密码"] = () => user.Password.NullEmpty(),
            };
            var verifyRes = check.Checker();
            if (verifyRes.haveerror)
            {
                return(verifyRes.info.Fail <AccountModel>());
            }
            #endregion
            user.Password   = user.Password.ToKeccak224();
            user.RegistTime = DateTime.Now;
            user.CreateTime = DateTime.Now;
            user.EditTime   = DateTime.Now;
            user.Status     = Core.Enum.AccountStatus.RegistVerify;
            // 如果用户名昵称为空用 帐号手机或者邮箱填充
            if (user.UserName.NullEmpty() && user.Account.NotNullEmpty())
            {
                user.UserName = user.Account;
            }
            if (user.UserName.NullEmpty() && user.Mobile.NotNullEmpty())
            {
                user.UserName = user.Mobile.Replace(2, 9, "*");
            }
            if (user.UserName.NullEmpty() && user.Email.NotNullEmpty())
            {
                user.UserName = user.Email.Replace(user.Email.BetweenSinceStr("@", "."), "****");
            }

            var res = ReqResTransShell <AccountModel, AccountDBModel, AccountDBModel, AccountModel>(user, (d) => _userDAL.Insert(d));
            return(res);
        }