Example #1
0
            public void ReturnsNullForUnregisteredViewModel()
            {
                var vmManager = new ViewModelManager();

                var foundvm = vmManager.GetViewModel(42);

                Assert.IsNull(foundvm);
            }
Example #2
0
            public void ReturnsViewModelForRegisteredViewModel()
            {
                var vm        = new TestViewModel();
                var vmManager = new ViewModelManager();

                vmManager.RegisterViewModelInstance(vm);
                var foundvm = vmManager.GetViewModel(vm.UniqueIdentifier);

                Assert.AreEqual(vm, foundvm);
            }
        void GridView_CellValidating(object sender, GridViewCellValidatingEventArgs e)
        {
            GridViewCell cell = e.Cell;

            //isValid = IsValidInventoryRange(e.NewValue);

            var    viewmodel      = ViewModelManager.GetViewModel <TransferRequestViewModel, TransferRequestsView>();
            var    qty            = (decimal)0.0;
            string validationText = "";
            bool   isValid        = false;

            if (decimal.TryParse(e.NewValue.ToString(), out qty))
            {
                qty = e.NewValue != null ? (decimal)e.NewValue : 0;
                var rangeMessage = TransferRequestHelper.GetInventoryRange(viewmodel.SelectedDetail.ItemCode, qty);

                isValid = (string.IsNullOrEmpty(rangeMessage.Item1)) ||
                          viewmodel.ConfirmDialog(rangeMessage.Item1, "Alerta inventario");

                validationText = rangeMessage.Item2;

                if (!isValid)
                {
                    validationText += "\n Porfavor ingrese un valor valido";
                }

                if (!isValid)
                {
                    this.MarkCell(cell, validationText);
                }
                else
                {
                    this.RestoreCell(cell);
                }
            }
            else
            {
                validationText = "Ingrese un valor valido";
            }
            e.ErrorMessage = validationText;
            e.IsValid      = isValid;
        }
Example #4
0
        public BaseDialogFragment(int layout)
        {
            _layout = layout;
#if DEBUG
            try
            {
                ViewModel = (T)ViewModelManager.GetViewModel(typeof(T));
            }
            catch (Exception)
            {
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }
                throw;
            }
#else
            ViewModel = (T)ViewModelManager.GetViewModel(typeof(T));
#endif
        }
            public void ReturnsViewModelForRegisteredViewModel()
            {
                var vm = new TestViewModel();
                var vmManager = new ViewModelManager();

                vmManager.RegisterViewModelInstance(vm);
                var foundvm = vmManager.GetViewModel(vm.UniqueIdentifier);

                Assert.AreEqual(vm, foundvm);
            }
            public void ReturnsNullForUnregisteredViewModel()
            {
                var vmManager = new ViewModelManager();

                var foundvm = vmManager.GetViewModel(42);

                Assert.IsNull(foundvm);
            }
Example #7
0
 protected T GetViewModel <T>()
 {
     return((T)ViewModelManager.GetViewModel(typeof(T)));
 }