public void Execute(object parameter) { PrintShop tempPrintShop = parameter as PrintShop; UpdatePrintShopVM = new UpdatePrintShopVM(tempPrintShop); VM.UpdateSelectedPrintShop(); }
public bool CanExecute(object parameter) { PrintShop selectedPrintShop = parameter as PrintShop; if (selectedPrintShop != null) { return(true); } return(false); }
public void AddNewMachine() { if (SelectedPrintShopName != null) { SelectedPrintShop = ListOfPrintShops.Where(p => (p.Name == SelectedPrintShopName)).FirstOrDefault() as PrintShop; NewMachine.PrintShopId = SelectedPrintShop.Id; if (NewMachine != null) { MessageBox.Show("New machine added to list"); DatabaseHelper.Insert <Machine>(NewMachine); } } }
public void TestSave() { using (var lifetime = IocConfig.Container.BeginLifetimeScope()) { var userService = lifetime.Resolve <IService <User> >(); //var printShopService = lifetime.Resolve<IService<PrintShop>>(); var printShop = new PrintShop { Code = "HongKong", DisplayName = "Hong Kong", EmailList = "*****@*****.**" }; var user = new User { UserName = "******", Password = "******", Active = 0, CreatedTime = DateTime.Now, DisplayName = "Leaf.Duan", Email = "*****@*****.**", PrintShop = printShop, VendorCode = "*", ModifiedTime = DateTime.Now }; //var printId = 0; var userId = 0; if (!userService.Exists(u => u.UserName == "leaf")) { /* print shop 主键作为 user 的外键时,会自动维护关系,先插入print shop,再赋值user的print_shop_id,再插入user */ /* 如果unique key关联,则不会自动维护关系 */ //printId = printShopService.Save<int>(printShop); userId = (int)userService.Save(user); } //Assert.IsTrue(printId > 0, "Save PrintShop fail"); Assert.IsTrue(userId > 0, "Save User fail"); } }
public AddNewPrintShopVM() { AddNewPrintShopCommand = new AddNewPrintShopCommand(this); NewPrintShop = new PrintShop(); }
public UpdatePrintShopVM(PrintShop selectedPrintShop) { SelectedPrintShop = selectedPrintShop; }