/// <summary> /// OnConfigureHardware opens the Configure Hardware Wizard /// so that the user can set up the licensing. /// </summary> private void OnConfigureHardware() { //Create a HardwareWizard and Show it HardwareViewModel hwVM = this._unity.Resolve <HardwareViewModel>(); HardwareView hwV = this._unity.Resolve <HardwareView>(); //Register the Instance of the HardwareView this._unity.RegisterInstance <HardwareView>(Strings.HardwareWizardName, hwV); //Wire up the View with the ViewModel and vice-versa hwV.DataContext = hwVM; hwVM.HookEvents(hwV); //Get a reference to the Shell and make it //the Owner of the Wizard ShellView sv = this._unity.Resolve <ShellView>(Strings.ShellViewName); hwV.Owner = sv; //Show the Dialog Nullable <Boolean> result = hwV.ShowDialog(); //If the user Finished the Dialog, fire the event //to notify of UI changes if (result == true) { this._eventAggregator.GetEvent <HardwareChangedEvent>().Publish(null); } }
public ActionResult Show(int?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var viewModel = new HardwareView(); var hardware = db.Hardwares .Include(h => h.Inventory) .Include(h => h.Inventory.Maker) .Include(h => h.Inventory.Vendor) .Include(h => h.HardwareType) .Include(h => h.Inventory.Owner) .Include(h => h.Inventory.Documents) .SingleOrDefault(h => h.Id == Id); var userId = User.Identity.GetUserId(); var employee = db.Employees .Include(e => e.Owner) .SingleOrDefault(i => i.User.Id == userId); if (User.IsInRole(ApplicationUser.USER) && hardware.Inventory.OwnerId != employee.Owner.Id) { return(new HttpUnauthorizedResult()); } if (hardware == null) { return(new HttpNotFoundResult()); } viewModel.Hardware = hardware; return(View(viewModel)); }