Exemple #1
0
        public IHttpActionResult Put(Infrastructure.ViewModel.Login.LoginRequest requestData)
        {
            var requestService = new Service.Utility.RequestDataHelper <Infrastructure.ViewModel.Login.LoginRequest>();
            var checkColumnKey = new string[2] {
                "account", "pushtoken"
            };
            var checkEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKey);
            var response   = new Infrastructure.ViewModel.Base.BaseResponse <string>();

            if (checkEmpty == false)
            {
                response.Success = false;
                response.Message = "遺漏參數";
                response.State   = Infrastructure.ViewModel.Base.LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var tokenService = new TokenService();
            var responseMsg  = tokenService.UpdateMemberPushToken(requestData.Account, requestData.PushToken);

            if (responseMsg == false)
            {
                response.Success = false;
                response.Message = "修改失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }

            response.Success = true;
            response.Message = "修改成功";

            return(Ok(response));
        }
        /// <summary>
        /// 驗證使用者登入
        /// </summary>
        /// <returns></returns>
        public IHttpActionResult Post(Infrastructure.ViewModel.Login.LoginRequest requestData)
        {
            var content = new ResultBaseModel <Infrastructure.ViewModel.Login.LoginResponse>();

            try
            {
                var service = new LoginService();
                //    var requestData = JsonConvert.DeserializeObject<Infrastructure.ViewModel.Login.LoginRequest>(strAccess);
                requestData.PhoneID = requestData.PhoneID.Replace("-", "").ToLower();

                var result = service.LoginProxy(requestData);

                if (result != null)
                {
                    content.Success = true;
                    content.Data    = new Infrastructure.ViewModel.Login.LoginResponse[1] {
                        result
                    };
                    content.Message = "登入成功";
                    content.State   = LogState.Suscess;
                    return(Ok(content));
                }
                else
                {
                    content.Success = false;
                    content.Data    = new Infrastructure.ViewModel.Login.LoginResponse[0];
                    content.Message = "登入失敗";
                    content.State   = LogState.NoAccount;
                    return(Ok(content));
                }
            }
            catch (Exception ex)
            {
                content.Success = false;
                content.Data    = new Infrastructure.ViewModel.Login.LoginResponse[0];
                content.Message = ex.Message;
                content.State   = LogState.Error;
                return(Content(HttpStatusCode.Forbidden, content));
            }
        }