Ejemplo n.º 1
0
        public async Task <string> LoginAsync(LoginModel model)
        {
            BaseResult result = new BaseResult();

            #region 判断验证码
            if (!ValidateCaptchaCode(model.CaptchaCode))
            {
                result.ResultCode = ResultCodeAddMsgKeys.SignInCaptchaCodeErrorCode;
                result.ResultMsg  = ResultCodeAddMsgKeys.SignInCaptchaCodeErrorMsg;
                return(result.ObjectToJson());
            }
            #endregion
            if (model == null || string.IsNullOrEmpty(model?.UserName))
            {
                result.ResultCode = ResultCodeAddMsgKeys.CommonModelStateInvalidCode;
                result.ResultMsg  = "wrong username";
                return(result.ObjectToJson());
            }

            try
            {
                var manager = await _managerService.LoginAsync(model);

                return(manager.ObjectToJson());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }