public LocationView(LocationListViewModel model) { InitializeComponent(); Model = model; Location = Model.CurrentLocation; DataContext = Location; }
private void InitializeModels() { FilmModel = new FilmListViewModel(this); PersonModel = new PersonListViewModel(this); CountryModel = new CountryListViewModel(this); LocationModel = new LocationListViewModel(this); }
// GET: Location public ActionResult Index(string state, int page = 1, string search = null) { IEnumerable <Location> locs = repo.Locations .Where(l => state == null || l.State == state) .Where(l => search == null || l.Name.Contains(search) || l.City.Contains(search) || l.Address1.Contains(search)) .OrderBy(l => l.Name) .Skip((page - 1) * PageSize) .Take(PageSize); int count = locs.Count(); LocationListViewModel model = new LocationListViewModel { Locations = locs, PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = repo.Locations.Where(l => search == null || l.Name.Contains(search) || l.City.Contains(search) || l.Address1.Contains(search)).Where(e => e.State == state).Count() }, CurrentState = state }; if (Request.IsAjaxRequest()) { return(PartialView("LocationSummary", model)); } return(View(model)); }
public ActionResult Index() { using (var inspectionAppCTXT = new InspectionAppCTXT()) { var locationList = new LocationListViewModel { //Convert each Location to a LocationViewModel Locations = inspectionAppCTXT.Locations.Select(p => new LocationViewModel { LocationID = p.LocationID, LocationName = p.LocationName, LocationAddress = p.LocationAddress, LocationCity = p.LocationCity, LocationState = p.LocationState, LocationZip = p.LocationZip, LocationType = p.LocationType, LocationInspectionDate = p.LocationInspectionDate, LocationGrade = p.LocationGrade, }).ToList() }; // count how many records locationList.TotalLocations = locationList.Locations.Count; return(View(locationList)); } }
public ActionResult Index() { IIotContextBase icont = (iotContext)System.Web.HttpContext.Current.Session["iotcontext"]; string domainId = DomainSession.GetContextDomain(this.HttpContext); iotDomain d = icont.Domains.First(dm => dm.DomainName.Equals(domainId)); List <Location> locs = d.Locations.ToList(); LocationListViewModel model = new LocationListViewModel(locs); return(View(model)); }
public IActionResult CrudOperations(int page = 1) { var count = this.locationsService.GetAll <LocationViewModel>(int.MaxValue, 0).Count(); var locationsListModel = new LocationListViewModel { Locations = this.locationsService.GetAll <LocationViewModel>(10, (page - 1) * 10), CurrentPage = page, PagesCount = (int)Math.Ceiling((double)count / 10), }; return(this.View(string.Format(ViewPaths.CrudOperationsViewPath, "Locations"), locationsListModel)); }
public async Task <IActionResult> GetLocation() { string token = GetToken(); if (!TokenService.ValidateToken(token) || !TokenService.VerifDateExpiration(token)) { return(Unauthorized()); } User connectedUser = _authService.GetUserConnected(token); var listLocation = await _context.Location.Where(l => l.LocUserId == connectedUser.UserId).ToListAsync(); List <LocationListViewModel> locations = new List <LocationListViewModel>(); if (listLocation.Count > 0) { foreach (Location loc in listLocation) { LocationListViewModel locVM = new LocationListViewModel(); locVM.LocationId = loc.LocId; locVM.DateDebutResa = loc.LocDatestartlocation.ToString("dd/MM/yyyy"); locVM.DateFinResa = loc.LocDateendlocation.ToLocalTime().ToString("dd/MM/yyyy"); User user = _context.User.Where(u => u.UserId == loc.LocUserId).First(); locVM.UserFriendlyName = String.Format("{0} {1}", user.UserFirstname, user.UserName); Pole poleStart = _context.Pole.Where(p => p.PoleId == loc.LocPoleIdstart).First(); locVM.PoleDepart = poleStart.PoleName; Pole poleEnd = _context.Pole.Where(p => p.PoleId == loc.LocPoleIdend).First(); locVM.PoleDestination = poleEnd.PoleName; if (loc.LocVehId != null) { Vehicle vehicle = _context.Vehicle.Where(v => v.VehId == loc.LocVehId).First(); locVM.VehicleFriendlyName = String.Format("{0} {1}", vehicle.VehBrand, vehicle.VehModel); } else { locVM.VehicleFriendlyName = "Pas de vehicule associé"; } locVM.LocationState = Enums.GetLocationStateTrad(loc.LocState); locVM.LocationStateId = loc.LocState; locations.Add(locVM); } } return(Ok(locations.OrderByDescending(x => x.DateDebutResa).ToList())); }
/// <summary> /// Creates a new location list page /// </summary> public LocationListPage() { this.Title = "Location list"; this.InitializeComponent(); this.geolocationService = DependencyService.Get <IGeolocationService>(); this.BindingContext = this.viewModel = new LocationListViewModel(App.Settings); this.SetupToolbar(); Task.Run(this.InitPositionAsync); }
public void TestCtor() { // set up var appSettings = new AppSettings(); var viewModel = new LocationListViewModel(appSettings); Assert.IsTrue( viewModel.WaitForPropertyChange( nameof(viewModel.LocationList), TimeSpan.FromSeconds(10)), "waiting for property change must succeed"); // check Assert.IsTrue(viewModel.LocationList.Any(), "location list initially contains the default locations"); Assert.AreEqual(0, viewModel.FilterText.Length, "filter text is initially empty"); Assert.IsFalse(viewModel.AreAllLocationsFilteredOut, "as there is no filter text, no location was filtered out"); }
public ActionResult Suggest(string locationOrPostcode, bool openOnly = false) { var suggestions = TempData["LocationResults"] as SuggestionQueryResult; var searchMethod = TempData["SearchMethod"] as string; if (suggestions is null) { suggestions = _locationSearchService.SuggestLocationName(locationOrPostcode); } var result = new List <LocationViewModel>(); suggestions.Matches.ForEach(item => result.Add(new LocationViewModel(item.Text, item.LatLon))); var vm = new LocationListViewModel(result, _benchmarkBasketService.GetSchoolBenchmarkList(), locationOrPostcode, string.Empty, openOnly, searchMethod); return(View(vm)); }
//[AuthorizeUserAccessLevel(UserRole = "SuperAdmin,Admin,")] //[Filters.AuthorizeUserRole] public ActionResult AdminIndex() { try { var locations = _locationmanager.GetAll(); var llvm = new LocationListViewModel { Locations = locations }; //ViewData["Username"] = User.Identity.Name; return(View(llvm)); } catch (Exception ex) { //Log exception return(View(ex.Message, "Error")); } }
public async Task <List <LocationListViewModel> > GetAllLocationInWaitingAsync() { List <Location> listLocation = await _context.Location.Where(x => x.LocState == (sbyte)Enums.LocationState.Asked).ToListAsync(); List <LocationListViewModel> locations = new List <LocationListViewModel>(); if (listLocation.Count > 0) { foreach (Location loc in listLocation) { LocationListViewModel locVM = new LocationListViewModel(); locVM.LocationId = loc.LocId; locVM.DateDebutResa = loc.LocDatestartlocation.ToString("dd/MM/yyyy"); locVM.DateFinResa = loc.LocDateendlocation.ToString("dd/MM/yyyy"); User user = _context.User.Where(u => u.UserId == loc.LocUserId).First(); locVM.UserFriendlyName = String.Format("{0} {1}", user.UserFirstname, user.UserName); Pole poleStart = _context.Pole.Where(p => p.PoleId == loc.LocPoleIdstart).First(); locVM.PoleDepart = poleStart.PoleName; Pole poleEnd = _context.Pole.Where(p => p.PoleId == loc.LocPoleIdend).First(); locVM.PoleDestination = poleEnd.PoleName; if (loc.LocVehId != null) { Vehicle vehicle = _context.Vehicle.Where(v => v.VehId == loc.LocVehId).First(); locVM.VehicleFriendlyName = String.Format("{0} {1}", vehicle.VehBrand, vehicle.VehModel); } else { locVM.VehicleFriendlyName = "Pas de vehicule associé"; } locVM.LocationState = GetLocationStateTrad(loc.LocState); locVM.LocationStateId = loc.LocState; locations.Add(locVM); } } return(locations.OrderByDescending(x => x.LocationState).ToList()); }
public void Can_Send_Pagination_View_Model() { // Arrange Mock <ILocationRepository> mock = new Mock <ILocationRepository>(); mock.Setup(m => m.Locations).Returns(new List <Location> { new Location { Id = 1, Name = "L1" }, new Location { Id = 2, Name = "L2" }, new Location { Id = 3, Name = "L3" }, new Location { Id = 4, Name = "L4" }, new Location { Id = 5, Name = "L5" } }); // Arrange LocationsController controller = new LocationsController(mock.Object); controller.PageSize = 3; ViewResult indx = (ViewResult)controller.Index(null, 2); //Act LocationListViewModel result = (LocationListViewModel)indx.Model; //Assert PagingInfo pageInfo = result.PagingInfo; Assert.AreEqual(pageInfo.CurrentPage, 2); Assert.AreEqual(pageInfo.ItemsPerPage, 3); Assert.AreEqual(pageInfo.TotalItems, 5); Assert.AreEqual(pageInfo.TotalPages, 2); }
public void Can_Locations_Paginate() { // Arrange Mock <ILocationRepository> mock = new Mock <ILocationRepository>(); mock.Setup(m => m.Locations).Returns(new List <Location> { new Location { Id = 1, Name = "L1" }, new Location { Id = 2, Name = "L2" }, new Location { Id = 3, Name = "L3" }, new Location { Id = 4, Name = "L4" }, new Location { Id = 5, Name = "L5" } }); LocationsController controller = new LocationsController(mock.Object); controller.PageSize = 3; ViewResult indx = (ViewResult)controller.Index(null, 2); //Act LocationListViewModel result = (LocationListViewModel)indx.Model; //Assert Location[] prodArray = result.Locations.ToArray(); Assert.IsTrue(prodArray.Length == 2); Assert.AreEqual(prodArray[0].Name, "L4"); Assert.AreEqual(prodArray[1].Name, "L5"); }
public void TestCtor() { // set up var appSettings = new AppSettings(); var viewModel = new LocationListViewModel(appSettings); var propertyChangedEvent = new ManualResetEvent(false); viewModel.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(viewModel.LocationList)) { propertyChangedEvent.Set(); } }; propertyChangedEvent.WaitOne(); // check Assert.IsTrue(viewModel.LocationList.Any(), "location list initially contains the default locations"); Assert.AreEqual(0, viewModel.FilterText.Length, "filter text is initially empty"); Assert.IsFalse(viewModel.AreAllLocationsFilteredOut, "as there is no filter text, no location was filtered out"); }
public IActionResult Index() { List <LocationListViewModel> locations = LocationListViewModel.GetLocations(repositoryFactory); return(View(locations)); }
public MainWindowViewModel() { NavCommand = new RelayCommand <string>(OnNav); _ageRangeListViewModel = ContainerHelper.Container.Resolve <AgeRangeListViewModel>(); // _ageRangeFormViewModel = ContainerHelper.Container.Resolve <AgeRangeFormViewModel>(); _coachListViewModel = ContainerHelper.Container.Resolve <CoachListViewModel>(); //_coachDetailViewModel = ContainerHelper.Container.Resolve<CoachDetailViewModel>(); _coachFormViewModel = ContainerHelper.Container.Resolve <CoachFormViewModel>(); _genderListViewModel = ContainerHelper.Container.Resolve <GenderListViewModel>(); //_genderDetailViewModel = ContainerHelper.Container.Resolve<GenderDetailViewModel>(); _genderFormViewModel = ContainerHelper.Container.Resolve <GenderFormViewModel>(); _guardianListViewModel = ContainerHelper.Container.Resolve <GuardianListViewModel>(); //_guardianDetailViewModel = ContainerHelper.Container.Resolve<GuardianDetailViewModel>(); _guardianFormViewModel = ContainerHelper.Container.Resolve <GuardianFormViewModel>(); _locationListViewModel = ContainerHelper.Container.Resolve <LocationListViewModel>(); //_locationDetailViewModel = ContainerHelper.Container.Resolve<LocationDetailViewModel>(); _locationFormViewModel = ContainerHelper.Container.Resolve <LocationFormViewModel>(); _organizerListViewModel = ContainerHelper.Container.Resolve <OrganizerListViewModel>(); //_organizerDetailViewModel = ContainerHelper.Container.Resolve<OrganizerDetailViewModel>(); _organizerFormViewModel = ContainerHelper.Container.Resolve <OrganizerFormViewModel>(); _playerListViewModel = ContainerHelper.Container.Resolve <PlayerListViewModel>(); //_playerDetailViewModel = ContainerHelper.Container.Resolve<PlayerDetailViewModel>(); _playerFormViewModel = ContainerHelper.Container.Resolve <PlayerFormViewModel>(); _scheduleListViewModel = ContainerHelper.Container.Resolve <ScheduleListViewModel>(); //_scheduleDetailViewModel = ContainerHelper.Container.Resolve<ScheduleDetailViewModel>(); _scheduleFormViewModel = ContainerHelper.Container.Resolve <ScheduleFormViewModel>(); _sportListViewModel = ContainerHelper.Container.Resolve <SportListViewModel>(); //_sportDetailViewModel = ContainerHelper.Container.Resolve<SportDetailViewModel>(); _sportFormViewModel = ContainerHelper.Container.Resolve <SportFormViewModel>(); _sportsEventListViewModel = ContainerHelper.Container.Resolve <SportsEventListViewModel>(); //_sportsEventDetailViewModel = ContainerHelper.Container.Resolve<SportsEventDetailViewModel>(); _sportsEventFormViewModel = ContainerHelper.Container.Resolve <SportsEventFormViewModel>(); //_ageRangeListViewModel.DetailAgeRangeRequested += NavToAgeRangeDetail; _ageRangeListViewModel.AddAgeRangeRequested += NavToAddAgeRange; _ageRangeListViewModel.EditAgeRangeRequested += NavToEditAgeRange; _ageRangeFormViewModel.Done += NavToAgeRangeList; //_coachListViewModel.DetailCoachRequested += NavToCoachDetail; _coachListViewModel.AddCoachRequested += NavToAddCoach; _coachListViewModel.EditCoachRequested += NavToEditCoach; _coachFormViewModel.Done += NavToCoachList; //_genderListViewModel.DetailGenderRequested += NavToGenderDetail; _genderListViewModel.AddGenderRequested += NavToAddGender; _genderListViewModel.EditGenderRequested += NavToEditGender; _genderFormViewModel.Done += NavToGenderList; //_guardianListViewModel.DetailGuardianRequested += NavToGuardianDetail; _guardianListViewModel.AddGuardianRequested += NavToAddGuardian; _guardianListViewModel.EditGuardianRequested += NavToEditGuardian; _guardianFormViewModel.Done += NavToGuardianList; //_locationListViewModel.DetailLocationRequested += NavToLocationDetail; _locationListViewModel.AddLocationRequested += NavToAddLocation; _locationListViewModel.EditLocationRequested += NavToEditLocation; _locationFormViewModel.Done += NavToLocationList; //_organizerListViewModel.DetailOrganizerRequested += NavToOrganizerDetail; _organizerListViewModel.AddOrganizerRequested += NavToAddOrganizer; _organizerListViewModel.EditOrganizerRequested += NavToEditOrganizer; _organizerFormViewModel.Done += NavToOrganizerList; //_playerListViewModel.DetailPlayerRequested += NavToPlayerDetail; _playerListViewModel.AddPlayerRequested += NavToAddPlayer; _playerListViewModel.EditPlayerRequested += NavToEditPlayer; _playerFormViewModel.Done += NavToPlayerList; //_scheduleListViewModel.DetailScheduleRequested += NavToScheduleDetail; _scheduleListViewModel.AddScheduleRequested += NavToAddSchedule; _scheduleListViewModel.EditScheduleRequested += NavToEditSchedule; _scheduleFormViewModel.Done += NavToScheduleList; //_sportListViewModel.DetailSportRequested += NavToSportDetail; _sportListViewModel.AddSportRequested += NavToAddSport; _sportListViewModel.EditSportRequested += NavToEditSport; _sportFormViewModel.Done += NavToSportList; //_sportsEventListViewModel.DetailSportsEventRequested += NavToSportsEventDetail; _sportsEventListViewModel.AddSportsEventRequested += NavToAddSportsEvent; _sportsEventListViewModel.EditSportsEventRequested += NavToEditSportsEvent; _sportsEventFormViewModel.Done += NavToSportsEventList; }
public IActionResult Index() { List <LocationListViewModel> viewModelLocations = LocationListViewModel.GetLocationListViewModel(context); return(View(viewModelLocations)); }
/// <summary> /// Constructor to subscription of events for overall program navigation. /// </summary> public MainWindowViewModel(IUnitOfWork unitOfWork) { NavCommand = new RelayCommand <string>(OnNav); //View Model Initializations _loginViewModel = new LoginViewModel(unitOfWork, DialogCoordinator.Instance); _homeDashboardViewModel = new HomeDashboardViewModel(); _inventoryDashboardViewModel = new InventoryDashboardViewModel(); _workCycleListViewModel = new WorkCycleListViewModel(unitOfWork, DialogCoordinator.Instance); _addEditWorkingCycleViewModel = new AddEditWorkingCycleViewModel(unitOfWork, DialogCoordinator.Instance); _purchaseOrderListViewModel = new PurchaseOrderListViewModel(unitOfWork, DialogCoordinator.Instance); _addEditPurchaseOrderListViewModel = new AddEditPurchaseOrderViewModel(unitOfWork, DialogCoordinator.Instance); _supplierListViewModel = new SupplierListViewModel(unitOfWork, DialogCoordinator.Instance); _rawMaterialListViewModel = new RawMaterialListViewModel(unitOfWork, DialogCoordinator.Instance); _rawMaterialCategoryListViewModel = new RawMaterialCategoryListViewModel(unitOfWork, DialogCoordinator.Instance); _locationListViewModel = new LocationListViewModel(unitOfWork, DialogCoordinator.Instance); _inventorySettingViewModel = new InventorySettingViewModel(unitOfWork, DialogCoordinator.Instance); _procurePurchaseOrderViewModel = new ProcurePurchaseOrderViewModel(unitOfWork, DialogCoordinator.Instance); //Set Login context SetLoginContext(); //Event Subscriptions _loginViewModel.LoginRequested += NavToHomeDashboard; _homeDashboardViewModel.LogoutRequested += NavToLoginView; _homeDashboardViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _inventoryDashboardViewModel.HomeDashboardRequested += NavToHomeDashboard; _inventoryDashboardViewModel.LogoutRequested += NavToLoginView; _inventoryDashboardViewModel.ManageWorkCyclesRequsted += NavToManageWorkCycles; _inventoryDashboardViewModel.PurchaseOrdersListsViewRequested += NavToPurchaseOrdersListView; _inventoryDashboardViewModel.SupplierListViewRequested += NavToSupplierListView; _inventoryDashboardViewModel.RawMaterialListViewRequested += NavToRawMaterialsListView; _inventoryDashboardViewModel.RawMaterialCategoryListViewRequested += NavToRawMaterialCategoryListView; _inventoryDashboardViewModel.LocationListViewRequested += NavToLocationListView; _inventoryDashboardViewModel.InventorySettingViewRequested += NavToInventorySettingView; _inventoryDashboardViewModel.ProcurePurchaseOrderViewRequested += NavToProcurePurchaseOrderView; _workCycleListViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _workCycleListViewModel.LogoutRequested += NavToLoginView; _workCycleListViewModel.HomeViewRequested += NavToHomeDashboard; _workCycleListViewModel.AddWorkCycleRequested += NavToAddWorkCycleView; _workCycleListViewModel.EditWorkCycleRequested += NavToEditWorkCycleView; _addEditWorkingCycleViewModel.LogoutRequested += NavToLoginView; _addEditWorkingCycleViewModel.ManageWorkCyclesRequsted += NavToManageWorkCycles; _addEditWorkingCycleViewModel.Done += NavToManageWorkCycles; _purchaseOrderListViewModel.LogoutRequested += NavToLoginView; _purchaseOrderListViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _purchaseOrderListViewModel.HomeViewRequested += NavToHomeDashboard; _purchaseOrderListViewModel.AddPurchaseOrderRequested += NavToAddPurchaseOrder; _purchaseOrderListViewModel.EditPurchaseOrderRequested += NavToEditPurchaseOrder; _addEditPurchaseOrderListViewModel.LogoutRequested += NavToLoginView; _addEditPurchaseOrderListViewModel.HomeViewRequested += NavToHomeDashboard; _addEditPurchaseOrderListViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _addEditPurchaseOrderListViewModel.PurchaseOrderListRequested += NavToPurchaseOrdersListView; _addEditPurchaseOrderListViewModel.Done += NavToPurchaseOrdersListView; _supplierListViewModel.LogoutRequested += NavToLoginView; _supplierListViewModel.HomeViewRequested += NavToHomeDashboard; _supplierListViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _rawMaterialListViewModel.LogoutRequested += NavToLoginView; _rawMaterialListViewModel.HomeViewRequested += NavToHomeDashboard; _rawMaterialListViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _rawMaterialCategoryListViewModel.LogoutRequested += NavToLoginView; _rawMaterialCategoryListViewModel.HomeViewRequested += NavToHomeDashboard; _rawMaterialCategoryListViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _locationListViewModel.LogoutRequested += NavToLoginView; _locationListViewModel.HomeViewRequested += NavToHomeDashboard; _locationListViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _inventorySettingViewModel.LogoutRequested += NavToLoginView; _inventorySettingViewModel.HomeViewRequested += NavToHomeDashboard; _inventorySettingViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; _procurePurchaseOrderViewModel.LogoutRequested += NavToLoginView; _procurePurchaseOrderViewModel.HomeViewRequested += NavToHomeDashboard; _procurePurchaseOrderViewModel.InventoryDashboardRequested += NavigateToInventoryDashboard; }