Exemplo n.º 1
0
        public UnifyApiResult Add(OperatorModel model)
        {
            if (model == null)
            {
                return(UnifyApiResult.Error("参数不能为空。"));
            }
            if (string.IsNullOrEmpty(model.LoginName))
            {
                return(UnifyApiResult.Error("用户名不能为空。"));
            }
            if (string.IsNullOrEmpty(model.Password))
            {
                return(UnifyApiResult.Error("密码不能为空。"));
            }

            OperatorDAL dal = new OperatorDAL();

            if (dal.GetData(model.LoginName) == null)
            {
                return(UnifyApiResult.Error("用户名不允许重复。"));
            }

            model.Password = EncryptionHelper.UserMd5(model.Password);
            dynamic result = dal.Insert(model);

            return(UnifyApiResult.Sucess(result));
        }