public ComponentNewEditXtraForm(Guid id, string number) { this.id = id; InitializeComponent(); viewModel = (ComponentNewEditViewModel)Program .Kernel .Get <ComponentNewEditViewModel>(new ConstructorArgument("id", id)); viewModel.ModifiableView = this; viewModel.ValidatableView = this; viewModel.Number = number; IsEditMode = ctx.HasAccess(global::Domain.Entity.Security.Privileges.EditComponent); attachmentsButton.Enabled = true; CannotOpenForViewing = id == Guid.Empty; #region --- Colouring of required controls --- componentNumber.SetRequiredText(); type.SetRequiredText(); #endregion //--- Colouring of required controls --- #region --- Set Properties.CharacterCasing to Upper --- componentNumber.SetAsIdentifier(); certificateNumber.SetAsIdentifier(); #endregion //--- Set Properties.CharacterCasing to Upper --- }
public ComponentNewEditXtraForm(Guid id, string number) { this.Id = id; InitializeComponent(); SetControlsTextLength(); viewModel = (ComponentNewEditViewModel)Program .Kernel .Get<ComponentNewEditViewModel>(new ConstructorArgument("id", id)); viewModel.ModifiableView = this; viewModel.ValidatableView = this; if (string.IsNullOrWhiteSpace(viewModel.Component.Number)) { viewModel.Number = number; } attachmentsButton.Enabled = true; CannotOpenForViewing = id == Guid.Empty; #region --- Colouring of required controls --- componentNumber.SetRequiredText(); type.SetRequiredText(); #endregion //--- Colouring of required controls --- #region --- Set Properties.CharacterCasing to Upper --- componentNumber.SetAsIdentifier(); certificateNumber.SetAsIdentifier(); #endregion //--- Set Properties.CharacterCasing to Upper --- positiveFloat.SetFloatMask(Constants.DigitsBeforeDecimalPoint); SetConditional(this.componentNumber, delegate(bool editMode) { return (viewModel.ComponentIsActive); }); SetConditional(certificateNumber, delegate(bool editMode) { return (viewModel.ComponentIsActive); }); SetConditional(type, delegate(bool editMode) { return (viewModel.ComponentIsActive); }); SetConditional(componentParameters, delegate(bool editMode) { return (viewModel.ComponentIsActive); }); SetConditional(this.componentLength, delegate(bool editMode) { return (viewModel.ComponentIsActive); }); SetConditional(inspectionHistoryGrid, delegate(bool editMode) { return (viewModel.ComponentIsActive); }); }
public ComponentNewEditXtraForm(Guid id, string number) { this.Id = id; InitializeComponent(); SetControlsTextLength(); viewModel = (ComponentNewEditViewModel)Program .Kernel .Get <ComponentNewEditViewModel>(new ConstructorArgument("id", id)); viewModel.ModifiableView = this; viewModel.ValidatableView = this; if (string.IsNullOrWhiteSpace(viewModel.Component.Number)) { viewModel.Number = number; } attachmentsButton.Enabled = true; CannotOpenForViewing = id == Guid.Empty; #region --- Colouring of required controls --- componentNumber.SetRequiredText(); type.SetRequiredText(); #endregion //--- Colouring of required controls --- #region --- Set Properties.CharacterCasing to Upper --- componentNumber.SetAsIdentifier(); certificateNumber.SetAsIdentifier(); #endregion //--- Set Properties.CharacterCasing to Upper --- positiveFloat.SetFloatMask(Constants.DigitsBeforeDecimalPoint); SetConditional(this.componentNumber, delegate(bool editMode) { return(viewModel.ComponentIsActive); }); SetConditional(certificateNumber, delegate(bool editMode) { return(viewModel.ComponentIsActive); }); SetConditional(type, delegate(bool editMode) { return(viewModel.ComponentIsActive); }); SetConditional(componentParameters, delegate(bool editMode) { return(viewModel.ComponentIsActive); }); SetConditional(this.componentLength, delegate(bool editMode) { return(viewModel.ComponentIsActive); }); SetConditional(inspectionHistoryGrid, delegate(bool editMode) { return(viewModel.ComponentIsActive); }); }
public void TestNewSaveComponent() { var modifiableView = new Mock<IModifiable>(); var validatableView = new Mock<IValidatable>(); var notify = new Mock<IUserNotify>(); var securityContext = new Mock<ISecurityContext>(); var componentRepo = new Mock<IComponentRepository>(); var componentTypeRepo = new Mock<IComponentTypeRepository>(); var repoInspector = new Mock<IInspectorRepository>(); var component = new Prizm.Domain.Entity.Construction.Component() { Number = string.Empty}; componentRepo.Setup(x => x.GetActiveByNumber(component)).Returns(new List<Prizm.Domain.Entity.Construction.Component>()); componentTypeRepo.Setup(x => x.GetAll()).Returns(new List<ComponentType>()); componentTypeRepo.Setup(x => x.GetAll()).Returns(new List<ComponentType>()); var componentsRepos = new Mock<IComponentRepositories>(); componentsRepos.SetupGet(_ => _.ComponentRepo).Returns(componentRepo.Object); componentsRepos.SetupGet(_ => _.ComponentTypeRepo).Returns(componentTypeRepo.Object); componentsRepos.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object); modifiableView.SetupGet(x => x.IsModified).Returns(false); validatableView.Setup(t => t.Validate()).Returns(true); var viewModel = new ComponentNewEditViewModel( componentsRepos.Object, Guid.Empty, notify.Object, securityContext.Object); viewModel.Component = component; viewModel.ModifiableView = modifiableView.Object; viewModel.ValidatableView = validatableView.Object; var command = new NewSaveComponentCommand( viewModel, componentsRepos.Object, notify.Object, securityContext.Object); command.Execute(); componentsRepos.Verify(_ => _.BeginTransaction(), Times.Once()); componentRepo.Verify(_ => _.SaveOrUpdate(It.IsAny<Prizm.Domain.Entity.Construction.Component>()), Times.Once()); componentsRepos.Verify(_ => _.Commit(), Times.Once()); componentRepo.Verify(_ => _.Evict(It.IsAny<Prizm.Domain.Entity.Construction.Component>()), Times.Once()); }
public SaveComponentCommand( ComponentNewEditViewModel viewModel, IComponentRepositories repo, IUserNotify notify, ISecurityContext ctx) { this.viewModel = viewModel; this.repos = repo; this.notify = notify; this.ctx = ctx; }
public NewSaveComponentCommand( ComponentNewEditViewModel viewModel, IComponentRepositories repo, IUserNotify notify, ISecurityContext ctx) { this.viewModel = viewModel; this.repos = repo; this.notify = notify; this.ctx = ctx; }
private void ComponentNewEditXtraForm_FormClosed(object sender, FormClosedEventArgs e) { commandManager.Dispose(); viewModel.Dispose(); viewModel = null; }