Exemplo n.º 1
0
        public T Get <T>(string requestUrl, Dictionary <string, string> headers = null)
            where T : class
        {
            T   f;
            var strResponse = string.Empty;
            HttpResponseMessage response = null;

            using (var client = new HttpClient())
            {
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                if (headers != null)
                {
                    foreach (var header in headers)
                    {
                        client.DefaultRequestHeaders.Add(header.Key, header.Value);
                    }
                }

                response    = client.GetAsync(requestUrl).Result;
                strResponse = response.Content.ReadAsStringAsync().Result;
                f           = SerializationServices.DeserializeJson <T>(strResponse);
            }

            return(f);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var _httpHelper = new HttpHelper();

            var url         = $"{appConfig.apiBaseUrl}/api/client?companyid=1";
            var strResponse = _httpHelper.GetString(url);
            var oClientList = SerializationServices.DeserializeJson <List <ClientVM> >(strResponse);

            gdvClientList.DataSource = oClientList;
            gdvClientList.DataBind();
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            currentUser = (StaffVM)Session["CurrentUser"];
            var _httpHelper = new HttpHelper();

            var url         = $"{appConfig.apiBaseUrl}/api/case?companyid={currentUser.CompanyId}";
            var strResponse = _httpHelper.GetString(url);
            var oCaseList   = SerializationServices.DeserializeJson <List <CaseVM> >(strResponse);

            gdvCasesList.DataSource = oCaseList;
            gdvCasesList.DataBind();
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CurrentUser = (StaffVM)Session["CurrentUser"];
            }
            ;

            var url     = $"{appConfig.apiBaseUrl}/api/staff";
            var headers = new Dictionary <string, string>();

            headers.Add("companyId", CurrentUser.CompanyId.ToString());

            var strResponse = _httpHelper.GetString(url);
            var oStaffList  = SerializationServices.DeserializeJson <List <StaffVM> >(strResponse);

            gdvClientList.DataSource = oStaffList;
            gdvClientList.DataBind();
        }
Exemplo n.º 5
0
        private StaffVM AuthenticateUser(string emailaddress, string password)
        {
            StaffVM oStaffObj   = null;
            var     _httpHelper = new HttpHelper();
            string  url         = $"{appConfig.apiBaseUrl}/api/staff/authenticate";

            var headers = new Dictionary <string, string>();

            headers.Add("emailaddress", emailaddress);
            headers.Add("password", password);

            var httpResponse = _httpHelper.Get(url, headers);

            if (httpResponse.IsSuccessStatusCode)
            {
                var strResponse = httpResponse.Content.ReadAsStringAsync().Result;
                oStaffObj = SerializationServices.DeserializeJson <StaffVM>(strResponse);
            }
            return(oStaffObj);
        }