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));
 }