public ActionResult Search_COA(string coa, string dash_used) { if (dash_used != "on") { string temp_new_coa = coa.Insert(5, "-"); temp_new_coa = temp_new_coa.Insert(9, "-"); temp_new_coa = temp_new_coa.Insert(13, "-"); coa = temp_new_coa; } var newentry = new coas_history(); var modify = (from m in db.coas where m.COA_ID == coa select m); foreach (var m in modify) { newentry.COA_ID = m.COA_ID; newentry.License_Type = m.License_Type; newentry.location = m.location; newentry.PDF_language = m.PDF_language; newentry.PK = m.PK; newentry.Pre_existing_COA_ID = m.Pre_existing_COA_ID; newentry.Product_Name = m.Product_Name; newentry.Recipient_City = m.Recipient_City; newentry.Recipient_Country___Region = m.Recipient_Country___Region; newentry.Recipient_Organization_Name = m.Recipient_Organization_Name; newentry.Recipient_Type = m.Recipient_Type; newentry.Request_ID = m.Request_ID; newentry.row_id = m.row_id; } //modify.Recipient_Type = "USED"; // System.Data.Entity.EntityState.Modified; db.coas_history.Add(newentry); // db.Entry(modify).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); coas deleteme = db.coas.Where(u => u.COA_ID.Equals(coa)).FirstOrDefault(); if (deleteme != null) { db.coas.Remove(deleteme); db.SaveChanges(); } db.Dispose(); ModelState.Clear(); return(RedirectToAction("admin")); }
public JsonResult ts_ship_stock(string[] asset) { string message = ""; //format the tsg sku to the ss format // channel = channel.Replace("TSG_", "HW-"); for (int i = 0; i < asset.Length; i++) { try { string temp_asset = asset[i]; var db = new db_a094d4_icdbEntities1(); var update_asset = db.ts_stock.Where(s => s.ictag == temp_asset).First(); update_asset.status = "Shipped"; db.SaveChanges(); message += "<p style='color:green'>" + asset[i] + " Sucessfully Marked as Shipped</p>"; } catch (Exception e) { message += "<p style='color:red'>" + asset[i] + e.InnerException.InnerException.Message + "</p>"; } } db.Dispose(); return(Json(message, JsonRequestBehavior.AllowGet)); }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
public JsonResult create_dymo(int asset, string model, string cpu, string ram, string hdd, double price) { string message = ""; try { var existing = (from im in db.retail where im.asset_tag.Equals(asset) select im).SingleOrDefault(); if (existing != null) { existing.price = price; existing.sold = "NO"; db.SaveChanges(); } else { var create_dymo = new retail(); create_dymo.time = DateTime.Today; create_dymo.custom_label = "YES"; create_dymo.asset_tag = asset; create_dymo.model = model; create_dymo.cpu = cpu; create_dymo.ram = ram; create_dymo.sold = "NO"; create_dymo.hdd = hdd; create_dymo.price = price; db.retail.Add(create_dymo); db.SaveChanges(); db.Dispose(); } } catch (Exception e) { message = e.Message.ToString(); } return(Json(message, JsonRequestBehavior.AllowGet)); }
//add ts stock from production public JsonResult ts_add_stock(string[] asset) { string message = ""; string current_asset = ""; //format the tsg sku to the ss format // channel = channel.Replace("TSG_", "HW-"); for (int i = 0; i < asset.Length; i++) { string temp_asset = asset[i]; var db = new db_a094d4_icdbEntities1(); var exisit = (from t in db.ts_stock where t.ictag == temp_asset select t).FirstOrDefault(); if (exisit == null) { int int_asset = int.Parse(temp_asset); var channel = (from t in db.rediscovery where t.ictag == int_asset select t.pallet).FirstOrDefault(); if (!channel.Contains("TSG_")) { message += "<p style='color:red'>" + asset[i] + " has a non-TechSoup SKU</p>"; continue; } channel = channel.Replace("TSG_", "HW-"); ts_stock ts = new ts_stock(); ts.ictag = temp_asset; current_asset = temp_asset; ts.sku = channel; ts.status = "Ready_for_Shipping"; db.ts_stock.Add(ts); db.SaveChanges(); message += "<p style='color:green'>" + asset[i] + " Sucessfully Added to " + channel + "</p>"; } else { message += "<p style='color:red'>" + asset[i] + " Failed to Import (possible duplicate entry)</p>"; } } db.Dispose(); return(Json(message, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> get_shipment(string id) { db_a094d4_icdbEntities1 db = new db_a094d4_icdbEntities1(); var baseAddress = new Uri("https://ssapi.shipstation.com/"); if (id == "interconnection123") { try { using (var httpClient = new HttpClient { BaseAddress = baseAddress }) { //Debug.Write(jj); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Basic ZmU3YzE2MGMyZjE0NDc1ZDljNWQ0ZWI2ZmMzYmRhOWU6YzRiM2RhMjlkZWZlNDgyOWJlZmRlYTExNmU1N2Q5ZTY="); // var DateStart = new DateTime(2016, 12, 13); var DateStart = DateTime.Today; var DateEnd = DateTime.Today.AddDays(+1); // var DateEnd = new DateTime(2016, 12, 30); using (var response = await httpClient.GetAsync("shipments?includeShipmentItems=true&shipDateStart=" + DateStart + "&shipDateEnd=" + DateEnd)) { if (response.IsSuccessStatusCode != true) { return(View(ViewBag.message = response.RequestMessage)); } string responseData = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <ss_order.ss_shipment_detail.Rootobject>(responseData); var total_page = result.pages; for (int i = 0; i < result.shipments.Length; i++) { if (result.shipments[i].shipmentItems != null) { var order_id = result.shipments[i].orderId; await get_order_detail(order_id); } } } } db.Dispose(); using (var db2 = new db_a094d4_icdbEntities1()) { db2.Database.ExecuteSqlCommand( "insert into process_run_time (process) values ('ShipStation')"); } } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } ViewBag.message = "Completed"; return(View()); } else { ViewBag.message = "Invalid ID"; return(View()); } }