Esempio n. 1
0
        public ActionResult Edit(string id)
        {
            Guid ID = Guid.Parse(id);

            var ls = orgApp.GetOrgSelect(ID);

            if (!(ID == Guid.Empty))
            {
                var org = orgApp.GetOrgInfo(ID);

                ls.Where(t => t.Value == org.ParentCode.ToString()).FirstOrDefault().Selected = true;

                var temp = ls.Where(t => t.Value == ID.ToString()).FirstOrDefault();

                if (temp != null)
                {
                    temp.Disabled = false;
                }

                ViewData["OrgViewModel"] = org;
            }
            else
            {
                ViewData["OrgViewModel"] = new OrgViewModel();
            }

            ViewData["OrgList"] = new SelectList(ls, "Value", "Text");
            return(View());
        }
Esempio n. 2
0
        /// <summary>
        /// 新增机构
        /// </summary>
        /// <param name="ovm"></param>
        /// <returns></returns>
        public AjaxResult Add(OrgViewModel ovm)
        {
            var Count = orgRository.Filter(t => t.OrgName == ovm.OrgName && t.ParentCode == ovm.ParentCode).Count();

            if (Count > 0)
            {
                return new AjaxResult {
                           state = ResultType.error.ToString(), message = "机构已存在!", data = null
                }
            }
            ;

            Organization org = new Organization();

            org.OrgCode        = Guid.NewGuid();
            org.ParentCode     = ovm.ParentCode;
            org.OrgName        = ovm.OrgName;
            org.OrgExplain     = ovm.OrgExplain;
            org.CreaterDate    = DateTime.Now;
            org.CreateUserCode = Guid.Parse(DLSession.GetCurrLoginCode());
            orgRository.Create(org);
            return(new AjaxResult {
                state = ResultType.success.ToString(), message = "操作成功!", data = null
            });
        }
        public void LoadChildren_UpdatesAllSpaces()
        {
            var initialSpacesList = new System.Collections.ObjectModel.ObservableCollection <TreeViewItemViewModel>
            {
                new SpaceViewModel(new CloudFoundrySpace("initial space 1", "initial space 1 guid", null), services),
                new SpaceViewModel(new CloudFoundrySpace("initial space 2", "initial space 2 guid", null), services),
                new SpaceViewModel(new CloudFoundrySpace("initial space 3", "initial space 3 guid", null), services)
            };

            ovm = new OrgViewModel(new CloudFoundryOrganization("fake org", null, null), services)
            {
                Children = initialSpacesList
            };

            var newSpacesList = new List <CloudFoundrySpace>
            {
                new CloudFoundrySpace("initial space 1", "initial space 1 guid", null),
                new CloudFoundrySpace("initial space 2", "initial space 2 guid", null)
            };

            mockCloudFoundryService.Setup(mock => mock.GetSpacesForOrgAsync(It.IsAny <CloudFoundryOrganization>()))
            .ReturnsAsync(newSpacesList);

            Assert.AreEqual(initialSpacesList.Count, ovm.Children.Count);

            ovm.IsExpanded = true;

            Assert.AreEqual(newSpacesList.Count, ovm.Children.Count);
            mockCloudFoundryService.VerifyAll();
        }
        public void ChildrenAreLazilyLoaded_UponViewModelExpansion()
        {
            var fakeSpaceList = new List <CloudFoundrySpace>
            {
                new CloudFoundrySpace("spaceName1", "spaceId1", null),
                new CloudFoundrySpace("spaceName2", "spaceId2", null),
                new CloudFoundrySpace("spaceName3", "spaceId3", null),
                new CloudFoundrySpace("spaceName4", "spaceId4", null)
            };

            mockCloudFoundryService.Setup(mock => mock.GetSpacesForOrgAsync(It.IsAny <CloudFoundryOrganization>()))
            .ReturnsAsync(fakeSpaceList);

            ovm = new OrgViewModel(new CloudFoundryOrganization("fake org", null, null), services);

            // check presence of single placeholder child *before* CfInstanceViewModel is expanded
            Assert.AreEqual(1, ovm.Children.Count);
            Assert.AreEqual(null, ovm.Children[0]);

            // expand several times to ensure children re-loaded each time
            ovm.IsExpanded = true;
            ovm.IsExpanded = false;
            ovm.IsExpanded = true;
            ovm.IsExpanded = false;
            ovm.IsExpanded = true;

            Assert.AreEqual(fakeSpaceList.Count, ovm.Children.Count);
            mockCloudFoundryService.Verify(mock =>
                                           mock.GetSpacesForOrgAsync(It.IsAny <CloudFoundryOrganization>()), Times.Exactly(3));
        }
Esempio n. 5
0
        public async Task RefreshChildren_AddsPlaceholder_WhenAllOrgsAreRemoved()
        {
            var fakeInitialOrg = new CloudFoundryOrganization("fake org name", "fake org id", parentCf: _sut.CloudFoundryInstance);
            var ovm            = new OrgViewModel(fakeInitialOrg, null, null, Services);

            var fakeEmptyOrgsResult = new DetailedResult <List <CloudFoundryOrganization> >(
                succeeded: true,
                content: new List <CloudFoundryOrganization>(), // simulate cf having lost all orgs before refresh
                explanation: null,
                cmdDetails: FakeSuccessCmdResult);

            MockCloudFoundryService.Setup(mock => mock.
                                          GetOrgsForCfInstanceAsync(_sut.CloudFoundryInstance, true, It.IsAny <int>()))
            .ReturnsAsync(fakeEmptyOrgsResult);

            _sut.Children = new ObservableCollection <TreeViewItemViewModel> {
                ovm
            };                                                                       // simulate cf initially having 1 org child

            Assert.AreEqual(1, _sut.Children.Count);
            Assert.AreEqual(typeof(OrgViewModel), _sut.Children[0].GetType());

            await _sut.RefreshChildren();

            Assert.AreEqual(1, _sut.Children.Count);
            Assert.AreEqual(typeof(PlaceholderViewModel), _sut.Children[0].GetType());
            Assert.AreEqual(CfInstanceViewModel._emptyOrgsPlaceholderMsg, _sut.Children[0].DisplayText);
        }
Esempio n. 6
0
        public async Task <IActionResult> EditOrganization([FromForm] OrgViewModel model)
        {
            if (ModelState.IsValid)
            {
                Organization organization;
                if (model.OrgId > 0)
                {
                    organization = await _sysAdminSvc.GetOrganiztion(model.OrgId);
                }
                else
                {
                    organization = new Organization
                    {
                        CreatedBy = UserHelper.GetUserID(HttpContext),
                        CreatedOn = DateTime.Now
                    };
                }

                organization.Name         = model.OrgName;
                organization.ActiveStatus = model.ActiveStatus;

                if (await _sysAdminSvc.SaveOrganization(organization) == true)
                {
                    return(RedirectToAction(nameof(Organizations)));
                }
                else
                {
                    ModelState.AddModelError("", "向数据库提交保存单位出现错误");
                }
            }
            return(View(model));
        }
Esempio n. 7
0
        private List <OrgViewModel> ToTreeViewModel(List <Organization> orgs)
        {
            List <OrgViewModel> Org_ls = new List <OrgViewModel>();

            foreach (var item in orgs)
            {
                OrgViewModel ov = new OrgViewModel();
                ov.CreaterDate    = item.CreaterDate;
                ov.CreateUserCode = item.CreateUserCode;
                ov.OrgCode        = item.OrgCode;
                ov.OrgExplain     = item.OrgExplain;
                ov.OrgName        = item.OrgName;
                ov.ParentCode     = item.ParentCode;
                ov.UpdateDate     = item.UpdateDate;
                ov.UpdateUserCode = item.UpdateUserCode;
                ov.level          = 0;
                ov.parent         = Guid.Empty;
                ov.isLeaf         = false;
                ov.expanded       = true;
                Org_ls.Add(ov);
                ToTreeViewModel(Org_ls, orgs.Where(t => t.ParentCode == item.OrgCode).ToList(), 0, item.OrgCode);
            }

            return(Org_ls);
        }
        public async Task FetchChildren_ReturnsListOfSpaces_WithoutUpdatingChildren()
        {
            var receivedEvents = new List <string>();
            var fakeOrg        = new CloudFoundryOrganization("junk", null, null);

            ovm = new OrgViewModel(fakeOrg, services);

            ovm.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                receivedEvents.Add(e.PropertyName);
            };

            mockCloudFoundryService.Setup(mock => mock.GetSpacesForOrgAsync(fakeOrg))
            .ReturnsAsync(new List <CloudFoundrySpace>
            {
                new CloudFoundrySpace("fake space name 1", "fake space id 1", fakeOrg),
                new CloudFoundrySpace("fake space name 2", "fake space id 2", fakeOrg)
            });

            var spaces = await ovm.FetchChildren();

            Assert.AreEqual(2, spaces.Count);

            Assert.AreEqual(1, ovm.Children.Count);
            Assert.IsNull(ovm.Children[0]);

            // property changed events should not be raised
            Assert.AreEqual(0, receivedEvents.Count);

            mockCloudFoundryService.VerifyAll();
        }
        public void Constructor_SetsDisplayTextToOrgName()
        {
            string orgName = "junk";
            var    fakeOrg = new CloudFoundryOrganization(orgName, null, null);

            ovm = new OrgViewModel(fakeOrg, services);

            Assert.AreEqual(orgName, ovm.DisplayText);
        }
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, OrgViewModel org)
        {
            if (org != null && ModelState.IsValid)
            {
                repo.Update(org);
            }

            return(Json(new[] { org }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, OrgViewModel org)
        {
            if (org != null)
            {
                repo.Destroy(org);
            }

            return(Json(new[] { org }.ToDataSourceResult(request, ModelState)));
        }
        public async Task RefreshAllCloudConnections_DoesNotThrowExceptions_WhenOrgsHaveNullChildren()
        {
            var fakeCfInstance = new CloudFoundryInstance("fake cf name", "http://fake.api.address", "fake-token");

            mockCloudFoundryService.SetupGet(mock => mock.CloudFoundryInstances)
            .Returns(new Dictionary <string, CloudFoundryInstance> {
                { "fake cf name", fakeCfInstance }
            });

            var cfivm = new CfInstanceViewModel(fakeCfInstance, services);

            var fakeOrg = new CloudFoundryOrganization("fake org name", "fake org id", fakeCfInstance);
            var ovm     = new OrgViewModel(fakeOrg, services);

            cfivm.Children = new ObservableCollection <TreeViewItemViewModel>
            {
                ovm
            };

            // check for presence of Dummy child (sanity check)
            Assert.AreEqual(1, ovm.Children.Count);
            Assert.IsNull(ovm.Children[0]);

            mockCloudFoundryService.Setup(mock => mock.GetOrgsForCfInstanceAsync(fakeCfInstance)).ReturnsAsync(new List <CloudFoundryOrganization>
            {
                fakeOrg
            });

            mockCloudFoundryService.Setup(mock => mock.GetSpacesForOrgAsync(fakeOrg)).ReturnsAsync(new List <CloudFoundrySpace>());

            vm.CloudFoundryList = new List <CfInstanceViewModel>
            {
                cfivm
            };

            Exception shouldStayNull = null;

            try
            {
                await vm.RefreshAllCloudConnections(null);
            }
            catch (Exception e)
            {
                shouldStayNull = e;
            }

            Assert.IsNull(shouldStayNull);

            Assert.AreEqual(1, cfivm.Children.Count);
            Assert.AreEqual(ovm, cfivm.Children[0]);

            Assert.AreEqual(1, ovm.Children.Count);
            Assert.IsNull(ovm.Children[0]);

            mockCloudFoundryService.VerifyAll();
        }
Esempio n. 13
0
        public IActionResult EditOrganization()
        {
            OrgViewModel model = new OrgViewModel
            {
                OrgId        = 0,
                ActiveStatus = true
            };

            return(View(model));
        }
Esempio n. 14
0
        public OrgTableSource(UITableView tableView, OrgViewModel viewModel)
            : base(tableView)
        {
            _viewModel = viewModel;

            tableView.RegisterClassForHeaderFooterViewReuse(typeof(GroupHeaderView), GroupHeaderView.Key);
            tableView.RegisterNibForCellReuse(EntityCell.Nib, EntityCell.Key);
            tableView.RegisterNibForCellReuse(OrgEventCell.Nib, OrgEventCell.Key);

            _scrollToHideManager = new ScrollToHideUIManager(tableView);
        }
        public void LoadChildren_SetsSpecialDisplayText_WhenThereAreNoSpaces()
        {
            ovm = new OrgViewModel(new CloudFoundryOrganization("fake org", null, null), services);
            List <CloudFoundrySpace> emptySpacesList = new List <CloudFoundrySpace>();

            mockCloudFoundryService.Setup(mock => mock.GetSpacesForOrgAsync(It.IsAny <CloudFoundryOrganization>()))
            .ReturnsAsync(emptySpacesList);

            ovm.IsExpanded = true;

            Assert.IsTrue(ovm.DisplayText.Contains(" (no spaces)"));
        }
Esempio n. 16
0
        private void UpdateOrg_Click(object sender, RoutedEventArgs e)
        {
            OrgViewModel  orVM   = OrgBox.SelectedItem as OrgViewModel;
            EditWindowOrg ew     = new EditWindowOrg(orVM);
            var           result = ew.ShowDialog();

            if (result == true)
            {
                orgService.Update(orVM);
                ew.Close();
                orgs = orgService.GetAll();
                OrgBox.ItemsSource = orgs;
            }
        }
        public async Task RefreshCfInstance_UpdatesChildrenOnCfInstanceViewModel()
        {
            var fakeCfInstance          = new CloudFoundryInstance("fake space name", "fake space id", null);
            var fakeCfInstanceViewModel = new CfInstanceViewModel(fakeCfInstance, services);

            var fakeOrgName1 = "fake org 1";
            var fakeOrgName2 = "fake org 2";
            var fakeOrgName3 = "fake org 3";

            var fakeOrgGuid1 = "fake org 1";
            var fakeOrgGuid2 = "fake org 2";
            var fakeOrgGuid3 = "fake org 3";

            fakeCfInstanceViewModel.Children = new ObservableCollection <TreeViewItemViewModel>
            {
                new OrgViewModel(new CloudFoundryOrganization(fakeOrgName1, fakeOrgGuid1, fakeCfInstance), services)
            };

            fakeCfInstanceViewModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                receivedEvents.Add(e.PropertyName);
            };

            Assert.AreEqual(1, fakeCfInstanceViewModel.Children.Count);
            OrgViewModel firstChildOrg = (OrgViewModel)fakeCfInstanceViewModel.Children[0];

            Assert.AreEqual(fakeOrgName1, firstChildOrg.Org.OrgName);

            mockCloudFoundryService.Setup(mock => mock.GetOrgsForCfInstanceAsync(fakeCfInstance)).ReturnsAsync(new List <CloudFoundryOrganization>
            {
                new CloudFoundryOrganization(fakeOrgName2, fakeOrgGuid2, fakeCfInstance),
                new CloudFoundryOrganization(fakeOrgName3, fakeOrgGuid3, fakeCfInstance)
            });

            await vm.RefreshCfInstance(fakeCfInstanceViewModel);

            Assert.AreEqual(2, fakeCfInstanceViewModel.Children.Count);
            OrgViewModel firstNewChildOrg  = (OrgViewModel)fakeCfInstanceViewModel.Children[0];
            OrgViewModel secondNewChildOrg = (OrgViewModel)fakeCfInstanceViewModel.Children[1];

            Assert.AreEqual(fakeOrgName2, firstNewChildOrg.Org.OrgName);
            Assert.AreEqual(fakeOrgName3, secondNewChildOrg.Org.OrgName);

            // property changed events should not be raised
            Assert.AreEqual(0, receivedEvents.Count);

            mockCloudFoundryService.VerifyAll();
        }
        public async Task RefreshOrg_UpdatesChildrenOnOrgViewModel()
        {
            var fakeOrg          = new CloudFoundryOrganization("fake org name", "fake org id", null);
            var fakeOrgViewModel = new OrgViewModel(fakeOrg, services);

            var fakeSpaceName1 = "fake space 1";
            var fakeSpaceName2 = "fake space 2";
            var fakeSpaceName3 = "fake space 3";

            var fakeSpaceGuid1 = "fake space 1";
            var fakeSpaceGuid2 = "fake space 2";
            var fakeSpaceGuid3 = "fake space 3";

            fakeOrgViewModel.Children = new ObservableCollection <TreeViewItemViewModel>
            {
                new SpaceViewModel(new CloudFoundrySpace(fakeSpaceName1, fakeSpaceGuid1, fakeOrg), services)
            };

            fakeOrgViewModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                receivedEvents.Add(e.PropertyName);
            };

            Assert.AreEqual(1, fakeOrgViewModel.Children.Count);
            SpaceViewModel firstChildSpace = (SpaceViewModel)fakeOrgViewModel.Children[0];

            Assert.AreEqual(fakeSpaceName1, firstChildSpace.Space.SpaceName);

            mockCloudFoundryService.Setup(mock => mock.GetSpacesForOrgAsync(fakeOrg)).ReturnsAsync(new List <CloudFoundrySpace>
            {
                new CloudFoundrySpace(fakeSpaceName2, fakeSpaceGuid2, fakeOrg),
                new CloudFoundrySpace(fakeSpaceName3, fakeSpaceGuid3, fakeOrg)
            });

            await vm.RefreshOrg(fakeOrgViewModel);

            Assert.AreEqual(2, fakeOrgViewModel.Children.Count);
            SpaceViewModel firstNewChildSpace  = (SpaceViewModel)fakeOrgViewModel.Children[0];
            SpaceViewModel secondNewChildSpace = (SpaceViewModel)fakeOrgViewModel.Children[1];

            Assert.AreEqual(fakeSpaceName2, firstNewChildSpace.Space.SpaceName);
            Assert.AreEqual(fakeSpaceName3, secondNewChildSpace.Space.SpaceName);

            // property changed events should not be raised
            Assert.AreEqual(0, receivedEvents.Count);

            mockCloudFoundryService.VerifyAll();
        }
