public ICommandResult Handle(DeleteMachineCommand command) { try { _uow.GetRepository <Machine>().Delete(command.MachineId); _uow.SaveChanges(); return(new CommandResult(success: true, message: "Máquina removida com sucesso", data: command)); } catch (Exception ex) { return(new CommandResult(success: false, message: ex.Message, data: null)); } }
public ICommandResult DeleteMachine(Guid machineId) { var command = new DeleteMachineCommand { MachineId = machineId }; command.Validate(); if (!command.Valid) { return(new CommandResult(success: false, message: null, data: command.Notifications)); } return(_handler.Handle(command)); }
public ServicesVM() { NewPrintShopCommand = new NewPrintShopCommand(this); NewMachineCommand = new NewMachineCommand(this); NewServiceCommand = new NewServiceCommand(this); DeletePrintShopCommand = new DeletePrintShopCommand(this); DeleteMachineCommand = new DeleteMachineCommand(this); DeleteServiceCommand = new DeleteServiceCommand(this); SelectedPrintShopCommand = new SelectedPrintShopCommand(this); ExitCommand = new ExitCommand(this); PrintShops = new ObservableCollection <PrintShop>(); Services = new ObservableCollection <Service>(); Machines = new ObservableCollection <Machine>(); ReadPrintShops(); ReadMachines(); ReadServices(); }