public ActionResult CreateCoaxialCable(CoaxialCable coaxialCable) { try { db.products.Add(coaxialCable); db.SaveChanges(); RemoveInventory removeInventory = new RemoveInventory() { CableQuantity = coaxialCable.CableQuantity, ConnecterQuantity = coaxialCable.ConnecterQuantity, HeatShrinkQuantity = coaxialCable.HeatShrinkQuantity }; using (var client = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate })) { client.BaseAddress = new Uri("http://localhost:52290/api/RemoveInventory/"); var response = client.PutAsJsonAsync(client.BaseAddress, removeInventory).Result; } CheckInventoryItems(); return(RedirectToAction("OrderMaterials", "Order", new { id = coaxialCable.OrderId })); } catch { return(RedirectToAction("OrderMaterials", "Order", new { id = coaxialCable.OrderId })); } }
public ActionResult CreateCoaxialCable(int orderId) { CoaxialCable coaxialCable = new CoaxialCable(); coaxialCable.OrderId = orderId; return(View(coaxialCable)); }
public ActionResult DeleteProduct(int id, CoaxialCable coaxial) { var coaxialCable = db.products.Where(i => i.PartId == id).Single(); try { db.products.Remove(coaxialCable); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(RedirectToAction("Index")); } }
public ActionResult EditProduct(CoaxialCable coaxialCable) { var findProduct = db.products.Where(p => p.PartId == coaxialCable.PartId).SingleOrDefault(); try { findProduct.HeatShrinkQuantity = coaxialCable.HeatShrinkQuantity; findProduct.Impedance = coaxialCable.Impedance; findProduct.PartName = coaxialCable.PartName; db.SaveChanges(); return(RedirectToAction("OrderMaterials", "Order", new { id = findProduct.OrderId })); } catch { return(RedirectToAction("OrderMaterials", "Order", new { id = findProduct.OrderId })); } }