Esempio n. 19
0
 public async Task <IActionResult> DeleteOrganization([FromForm] OrgViewModel model)
 {
     if (model.ActiveStatus == true)
     {
         ModelState.AddModelError("", "正在使用的组织不可以删除,请首先设置它为无效");
     }
     else
     {
         if (await _sysAdminSvc.DeleteOrganization(model.OrgId) == true)
         {
             return(RedirectToAction(nameof(Organizations)));
         }
         ModelState.AddModelError("", "删除单位出现错误,没有成功。");
     }
     return(View("EditOrganization", model));
 }
Esempio n. 20
0
 public ActionResult AddOrUpdateOrg(OrgViewModel ov)
 {
     if (ov != null)
     {
         if (ov.OrgCode == Guid.Empty)
         {
             return(Content(orgApp.Add(ov).ToJson()));
         }
         else
         {
             return(Content(orgApp.Update(ov).ToJson()));
         }
     }
     return(Content(new AjaxResult {
         state = ResultType.error.ToString(), message = "数据填写不完整!", data = null
     }.ToJson()));
 }
Esempio n. 21
0
        private void DeleteOrg_Click(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("Are you sure?", "Delete", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                OrgViewModel orVM = OrgBox.SelectedItem as OrgViewModel;
                orgService.Delete(orVM.OrgID);
                orgs = orgService.GetAll();
                OrgBox.ItemsSource    = orgs;
                clients               = clientService.GetAll();
                ClientBox.ItemsSource = clients;
                orders = orderService.GetAll();
                OrderBox.ItemsSource    = orders;
                payments                = paymentService.GetAll();
                PaymentGrid.ItemsSource = payments;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// 转换为树型
        /// </summary>
        /// <param name="orgs"></param>
        /// <returns></returns>
        private List <OrgViewModel> ToViewModel(IQueryable <Organization> orgs)
        {
            List <OrgViewModel> ovm = new List <OrgViewModel>();

            foreach (var item in orgs)
            {
                OrgViewModel ov = new OrgViewModel();
                ov.CreaterDate    = item.CreaterDate;
                ov.CreateUserCode = item.CreateUserCode;
                ov.OrgCode        = item.OrgCode;
                ov.OrgExplain     = item.OrgExplain;
                ov.OrgName        = item.OrgName;
                ov.ParentCode     = item.ParentCode;
                ov.UpdateDate     = item.UpdateDate;
                ov.UpdateUserCode = item.UpdateUserCode;
                ovm.Add(ov);
            }
            return(ovm);
        }
Esempio n. 23
0
        /// <summary>
        /// 获取机构信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public OrgViewModel GetOrgInfo(Guid ID)
        {
            var item = orgRository.Filter(t => t.OrgCode == ID).FirstOrDefault();

            if (item != null)
            {
                OrgViewModel ov = new OrgViewModel();
                ov.CreaterDate    = item.CreaterDate;
                ov.CreateUserCode = item.CreateUserCode;
                ov.OrgCode        = item.OrgCode;
                ov.OrgExplain     = item.OrgExplain;
                ov.OrgName        = item.OrgName;
                ov.ParentCode     = item.ParentCode;
                ov.UpdateDate     = item.UpdateDate;
                ov.UpdateUserCode = item.UpdateUserCode;
                return(ov);
            }
            return(null);
        }
Esempio n. 24
0
        private void AddOrg_Click(object sender, RoutedEventArgs e)
        {
            var           orVM   = new OrgViewModel();
            EditWindowOrg ew     = new EditWindowOrg(orVM);
            var           result = ew.ShowDialog();

            if (result == true)
            {
                orgService.Create(orVM);
                ew.Close();
                orgs = orgService.GetAll();
                OrgBox.ItemsSource    = orgs;
                clients               = clientService.GetAll();
                ClientBox.ItemsSource = clients;
                orders = orderService.GetAll();
                OrderBox.ItemsSource    = orders;
                payments                = paymentService.GetAll();
                PaymentGrid.ItemsSource = payments;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// 修改机构
        /// </summary>
        /// <param name="ovm"></param>
        /// <returns></returns>
        public AjaxResult Update(OrgViewModel ovm)
        {
            var org = orgRository.Find(t => t.OrgCode == ovm.OrgCode);

            if (org != null)
            {
                org.ParentCode     = ovm.ParentCode;
                org.OrgExplain     = ovm.OrgExplain;
                org.OrgName        = ovm.OrgName;
                org.UpdateDate     = DateTime.Now;
                org.UpdateUserCode = Guid.Parse(DLSession.GetCurrLoginCode());
                orgRository.Update(org);
                return(new AjaxResult {
                    state = ResultType.success.ToString(), message = "操作成功!", data = null
                });
            }
            return(new AjaxResult {
                state = ResultType.error.ToString(), message = "未找到机构!", data = null
            });
        }
Esempio n. 26
0
        public void TestInit()
        {
            RenewMockServices();

            MockUiDispatcherService.Setup(mock => mock.
                                          RunOnUiThread(It.IsAny <Action>()))
            .Callback <Action>(action =>
            {
                // Run whatever method is passed to MockUiDispatcherService.RunOnUiThread; do not delegate to the UI Dispatcher
                action();
            });

            _fakeTasExplorerViewModel = new TasExplorerViewModel(Services);
            _fakeCfInstanceViewModel  = new CfInstanceViewModel(FakeCfInstance, _fakeTasExplorerViewModel, Services, expanded: true);
            _sut = new OrgViewModel(FakeCfOrg, _fakeCfInstanceViewModel, _fakeTasExplorerViewModel, Services);

            _receivedEvents       = new List <string>();
            _sut.PropertyChanged += (sender, e) =>
            {
                _receivedEvents.Add(e.PropertyName);
            };
        }
Esempio n. 27
0
        private void ToTreeViewModel(List <OrgViewModel> ls, List <Organization> orgs, int Level, Guid ParentOrgCode)
        {
            foreach (var item in orgs.Where(t => t.ParentCode == ParentOrgCode))
            {
                OrgViewModel ov = new OrgViewModel();
                ov.CreaterDate    = item.CreaterDate;
                ov.CreateUserCode = item.CreateUserCode;
                ov.OrgCode        = item.OrgCode;
                ov.OrgExplain     = item.OrgExplain;
                ov.OrgName        = item.OrgName;
                ov.ParentCode     = item.ParentCode;
                ov.UpdateDate     = item.UpdateDate;
                ov.UpdateUserCode = item.UpdateUserCode;

                ov.level  = Level;
                ov.id     = item.OrgCode;
                ov.parent = item.ParentCode;
                if (orgs.Where(t => t.ParentCode == item.OrgCode).Count() > 0)
                {
                    ov.isLeaf   = false;
                    ov.expanded = true;
                }
                else
                {
                    ov.isLeaf   = true;
                    ov.expanded = false;
                }
                ov.loaded = true;

                ls.Add(ov);
                if (orgs.Where(t => t.ParentCode == item.OrgCode).Count() > 0)
                {
                    ToTreeViewModel(ls, orgs, Level + 1, item.OrgCode);
                }
            }
        }
        public ActionResult OrgSearch(string searchOrg, string by)
        {
            IQueryable <Org> orgs = db.Orgs.OrderBy(p => p.Name);

            //get rid of the None org
            orgs = orgs.Where(s => s.OrgId != 1);

            if (searchOrg != null)
            {
                if (by == "Name")
                {
                    orgs = orgs.Where(p => p.Name.Contains(searchOrg));
                }
                else if (by == "Focus")
                {
                    orgs = orgs.Where(p => p.Focus.Contains(searchOrg));
                }
            }

            var orgsList  = orgs.Take(1000).ToList();
            var viewModel = new OrgViewModel(orgs);

            return(PartialView(viewModel));
        }
Esempio n. 29
0
        public async Task FetchChildren_SetsAuthenticationRequiredToTrue_WhenOrgsRequestFailsBecauseOfInvalidRefreshToken()
        {
            _sut = new OrgViewModel(FakeCfOrg, _fakeCfInstanceViewModel, _fakeTasExplorerViewModel, Services, expanded: true);

            var fakeFailedResult =
                new DetailedResult <List <CloudFoundrySpace> >(succeeded: false, content: null, explanation: "junk", cmdDetails: FakeFailureCmdResult)
            {
                FailureType = FailureType.InvalidRefreshToken,
            };

            MockCloudFoundryService.Setup(mock => mock.
                                          GetSpacesForOrgAsync(_sut.Org, true, It.IsAny <int>()))
            .ReturnsAsync(fakeFailedResult);

            Assert.IsFalse(_sut.ParentTasExplorer.AuthenticationRequired);

            var result = await _sut.FetchChildren();

            Assert.IsTrue(_sut.ParentTasExplorer.AuthenticationRequired);

            MockErrorDialogService.Verify(mock => mock.
                                          DisplayErrorDialog(It.IsAny <string>(), It.IsAny <string>()),
                                          Times.Never);
        }
Esempio n. 30
0
        public ActionResult Register()
        {
            var viewModel = new OrgViewModel(db.Orgs);

            return(View(viewModel));
        }