Ejemplo n.º 1
0
 partial void DeleteCartIntegration(CartIntegration instance);
Ejemplo n.º 2
0
 partial void InsertCartIntegration(CartIntegration instance);
Ejemplo n.º 3
0
 partial void UpdateCartIntegration(CartIntegration instance);
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
 public void SetCustomerPart(int customerID = 0, string key = "", int partID = 0, int customerPartID = 0)
 {
     try {
         CartIntegration integration = new CartIntegration {
             custID = customerID,
             custPartID = customerPartID,
             partID = partID
         };
         Response.ContentType = "application/json";
         Response.Write(JsonConvert.SerializeObject(integration.Set(key)));
         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();
     }
 }
Ejemplo n.º 6
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();
     }
 }
Ejemplo n.º 7
0
 public void GetUnintegratedParts(int customerID = 0, string dataType = "", string callback = "")
 {
     // Validate the customerID
     if (customerID == 0) {
         Response.ContentType = "application/json";
         Response.Write("You must provide your customer ID");
         Response.End();
     } else {
         CartIntegration integration = new CartIntegration {
             custID = customerID
         };
         if (dataType.ToUpper() == "JSON" || dataType.ToUpper() == "JSONP") { // Display JSON
             string gridJSON = integration.GetUnintegratedPartsJSON();
             if (dataType.ToUpper() == "JSONP") {
                 Response.ContentType = "application/x-javascript";
                 Response.Write(callback + "(" + gridJSON + ")");
             } else {
                 Response.ContentType = "application/json";
                 Response.Write(gridJSON);
             }
             Response.End();
         } else { // Display XML
             Response.ContentType = "text/xml";
             Response.Write(integration.GetUnintegratedPartsXML());
             Response.End();
         }
     }
 }
Ejemplo n.º 8
0
        public CartIntegration Set(string key)
        {
            Authenticate(key);
            CurtDevDataContext db = new CurtDevDataContext();

            // Validate required fields

            // This isn't working because the customer needs to be able to unlink
            // if (this.custPartID == 0) { throw new Exception("Customer Part ID failed to validate against null or zero."); }
            //  - ajn
            if (this.partID == 0) { throw new Exception("Part Number failed to validate against null or zero."); }

            // Attempt to get a CustomerPricing record for this customerID and partID
            List<CartIntegration> tmpIntegrations = db.CartIntegrations.Where(x => x.custID.Equals(this.custID) && x.partID.Equals(this.partID)).ToList<CartIntegration>();
            CartIntegration newintegration = new CartIntegration();
            List<CartIntegration> deleteables = new List<CartIntegration>();
            bool updated = false;
            foreach (CartIntegration tmpIntegration in tmpIntegrations) {
                if (tmpIntegration.custPartID == 0) {
                    deleteables.Add(tmpIntegration);
                } else {
                    if (!updated && this.custPartID > 0) {
                        tmpIntegration.custPartID = this.custPartID;
                        updated = true;
                    } else {
                        deleteables.Add(tmpIntegration);
                    }
                }
            }
            if (!updated && this.custPartID > 0) {
                newintegration = this;
                newintegration.custID = this.custID;
                db.CartIntegrations.InsertOnSubmit(newintegration);
            }
            if (deleteables.Count > 0) {
                db.CartIntegrations.DeleteAllOnSubmit(deleteables);
            }
            db.SubmitChanges();

            CartIntegration cartIntegration = new CartIntegration {
                custID = this.custID,
                partID = newintegration.partID,
                custPartID = newintegration.custPartID,
                referenceID = newintegration.referenceID
            };
            return cartIntegration;
        }