コード例 #1
0
        public IActionResult Add(AdministratorAddModel model)
        {
            var oldAdmin = AdministratorDal.FindByAccounts(model.Accounts);

            if (oldAdmin != null)
            {
                return(Json("该登录账号已经占用"));
            }

            try
            {
                CryptoHelper helper = new CryptoHelper();

                var p = new AdministratorDefinition()
                {
                    AdministratorId = Guid.NewGuid().ToString("N"),
                    SysAdmin        = false,
                    Name            = model.Name,
                    PassWord        = helper.Encrypt(model.PassWord.Trim()),
                    Phone           = model.Phone,
                    Accounts        = model.Accounts.ToLower(),
                    ReWritePassWord = true,
                    RoleId          = model.RoleId,
                };
                AdministratorDal.Add(p);
                return(Json(1));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }
コード例 #2
0
 public int Login(Administrator t)
 {
     return(adal.Add(t));
 }