Example #1
0
 /// <summary>
 /// 使用指定的编码对象对 URL 字符串进行编码。
 /// </summary>
 /// <param name="text">指定的字符串</param>
 /// <param name="encoding">指定编码默认为Default</param>
 /// <returns>转码后字符串</returns>
 public static string UrlEncode(string text, Encoding encoding = null)
 {
     return(HttpUrlHelper.UrlEncode(text, encoding));
 }
Example #2
0
 public static NameValueCollection GetNameValueCollection(string str)
 {
     return(HttpUrlHelper.GetNameValueCollection(str));
 }
Example #3
0
 public static string GetUrlIp(string url)
 {
     return(HttpUrlHelper.GetUrlIp(url));
 }
 protected static string ConstructQuery(IReadOnlyList <StringKeyValuePair> parameters) =>
 HttpUrlHelper.ToQueryString(parameters);
Example #5
0
 protected Task <DepartureSearchResult> GetDepartureSearch(
     IEnumerable <StringKeyValuePair> queryParams,
     CancellationToken cancelToken = default) =>
 GetDepartureSearch(HttpUrlHelper.ToQueryString(queryParams), cancelToken);
Example #6
0
        public void LogIn(UserParam userParam)
        {
            try
            {
                var userInfo = UserInfo.Instance;
                userInfo.Mobile          = userParam.Mobile;
                userInfo.Password        = userParam.Password;
                userInfo.IsAuthenticated = true;
                var passengerParam = new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <PassengerParam>(HttpUrlHelper.Get(AppConstant.RestUrl, "Passenger", "GetByMobile", userParam.Mobile));

                userParam.Language = string.IsNullOrEmpty(userParam.Language) ? userInfo.Language : userParam.Language;

                passengerParam.UserParam.IsAuthenticated = true;
                passengerParam.UserParam.Language        = userParam.Language;
                passengerParam.UserParam.Password        = userParam.Password;
                userParam.Id = passengerParam.UserParam.Id;
                userParam.IsAuthenticated = true;


                var users = _userRepository.GetAll();
                foreach (var user in users)
                {
                    user.IsAuthenticated = false;
                    _userRepository.Update(user);
                }


                var currentUser = users.FirstOrDefault(c => c.Mobile == userParam.Mobile);
                if (currentUser == null)
                {
                    var userInsert = new User()
                    {
                        Id = userParam.Id,
                        IsAuthenticated = true,
                        Password        = userParam.Password,
                        Language        = userParam.Language,
                        Mobile          = userParam.Mobile
                    };
                    _userRepository.Insert(userInsert);
                }
                else
                {
                    currentUser.IsAuthenticated = true;
                    _userRepository.Update(currentUser);
                }



                MapToUserInfo(passengerParam);
            }
            catch (Exception e)
            {
                UserInfo.Instance.IsAuthenticated = false;
                throw new Exception(e.Message);
            }
        }
        TripCostParam ITripCostService.GetTripCost(TripLocationParam tripLocationParam)
        {
            var result = new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <TripCostParam>(HttpUrlHelper.Get(AppConstant.RestUrl, "TripCost", "GetTripCost"), tripLocationParam);

            return(result);
        }
Example #8
0
 public void UpdateUserCode(UserParam userParam)
 {
     new  HttpClientHelper(UserInfoMapping.MapToUserInfo()).Post(HttpUrlHelper.Post(AppConstant.RestUrl, "Account", "UpdateUserCode"), userParam);
 }
Example #9
0
        public UserParam GetUserCode(string mobile)
        {
            if (mobile == null)
            {
                mobile = UserInfo.Instance.Mobile;
            }
            var userParam = new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <UserParam>(HttpUrlHelper.Get(AppConstant.RestUrl, "Account", "GetByMobile", mobile));

            return(userParam);
        }
Example #10
0
        public TripParam GetById(Guid id)
        {
            var userParam = new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <TripParam>(HttpUrlHelper.Get(AppConstant.RestUrl, "Trip", "GetById", id.ToString()));

            return(userParam);
        }
Example #11
0
 public TripParam GetTripDetailsByTripId(Guid id)
 {
     try
     {
         return(new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <TripParam>(HttpUrlHelper.Get(AppConstant.RestUrl, "Trip", "GetTripDetailsByTripId", id.ToString())));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Example #12
0
 public List <TripParam> GetTripByMobile(string mobile)
 {
     try
     {
         return(new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <List <TripParam> >(HttpUrlHelper.Get(AppConstant.RestUrl, "Trip", "GetTripUserByMobile", mobile)));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
Example #13
0
        public List <TripParam> GetNewRequest()
        {
            var tripParam = new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <List <TripParam> >(HttpUrlHelper.Get(AppConstant.RestUrl, "Trip", "GetNewRequest"));

            return(tripParam);
        }
 public void Delete(Guid id)
 {
     try
     {
         new HttpClientHelper(UserInfoMapping.MapToUserInfo()).Get <SelectedAddressParam>(HttpUrlHelper.Get(AppConstant.RestUrl, "SelectedAddress", "Delete", id.ToString()));
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }