public async Task <IActionResult> Edit(int id, [Bind("mcID,Name,Cost,InStock,mID,jtID,pID")] MComponent mComponent) { if (id != mComponent.mcID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(mComponent); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MComponentExists(mComponent.mcID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["jtID"] = new SelectList(_context.jTypes, "jtID", "jtID", mComponent.jtID); ViewData["mID"] = new SelectList(_context.Metals, "mID", "mID", mComponent.mID); ViewData["pID"] = new SelectList(_context.Provisioners, "pID", "pID", mComponent.pID); return(View(mComponent)); }
public MComponent Add(int componentType, MComponent component) { component.Entity = this; int index = componentType; _components[index] = component; OnComponentAdded(this, componentType, component); _componentsMask |= 1L << index; return(component); }
public async Task <IActionResult> Create([Bind("mcID,Name,Cost,InStock,mID,jtID,pID")] MComponent mComponent) { if (ModelState.IsValid) { _context.Add(mComponent); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["jtID"] = new SelectList(_context.jTypes, "jtID", "jtID", mComponent.jtID); ViewData["mID"] = new SelectList(_context.Metals, "mID", "mID", mComponent.mID); ViewData["pID"] = new SelectList(_context.Provisioners, "pID", "pID", mComponent.pID); return(View(mComponent)); }
public void AddComponent(MComponent component, int componentType) { _components[componentType].Add(component); }
private void OnComponentAdded(MEntity entity, int componentType, MComponent component) { _componentGroup.AddComponent(component, componentType); }