public ActionResult Create([Bind(Include = "PortID,SiteID,Facility,PortType,NoOfPorts,StartPort")] Port port) { var sid = (int)Session["siteid"]; ViewBag.SiteCode = sid; if (ModelState.IsValid) { var portInventories = new PortInventory(); db.Ports.Add(port); portInventories.PortID = port.PortID; int startingIndex = port.StartPort.Trim().LastIndexOf("/"); string portPrefix = port.StartPort.Trim().Substring(0, startingIndex + 1); int startingPort = int.Parse(port.StartPort.Substring(startingIndex + 1)); for (int i = startingPort; i <= (int)port.NoOfPorts + startingPort - 1; i++) { portInventories.Port = portPrefix + i.ToString(); db.PortInventories.Add(portInventories); db.SaveChanges(); } db.SaveChanges(); return(RedirectToAction("GetDetails", "Inventories", new { id = sid })); } ViewBag.SiteID = new SelectList(db.Sites.Where(s => s.SiteID == sid), "SiteID", "SiteFullName", port.SiteID); return(View(port)); }
public ActionResult DeleteConfirmed(int id) { PortInventory portInventory = db.PortInventories.Find(id); db.PortInventories.Remove(portInventory); db.SaveChanges(); return(RedirectToAction("Index", new { pid = portInventory.PortID })); }
public void SetupPort() { Debug.Log("Attempting to set up port " + portName); gameController = GameObject.Find("GameController").GetComponent <GameController>(); portInventory = GetComponent <PortInventory>(); portInventory.SetUpPortInventory(); playerInventory = GameObject.FindWithTag("Player").GetComponent <ShipInventory>(); Debug.Log("Successfully set up " + portName); }
public ActionResult Edit([Bind(Include = "PortInventoryID,PortID,Port,ConnectorType,Bandwidth,CircuitAssignment,NeighborPort,Remarks")] PortInventory portInventory) { if (ModelState.IsValid) { db.Entry(portInventory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { pid = portInventory.PortID })); } ViewBag.CurrentPortID = portInventory.PortID; ViewBag.PortID = new SelectList(db.Ports, "PortID", "Facility", portInventory.PortID); return(View(portInventory)); }
// GET: PortInventories/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PortInventory portInventory = db.PortInventories.Find(id); if (portInventory == null) { return(HttpNotFound()); } ViewBag.CurrentPortID = portInventory.PortID; return(View(portInventory)); }
// GET: PortInventories/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PortInventory portInventory = db.PortInventories.Find(id); if (portInventory == null) { return(HttpNotFound()); } ViewBag.CurrentPortID = portInventory.PortID; ViewBag.PortID = new SelectList(db.Ports, "PortID", "Facility", portInventory.PortID); return(View(portInventory)); }
public void PopulateSellButtonList(PortInventory portInventory) { sellButtons = new List <GameObject>(); foreach (ItemForSale item in portInventory.itemsPurchasableHere) { GameObject newButton = Instantiate(sellButtonsPrefab); newButton.transform.SetParent(sellButtonsPrefab.transform.parent); newButton.transform.localScale = sellButtonsPrefab.transform.localScale; SaleButton buttonScript = newButton.GetComponent <SaleButton>(); buttonScript.itemForSale = item; buttonScript.itemName.text = item.item.itemName; buttonScript.itemCost.text = item.price.ToString(); sellButtons.Add(newButton); newButton.SetActive(true); } }