示例#1
0
        public static string GetError(string errorcode)
        {
            string errMessage =
                "<div align=\'center\' class=\'FormTable\' style=\'padding-top: 10px;color:red; font-weight:400; font-size:16px; text-align:center; line-height:20px;\' id=\'status\' runat=\'server\'>\r\n" +
                "<strong>Thank you for your interest in Our Products.</strong><br />\r\n    </div>\r\n    <div align=\'center\' style=\'font-weight:300; font-size:14px; text-align:center; line-height:20px;\'>\r\n\t\t!_errorMessage_!\r\n</div>";

            string default_message =
                "Due to technical difficulties, we are not able to process your order.<br />\r\nPlease call us at the number below to place an order via phone.<br />\r\n" +
                "Thank you again for your interest and understanding. Phone: <a href=\'https://www.earlymoments.com/Customer-Care/\'>\r\n1-800-353-3140</a>";
            object result = null;

            try
            {
                if (!string.IsNullOrEmpty(errorcode))
                {
                    if (Convert.ToInt32(errorcode) > 0)
                    {
                        string serviceUrl = System.Configuration.ConfigurationManager.AppSettings["iservice"].ToString();
                        serviceUrl += "errorMessage?ErrorCode=" + errorcode + "&format=json";
                        connectIServices connectIServices = new connectIServices();
                        string obj = connectIServices.returnJson(serviceUrl);
                        var yourOjbect = new JavaScriptSerializer().DeserializeObject(obj);
                        List<object> resultList = new List<object>();
                        Dictionary<string, object> dictStr = new Dictionary<string, object>();
                        dictStr = (Dictionary<string, object>)yourOjbect;

                        //var errorcd = dictStr.Where(b => b.Key == "ErrorCode").Select(b => b.Value).FirstOrDefault();
                        result = dictStr.Where(b => b.Key == "Message").Select(b => b.Value).FirstOrDefault();
                    }
                }

                if (Convert.ToInt32(errorcode) <= 0)
                {
                    result = default_message;
                }
            }
            catch (Exception)
            {
                result = default_message;
            }
            return errMessage.Replace("!_errorMessage_!", result != null ? Convert.ToString(result) : "");
        }
        private static bool addUpsellToCart(string orderId, string campaignId, string offerId, string upsellId)
        {
            string serviceUrl = System.Configuration.ConfigurationManager.AppSettings["iservice"].ToString();
            serviceUrl += "addItemToOrder/?token=741889E3-4565-40A1-982A-F15F7A923D72&PromotionId=" + campaignId + "&OrderId=" + orderId + "&UpsellId=" + upsellId + "&OfferCodes=" + offerId + "&format=json";
            connectIServices connectIServices = new connectIServices();
            try
            {
                string obj = connectIServices.returnJson(serviceUrl);
                var yourOjbect = new JavaScriptSerializer().DeserializeObject(obj);
                List<object> offerList = new List<object>();

                List<object> resultList = new List<object>();
                Dictionary<string, object> dictStr = new Dictionary<string, object>();
                dictStr = (Dictionary<string, object>)yourOjbect;
                var result = dictStr.Where(b => b.Key == "response").Select(b => b.Value).ToList();

                System.Collections.Generic.Dictionary<string, object> book = new Dictionary<string, object>();
                book = (System.Collections.Generic.Dictionary<string, object>)result.FirstOrDefault();
                var O_bookDesc = book.Where(b => b.Key == "processed").Select(b => b.Value).FirstOrDefault();
                if (yourOjbect != null && result != null)
                {
                    if (O_bookDesc != null)
                        return Convert.ToBoolean(O_bookDesc);
                }
                return false;
            }
            catch
            {
                return false;
            }
        }
        public ActionResult OrderDetails()
        {
            var oComm = new CommonModels();
            OrderVariables oVariables = new OrderVariables();
            try
            {
                if (Session["NewOrderDetails"] != null)
                {

                    oVariables = Session["NewOrderDetails"] as OrderVariables;
                    string serviceUrl = ConfigurationManager.AppSettings["iservice"].ToString();
                    if (oVariables != null)
                    {
                        BindCartDetails();
                        serviceUrl += "getupselloffers/?token=741889E3-4565-40A1-982A-F15F7A923D72&UpsellId=" + oVariables.upsellId.ToString() + "&PromotionId=" + oVariables.campaign_id + "&format=json";
                        //serviceUrl += "getupselloffers/?token=741889E3-4565-40A1-982A-F15F7A923D72&UpsellId=19790613&PromotionId=12469&format=json";
                        connectIServices connectIServices = new connectIServices();

                        string obj = connectIServices.returnJson(serviceUrl);
                        var yourOjbect = new JavaScriptSerializer().DeserializeObject(obj);
                        List<object> offerList = new List<object>();
                        object[] O_bookList;

                        int i = 0;
                        foreach (var item1 in (Dictionary<string, object>)yourOjbect)
                        {
                            i++;
                            var item2 = item1.Value;
                            if (i < 2)
                            {
                                O_bookList = (object[])item2;
                                offerList = O_bookList.ToList();
                            }
                        }

                        BindOfferDetails(offerList);
                        AssignValuestoViewBag(1);
                        ViewBag.BillZipCode = oVariables.bill_to_zipcode;

                    }
                }
            }
            catch (Exception ex)
            {
                oComm.SendEmail("Upsell Page 1 deals <br />Exception Raised from Upsell Page 1 deals. Exception: " + ex.Message.ToString() + ".<br />More Data (Offer URL): "
                    + oVariables.referring_url + ". <br />More Data (Order Id):" + oVariables.order_id);
            }
            return View();
        }