public ReleaseNoteViewModel(IReleaseNoteRepositories repos, Guid id, IUserNotify notify, ISecurityContext ctx) { this.repos = repos; this.notify = notify; this.ctx = ctx; saveCommand = ViewModelSource.Create(() => new SaveReleaseNoteCommand(this, repos, notify, ctx)); shipCommand = ViewModelSource.Create(() => new ShipReleaseNoteCommand(this, repos, notify, ctx)); unshipCommand = ViewModelSource.Create(() => new UnshipReleaseNoteCommand(this, repos, notify, ctx)); ReleaseNotePipes = new PlainPipeBindingList(); if (id == Guid.Empty) { NewRailcar(); } else { ReleaseNote = repos.ReleaseNoteRepo.Get(id); if (ReleaseNote == null) { log.Error(string.Format("Release Note (id:{0}) does not exist.", id)); // TODO: user message? close document? } else { IList <Pipe> pipes = repos.ReleaseNoteRepo.GetReleasedNotePipe(id); foreach (var p in pipes) { ReleaseNotePipes.Add(new PlainPipe(p)); } } } }
public ReleaseNoteViewModel(IReleaseNoteRepositories repos, Guid id, IUserNotify notify, ISecurityContext ctx) { try { this.repos = repos; this.notify = notify; this.ctx = ctx; saveCommand = ViewModelSource.Create(() => new SaveReleaseNoteCommand(this, repos, notify, ctx)); shipCommand = ViewModelSource.Create(() => new ShipReleaseNoteCommand(this, repos, notify, ctx)); unshipCommand = ViewModelSource.Create(() => new UnshipReleaseNoteCommand(this, repos, notify, ctx)); ReleaseNotePipes = new PlainPipeBindingList(); if (id == Guid.Empty) { NewRailcar(); } else { ReleaseNote = repos.SimpleNoteRepo.Get(id); if (ReleaseNote == null) { log.Error(string.Format("Release Note (id:{0}) does not exist.", id)); // TODO: user message? close document? } else { IList <SimplePipe> pipes = repos.SimpleNoteRepo.GetReleasedNotePipe(id); foreach (var p in pipes) { ReleaseNotePipes.Add(new PlainPipe(p)); } } } } catch (RepositoryException ex) { log.Warn(this.GetType().Name + " | " + ex.ToString()); notify.ShowWarning(Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Message), Program.LanguageManager.GetString(StringResources.Notification_Error_Db_Header)); } }
public void UnshipRailcarCommand() { notify = new Mock<IUserNotify>(); repos = new Mock<IReleaseNoteRepositories>(); pipeRepo = new Mock<IPipeRepository>(); carRepo = new Mock<IRailcarRepository>(); var ctx = new Mock<ISecurityContext>(); pipeRepo.Setup(x => x.GetStored()).Returns(new List<Pipe>() { new Pipe() }); repos.SetupGet(_ => _.PipeRepo).Returns(pipeRepo.Object); repos.SetupGet(_ => _.RailcarRepo).Returns(carRepo.Object); viewModel = new ReleaseNoteViewModel(repos.Object, Guid.Empty, notify.Object, ctx.Object); viewModel.Railcar.Number = "Railcar"; command = new UnshipReleaseNoteCommand(viewModel, repos.Object, notify.Object, ctx.Object); command.Execute(); }