public AuthenticateResponse AuthenticateUser(string Username, string Password)
        {
            AuthenticateResponse authResponse = new AuthenticateResponse();

            try
            {
                AuthenticateCL auth = new AuthenticateCL();
                auth.ClientId  = apiClientId;
                auth.EndUserIp = IPAddress;
                auth.UserName  = Username;
                auth.Password  = Password;
                var    jsonStringObject = JsonConvert.SerializeObject(auth);
                String Qualifiedurl     = Baseurl + "SharedServices/SharedData.svc/rest/Authenticate";
                var    result           = APIHotel.Instance().GetResponse(Qualifiedurl, Verbs.POST, jsonStringObject);
                if (result != null)
                {
                    authResponse = JsonConvert.DeserializeObject <AuthenticateResponse>(result);
                }
                return(authResponse);
            }
            catch (Exception ex)
            {
                authResponse.Error.ErrorMessage = ex.Message;
                return(authResponse);
            }
        }
예제 #2
0
        public string Login()
        {
            string LoginResult = string.Empty;

            try
            {
                AuthenticateCL auth = new AuthenticateCL();
                auth.ClientId  = ConfigurationManager.AppSettings["ClientId"].ToString();
                auth.EndUserIp = ConfigurationManager.AppSettings["EndUserIp"].ToString();
                auth.UserName  = ConfigurationManager.AppSettings["UserName"].ToString();
                auth.Password  = ConfigurationManager.AppSettings["Password"].ToString();
                var    jsonStringObject = JsonConvert.SerializeObject(auth);
                String Qualifiedurl     = Baseurl + "SharedServices/SharedData.svc/rest/Authenticate";
                var    result           = HotelOperation.Instance().GetResponse(Qualifiedurl, Verbs.POST, jsonStringObject);
                if (result != null)
                {
                    AuthenticateResponse authResponse = new AuthenticateResponse();
                    authResponse = JsonConvert.DeserializeObject <AuthenticateResponse>(result);
                    if (authResponse.Error != null)
                    {
                        if (authResponse.Error.ErrorCode > 0)
                        {
                            HttpContext.Current.Session["ErrorMsg"] = authResponse.Error.ErrorMessage;
                            LoginResult = authResponse.Error.ErrorMessage;
                        }
                        else
                        {
                            HttpContext.Current.Session["Token"]    = authResponse.TokenId.ToString();
                            HttpContext.Current.Session["AgencyId"] = authResponse.Member.AgencyId.ToString();
                            HttpContext.Current.Session["MemberId"] = authResponse.Member.MemberId.ToString();
                        }
                    }
                    else
                    {
                        LoginResult = "Sucess";
                    }
                }
            }
            catch
            {
                LoginResult = "Failed";
            }
            return(LoginResult);
        }