예제 #1
0
 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 }));
     }
 }
예제 #2
0
        public ActionResult CreateCoaxialCable(int orderId)
        {
            CoaxialCable coaxialCable = new CoaxialCable();

            coaxialCable.OrderId = orderId;
            return(View(coaxialCable));
        }
예제 #3
0
        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"));
            }
        }
예제 #4
0
        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 }));
            }
        }