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(); } }
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(); } }
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(); } }