Example #1
0
        public void SetCustomerPartAndPrice(int customerID = 0, string key = "", int partID = 0,  int customerPartID = 0, decimal price = 0, int isSale = 0, string sale_start = "", string sale_end = "")
        {
            try {
                CartIntegration integration = new CartIntegration {
                    custID = customerID,
                    custPartID = customerPartID,
                    partID = partID
                };
                CartIntegration newintegration = integration.Set(key);
                CustomerPricing pricing = new CustomerPricing {
                    cust_id = customerID,
                    partID = partID,
                    price = price,
                    isSale = isSale,
                    sale_start = (sale_start.Length > 0) ? Convert.ToDateTime(sale_start) : (DateTime?)null,
                    sale_end = (sale_end.Length > 0) ? Convert.ToDateTime(sale_end) : (DateTime?)null
                };
                SimplePricing newpricing = pricing.Set(key);
                List<object> results = new List<object>();
                results.Add(newintegration);
                results.Add(newpricing);

                Response.ContentType = "application/json";
                Response.Write(JsonConvert.SerializeObject(results));
                Response.End();
            } catch (Exception e) {
                //Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                //Response.StatusDescription = e.Message;
                Response.ContentType = "application/json";
                Response.Write(JsonConvert.SerializeObject(e.Message, Formatting.Indented));
                Response.End();
            }
        }
Example #2
0
        public void SetPrice(string key = "")
        {
            try {
                int customerID = Convert.ToInt32(Request.Form["customerID"]);
                int partID = Convert.ToInt32(Request.Form["partID"]);
                decimal price = Convert.ToDecimal(Request.Form["price"]);
                int isSale = (Request.Form["isSale"] != null && Request.Form["isSale"] != "") ? Convert.ToInt32(Request.Form["isSale"]) : 0;
                string sale_start = (Request.Form["sale_start"] != null) ? Request.Form["sale_start"].Trim() : "";
                string sale_end = (Request.Form["sale_end"] != null) ? Request.Form["sale_end"].Trim() : "";

                CustomerPricing pricing = new CustomerPricing{
                    cust_id = customerID,
                    partID = partID,
                    price = price,
                    isSale = isSale,
                    sale_start = (sale_start.Length > 0) ? Convert.ToDateTime(sale_start) : (DateTime?)null,
                    sale_end = (sale_end.Length > 0) ? Convert.ToDateTime(sale_end) : (DateTime?)null
                };

                SimplePricing simpleprice = pricing.Set(key);

                Response.ContentType = "application/json";
                Response.Write(JsonConvert.SerializeObject(simpleprice));
                Response.End();
            } catch (Exception e) {
                //Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                //Response.StatusDescription = e.Message;
                Response.ContentType = "application/json";
                Response.Write(JsonConvert.SerializeObject(e.Message + " " + e.StackTrace,Formatting.Indented));
                Response.End();
            }
        }
Example #3
0
 public void PriceUpload(string key = "", int customerID = 0)
 {
     try {
         if (key == "") {
             throw new Exception("Key is missing and is required");
         }
         if (customerID == 0) {
             throw new Exception("Customer ID is missing and is required");
         }
         StreamReader reader = new StreamReader(Request.InputStream);
         string pricedata = reader.ReadToEnd();
         List<string> rows = pricedata.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).ToList();
         Parallel.ForEach(rows, currentRow => {
             try {
                 List<string> fields = currentRow.Split(',').ToList();
                 int partID = Convert.ToInt32(fields[0]);
                 int CustomerPartID = (fields[1].Trim() != "") ? Convert.ToInt32(fields[1]) : 0;
                 decimal price = (fields[2].Trim() != "") ? Convert.ToDecimal(fields[2]) : 0;
                 string sale_start = fields[3].Trim();
                 string sale_end = fields[4].Trim();
                 int isSale = (sale_start != "") ? 1 : 0;
                 CustomerPricing pricing = new CustomerPricing {
                     cust_id = customerID,
                     partID = partID,
                     price = price,
                     isSale = isSale,
                     sale_start = (sale_start.Length > 0) ? Convert.ToDateTime(sale_start) : (DateTime?)null,
                     sale_end = (sale_end.Length > 0) ? Convert.ToDateTime(sale_end) : (DateTime?)null
                 };
                 try {
                     pricing.Set(key);
                 } catch { }
                 CartIntegration integration = new CartIntegration {
                     custID = customerID,
                     custPartID = CustomerPartID,
                     partID = partID
                 };
                 try {
                     integration.Set(key);
                 } catch { }
             } catch {}
         });
         Response.ContentType = "application/json";
         Response.Write(JsonConvert.SerializeObject("uploading", Formatting.Indented));
         Response.End();
     } catch (Exception e) {
         Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
         Response.StatusDescription = e.Message;
         Response.ContentType = "application/json";
         Response.Write(JsonConvert.SerializeObject(e.Message, Formatting.Indented));
         Response.End();
     }
 }