Exemplo n.º 1
0
        public async Task <JsonResult> PlaceOrder(PlaceOrderRequestModelLocal userObj)
        {
            PlaceOrderResponseModel responseContent = null;

            try
            {
                userObj.OrderPlacedById = User.Identity.GetUserId();
                userObj.FromWeb         = true;
                using (HttpClient client = new HttpClient())
                {
                    string actionPath = "order/place";
                    client.BaseAddress = baseApiUrl;
                    client.DefaultRequestHeaders.Authorization = AuthHandler.AuthenticationHeader();
                    HttpResponseMessage response = await client.PostAsJsonAsync(actionPath, userObj);

                    if (response.IsSuccessStatusCode)
                    {
                        responseContent = await response.Content.ReadAsAsync <PlaceOrderResponseModel>();
                    }
                }
                System.Web.HttpContext.Current.Session["ConfirmedOrderSerialNo"] = responseContent.SerialNo;
            }
            catch (Exception e)
            {
                //log ex here
                //throw;
            }



            return(Json(responseContent));
        }
Exemplo n.º 2
0
        public async Task <JsonResult> FetchDeliveryChargesAndTime(PlaceOrderRequestModelLocal userObj)
        {
            DeliveryChargesResponseModel responseContent = null;

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    string actionPath = "order/estimatedDeliveryCharges";
                    client.BaseAddress = baseApiUrl;
                    client.DefaultRequestHeaders.Authorization = AuthHandler.AuthenticationHeader();

                    //validate the userobj before sending it fruther to prevent sql injections and stuff

                    //here

                    HttpResponseMessage response = await client.PostAsJsonAsync(actionPath, userObj);

                    if (response.IsSuccessStatusCode)
                    {
                        responseContent = await response.Content.ReadAsAsync <DeliveryChargesResponseModel>();
                    }
                }
            }
            catch (Exception e)
            {
                //log ex here
                //throw;
            }



            return(Json(responseContent));
        }