Exemplo n.º 1
0
        // Get Info bill payment by id
        public async Task <PagedViewModel <BillRequest> > GetByIDMotel(int value)
        {
            if (!IDmotel.Contains(value))
            {
                return(null);
            }
            var result = from c in _context.InforBills
                         where c.IdMotel == value
                         select c;
            var data = new PagedViewModel <BillRequest>()
            {
                Items = result.Select(x => new BillRequest()
                {
                    ElectricBill = x.ElectricBill,
                    Id           = x.IdInforBill,
                    IdMotel      = x.IdMotel,
                    MonthRent    = x.MonthRent,
                    ParkingFee   = x.ParkingFee,
                    RoomBil      = x.RoomBill,
                    WaterBill    = x.WaterBill,
                    WifiBill     = x.WifiBill,
                    Payment      = x.Payment,
                    DateCreate   = x.DateCreate,
                }).ToList(),
                TotalRecord = await result.CountAsync(),
            };

            return(data);
        }
Exemplo n.º 2
0
        public async Task <int> GetByIdUser(string iduser)
        {
            if (!IDcustomer.Contains(iduser))
            {
                return(0);
            }
            var request = from c in _context.Rents
                          where c.IDcustomer == iduser
                          select c;
            PagedViewModel <RentRequest> data = new PagedViewModel <RentRequest>()
            {
                Items = request.Select(x => new RentRequest()
                {
                    IdRent     = x.IdRent,
                    IDcustomer = x.IDcustomer,
                    End        = x.End.Value,
                    idMotel    = x.idMotel,
                    Start      = x.Start
                }).ToList(),
                TotalRecord = await request.CountAsync(),
            };
            var kq = data.Items;

            return((int)kq.FirstOrDefault().idMotel);
        }
Exemplo n.º 3
0
 public void SetupWithOneParameterReturnsOrderedSequence()
 {
     var query = MockRepositoryMethod();
     var model = new PagedViewModel<MockEntity> { Query = MockRepositoryMethod(), GridSortOptions = new GridSortOptions { Direction = SortDirection.Descending } }.Setup(m => m.IntProp);
     Assert.IsTrue(model.PagedList.Count() == query.Count());
     Assert.AreEqual(query.First().IntProp, model.PagedList.Last().IntProp);
 }
Exemplo n.º 4
0
        public async Task <PagedViewModel <FamilyRequest> > GetByUserID(string userid)
        {
            var result = from c in _context.Families
                         where c.User == userid
                         select c;

            var data = new PagedViewModel <FamilyRequest>()
            {
                Items = result.Select(x => new FamilyRequest()
                {
                    Address        = x.Address,
                    Birthday       = x.Birthday,
                    FirstName      = x.FirstName,
                    Id             = x.Id,
                    Identification = x.Identification,
                    LastName       = x.LastName,
                    PhoneNumber    = x.PhoneNumber,
                    Sex            = x.Sex,
                    User           = x.User
                }).ToList(),
                TotalRecord = await result.CountAsync(),
            };

            return(data);
        }
Exemplo n.º 5
0
        private PagedViewModel <EmployeeModel> GetEmployeeDetails(string employeeName, string salary, int?page = null)
        {
            IEnumerable <EmployeeModel> data;

            if (string.IsNullOrEmpty(employeeName) && string.IsNullOrEmpty(salary))
            {
                data = _employeeService.employee_List().OrderBy(o => o.Salary);
            }
            else
            {
                if (!string.IsNullOrEmpty(employeeName))
                {
                    data = _employeeService.employee_List().OrderBy(o => o.Salary)
                           .Where(o => o.FirstName.Trim().ToLower().Contains(employeeName.Trim().ToLower()) ||
                                  o.Salary.Trim().ToLower() == salary.Trim().ToLower());
                }
                else
                {
                    data = _employeeService.employee_List().OrderBy(o => o.Salary)
                           .Where(o => o.Salary.Trim().ToLower() == salary.Trim().ToLower());
                }
            }
            var model = new PagedViewModel <EmployeeModel>
            {
                Page  = page,
                Query = data
            }.Setup();

            return(model);
        }
Exemplo n.º 6
0
        public async Task <PagedViewModel <FamilyRequest> > GetByFirstName(string name)
        {
            var result = from c in _context.Families
                         where c.FirstName.Contains(name)
                         orderby c.Id
                         select c;
            PagedViewModel <FamilyRequest> list = new PagedViewModel <FamilyRequest>()
            {
                Items = result.Select(x => new FamilyRequest()
                {
                    Address        = x.Address,
                    Birthday       = x.Birthday,
                    FirstName      = x.FirstName,
                    Id             = x.Id,
                    Identification = x.Identification,
                    LastName       = x.LastName,
                    PhoneNumber    = x.PhoneNumber,
                    Sex            = x.Sex,
                    User           = x.User
                }).ToList(),
                TotalRecord = await result.CountAsync(),
            };

            return(list);
        }
        protected virtual async Task <PagedViewModel <TViewModel> > GetFilteredPaged(string includeProperties = null,
                                                                                     int page     = 1,
                                                                                     int pageSize = WebApiConstants.DefaultPageSize,
                                                                                     string sort  = null,
                                                                                     string dir   = "",
                                                                                     Expression <Func <TModel, bool> > filter = null)
        {
            var sortQuery = string.IsNullOrEmpty(sort) ? null : $"{sort} {dir}";

            var models = await _repository
                         .Get(includeProperties : includeProperties, filter : filter, orderBy : sortQuery ?? _defaultOrderByProperty)
                         .ToPagedListAsync(page, pageSize);

            var abstractViewModels = _mapper.Map <IEnumerable <TModel>, IEnumerable <TViewModel> >(models);
            var pagedVm            = new StaticPagedList <TViewModel>(abstractViewModels, models.PageNumber, models.PageSize, models.TotalItemCount);

            var result = new PagedViewModel <TViewModel>
            {
                PagedList = pagedVm,
                PageCount = pagedVm.PageCount,
                ItemCount = pagedVm.TotalItemCount,
                PageSize  = pageSize
            };

            return(result);
        }
        public ActionResult List(int page = 1)
        {
            LoadCountriesIntoViewData();

            List <HomeInputModel> filteredItems = Items;


            var qName    = Request.QueryString["Name"];
            var qCountry = Request.QueryString["Country"];

            bool filtered = false;

            if (!String.IsNullOrWhiteSpace(qName))
            {
                filteredItems = Items.Where(x => x.Name == qName).ToList();
                filtered      = true;
            }
            if (!String.IsNullOrWhiteSpace(qCountry))
            {
                filteredItems = Items.Where(x => x.Country == int.Parse(qCountry)).ToList();
                filtered      = true;
            }

            var take = PagedViewModel.DefaultPagesize;
            var skip = (page - 1) * take;

            var viewModel =
                new PagedViewModel(
                    filteredItems.Skip(skip).Take(take),
                    filteredItems.Count, page, "Users");

            viewModel.Filtered = filtered;
            return(View("Index", viewModel));
        }
Exemplo n.º 9
0
        public async Task <PagedViewModel <RoleViewModel> > GetPaged(int page                 = 1,
                                                                     int pageSize             = WebApiConstants.DefaultPageSize,
                                                                     string s                 = "",
                                                                     string sort              = "Name",
                                                                     string dir               = "",
                                                                     string includeProperties = "")
        {
            var sortString = string.IsNullOrEmpty(sort) ? null : $"{sort} {dir}";

            var roles = await GetRolesAsync(sortString, includeProperties, s);

            var rolesViewModel = _mapper.Map <IEnumerable <ApplicationRole>, IEnumerable <RoleViewModel> >(roles);

            var pagedList = await rolesViewModel.ToPagedListAsync(page, pageSize);

            var pagedModel = new PagedViewModel <RoleViewModel>
            {
                PagedList = pagedList,
                PageCount = pagedList.PageCount,
                ItemCount = pagedList.TotalItemCount,
                PageSize  = pageSize
            };

            return(pagedModel);
        }
        public ActionResult List(int page = 1)
        {
            LoadCountriesIntoViewData();

            List<HomeInputModel> filteredItems = Items;

            
            var qName = Request.QueryString["Name"];
            var qCountry = Request.QueryString["Country"];

            bool filtered = false;

            if (!String.IsNullOrWhiteSpace(qName))
            {
                filteredItems = Items.Where(x => x.Name == qName).ToList();
                filtered = true;
            }
            if (!String.IsNullOrWhiteSpace(qCountry))
            {
                filteredItems = Items.Where(x => x.Country == int.Parse(qCountry)).ToList();
                filtered = true;
            }

            var take = PagedViewModel.DefaultPagesize;
            var skip = (page - 1)*take;

            var viewModel =
                new PagedViewModel(
                    filteredItems.Skip(skip).Take(take),
                    filteredItems.Count, page, "Users");

            viewModel.Filtered = filtered;
            return View("Index", viewModel);
        }
        public void Counter_ByDefault_ReturnsCounter(IEnumerable <int> dummy)
        {
            var counter = BuildPageCounter.AValidOne().Please();
            var sut     = new PagedViewModel <int>(counter, dummy.AsQueryable());

            sut.Counter.Should().Be(counter);
        }
Exemplo n.º 12
0
        // remember test
        public async Task <string> GetByIDMotel(int id)
        {
            if (!IDMotel.Contains(id))
            {
                return(null);
            }
            var request = from c in _context.Rents
                          where c.idMotel == id
                          select c;
            PagedViewModel <RentRequest> data = new PagedViewModel <RentRequest>()
            {
                Items = request.Select(x => new RentRequest()
                {
                    IdRent     = x.IdRent,
                    IDcustomer = x.IDcustomer,
                    End        = x.End.Value,
                    idMotel    = x.idMotel,
                    Start      = x.Start
                }).ToList(),
                TotalRecord = await request.CountAsync(),
            };
            var kq = data.Items;

            return(kq.FirstOrDefault().IDcustomer.ToString());
        }
 public ActionResult Advance(string account, string originator, string seller, string investor, string columnToSort, string sortDirection,GridSortOptions gridSortOptions, int? page)
 {
     if (Request.IsAjaxRequest())
     {
         gridSortOptions.Column = columnToSort;
         gridSortOptions.Direction = (sortDirection == "ASC") ? MvcContrib.Sorting.SortDirection.Ascending : MvcContrib.Sorting.SortDirection.Descending;
     }
     if (account == "account #")
         account = "";
     if (originator == "originator")
         originator = "";
     if (seller == "seller")
         seller = "";
     if (investor == "investor")
         investor = "";
     var dataQueries = new DataQueries();
     IQueryable<SearchResult> results = dataQueries.GetSearchResults(account, originator, seller, investor);
     //return PartialView("_BasicPartial", results);
     var pagedViewModel = new PagedViewModel<SearchResult>
     {
         ViewData = ViewData,
         Query = results,
         GridSortOptions = gridSortOptions,
         DefaultSortColumn = "ACCOUNT",
         Page = page,
         PageSize = 20,
     }
     .Setup();
     if (Request.IsAjaxRequest())
         return PartialView("_BasicPartial",pagedViewModel);
     return View("Basic",pagedViewModel);
 }
Exemplo n.º 14
0
        // Get infobil payment
        public async Task <PagedViewModel <BillRequest> > GetPaymentDone()
        {
            var result = from c in _context.InforBills
                         where c.Payment == true && c.DatePay != null
                         select c;
            var data = new PagedViewModel <BillRequest>()
            {
                Items = result.Select(x => new BillRequest()
                {
                    ElectricBill = x.ElectricBill,
                    Id           = x.IdInforBill,
                    IdMotel      = x.IdMotel,
                    MonthRent    = x.MonthRent,
                    ParkingFee   = x.ParkingFee,
                    RoomBil      = x.RoomBill,
                    WaterBill    = x.WaterBill,
                    WifiBill     = x.WifiBill,
                    Payment      = x.Payment,
                    DateCreate   = x.DateCreate,
                }).ToList(),
                TotalRecord = await result.CountAsync(),
            };

            return(data);
        }
Exemplo n.º 15
0
 public static PagedViewModel <RequestLogViewModel> ToViewModel(this PagedViewModel <RequestLog> pagedLogs)
 {
     return(new PagedViewModel <RequestLogViewModel>(pagedLogs)
     {
         Data = pagedLogs.Data.ToViewModel()
     });
 }
 public ActionResult Basic(string basicSearchVal, string columnToSort, string sortDirection, GridSortOptions gridSortOptions, int? page)
 {
     if (Request.IsAjaxRequest())
     {
         gridSortOptions.Column = columnToSort;
         gridSortOptions.Direction = (sortDirection == "ASC") ? MvcContrib.Sorting.SortDirection.Ascending : MvcContrib.Sorting.SortDirection.Descending;
     }
     var dataQueries = new DataQueries();
     IQueryable<SearchResult> results = dataQueries.GetSearchResults(basicSearchVal);
     //return PartialView("_BasicPartial", results);
     var pagedViewModel = new PagedViewModel<SearchResult>
     {
         ViewData = ViewData,
         Query = results,
         GridSortOptions = gridSortOptions,
         DefaultSortColumn = "ACCOUNT",
         Page = page,
         PageSize = 50,
     }
     .Setup();
     if (Request.IsAjaxRequest())
         return PartialView("_BasicPartial", pagedViewModel);
     return View(pagedViewModel);
     //return PartialView("_BasicPartial",pagedViewModel);
 }
Exemplo n.º 17
0
        protected AbstractPanelModel(PagedViewModel model)
        {
            Model = model;

            _stateHandler = new InstallationStateHandler(
                Model.Dispatcher,
                new Dictionary<InstallationState, Action>
                    {
                        {InstallationState.Applying, ConfigureApplying},
                        {InstallationState.InstallApplied, ConfigureInstallApplied},
                        {InstallationState.RemoveApplied, ConfigureRemoveApplied},
                        {InstallationState.RepairApplied, ConfigureRepairApplied},
                        {InstallationState.DetectedPresent, ConfigureStart},
                        {InstallationState.DetectedAbsent, ConfigureInstall},
                        {InstallationState.DetectedNewer,  ConfigureNewer},
                        {InstallationState.DetectedOlder, ConfigureOlder},
                        {InstallationState.Initializing, ConfigureInitializing},
                        {InstallationState.Failed, ConfigureFailed},
                        {InstallationState.LaunchingNewInstall, ConfigureLaunchingNew},
                        {InstallationState.LaunchingAlreadyInstalled, ConfigureLaunchingCurrent},
                        {InstallationState.Cancelling, Cancelling},
                        {InstallationState.ShowingRemoveOptions, ConfigureShowRemoveOptions},
                        {InstallationState.RunningExternal, ConfigureRunningExternal},
                        {InstallationState.AskingExternalIssueRetry, ConfigureAskExternalRetry},
                        {InstallationState.AskingCancel, ConfigureAskCancel}
                     });

            Model.PropertyChanged += RootPropertyChanged;
        }
Exemplo n.º 18
0
        protected virtual PagedViewModel <EmployeeListViewModel> GetFilteredPaged(
            string includeProperties = null, int page = 1, int pageSize = ConstWebApi.DefaultPageSize,
            string sort = null, string dir            = "", Expression <Func <ApplicationUser, bool> > filter = null)
        {
            var isAdmin = _permissionService.UserHasPermission(GetUserAndOrganization(), AdministrationPermissions.ApplicationUser);

            string sortQuery = string.IsNullOrEmpty(sort) ? null : $"{sort} {dir}";

            IPagedList <ApplicationUser> models = _applicationUserRepository.Get(
                includeProperties: includeProperties, filter: filter, orderBy: sortQuery ?? null)
                                                  .Where(_roleService.ExcludeUsersWithRole(Roles.NewUser))
                                                  .ToPagedList(page, pageSize);

            var pagedVM = new StaticPagedList <EmployeeListViewModel>(_mapper.Map <IEnumerable <ApplicationUser>, IEnumerable <EmployeeListViewModel> >(models), models.PageNumber, models.PageSize, models.TotalItemCount);

            if (!isAdmin)
            {
                foreach (var model in pagedVM)
                {
                    model.BirthDay    = BirthdayDateTimeHelper.RemoveYear(model.BirthDay);
                    model.PhoneNumber = null;
                }
            }

            var result = new PagedViewModel <EmployeeListViewModel>
            {
                PagedList = pagedVM,
                PageCount = pagedVM.PageCount,
                ItemCount = pagedVM.TotalItemCount,
                PageSize  = pageSize
            };

            return(result);
        }
Exemplo n.º 19
0
    private async Task <PagedViewModel <DiaryRuntime> > GetViewModel(int page, int?year, int?month)
    {
        PagedViewModel <DiaryRuntime> viewModel = null;
        const int itemsPerPage = 8;
        var       request      = new DiaryGrpcRequest {
            Year = year, Month = month
        };
        var response = await _diaryGrpcService.GetDiaryDatesAsync(request);

        if (response.IsOk)
        {
            viewModel = new PagedViewModel <DiaryRuntime>(page, response.DiaryDates?.Count ?? 0, itemsPerPage)
            {
                Url = Request.Path
            };
            request.Count          = itemsPerPage;
            request.ExtractRuntime = true;
            request.Offset         = (viewModel.CurrentPage - 1) * itemsPerPage;
            response = await _diaryGrpcService.GetDiariesAsync(request);

            if (response.IsOk)
            {
                response.DiaryRuntimeList ??= new List <DiaryRuntime>();
                foreach (var diaryRuntime in response.DiaryRuntimeList)
                {
                    viewModel.Items.Add(diaryRuntime);
                }
            }
        }

        return(viewModel);
    }
        public void Items_WhenNull_ReturnEmptyAndNotNull()
        {
            var dummy = BuildPageCounter.AValidOne().Please();
            var sut   = new PagedViewModel <int>(dummy, null);

            sut.ItemsInThePage.Should().BeEmpty().And.NotBeNull();
        }
Exemplo n.º 21
0
 public void SetupWithTwoColumnNamesReturnsOrderedSequence()
 {
     var query = MockRepositoryMethod();
     var model = new PagedViewModel<MockEntity> { Query = MockRepositoryMethod(), GridSortOptions = new GridSortOptions { Direction = SortDirection.Ascending } }
         .SetupByNames("IntProp", "StringProp");
     Assert.IsTrue(model.PagedList.Count() == query.Count());
     Assert.AreEqual(query.First().IntProp, model.PagedList.Skip(1).First().IntProp);
 }
Exemplo n.º 22
0
        public DynamicShowExternalOptionsButtonModel(PagedViewModel model)
            : base(model)
        {
            if (model.ExternalEngine == null  || !model.ExternalEngine.IsValid)
                Command = new RelayCommand(param => Model.BaseModel.Plan(InstallActions.Remove));

            Command = new RelayCommand(param => Model.InstallationState = InstallationState.ShowingRemoveOptions);
        }
Exemplo n.º 23
0
 protected AbstractPageModel(Page page, PagedViewModel model)
 {
     Model = model;
     Page = page;
     Foreground = Model.Foreground;
     Background = Model.Background;
     Page.DataContext = this;
 }
Exemplo n.º 24
0
        //GET All Paging
        public async Task <PagedViewModel <BillRequest> > GetAllPaging()
        {
            #region need fix all
            ////1. Select join
            //var query = from c in _context.InforBills
            //            join mr in _context.MotelRooms on c.IdMotel equals mr.idMotel
            //            select new { c, mr };

            ////2.Filter
            //if (!String.IsNullOrEmpty(request.kw))
            //    query = query.Where(x => x.mr.NameRoom.Contains(request.kw));

            ////3.Paging
            //int totalRow = await query.CountAsync();
            //var data = await query.Skip((request.PIndex - 1) * request.PSize)
            //    .Take(request.PSize)
            //    .Select(x => new BillPaymentRequest()
            //    {
            //        Id = x.c.IdInforBill,
            //        ElectricBill = x.c.ElectricBill,
            //        MonthRent = x.c.MonthRent,
            //        ParkingFee = x.c.ParkingFee,
            //        RoomBil = x.c.RoomBill,
            //        WaterBill = x.c.WaterBill,
            //        WifiBill = x.c.WifiBill
            //    }).ToListAsync();

            ////4. select and projection
            //var pageResult = new PagedViewModel<BillPaymentViewModel>()
            //{
            //    TotalRecord = totalRow,
            //    Items = data
            //};
            //return pageResult;
            #endregion
            var request = from c in _context.InforBills
                          orderby c.IdInforBill
                          select c;

            PagedViewModel <BillRequest> list = new PagedViewModel <BillRequest>()
            {
                Items = request.Select(x => new BillRequest()
                {
                    ElectricBill = x.ElectricBill,
                    Id           = x.IdInforBill,
                    IdMotel      = x.IdMotel,
                    MonthRent    = x.MonthRent,
                    ParkingFee   = x.ParkingFee,
                    RoomBil      = x.RoomBill,
                    WaterBill    = x.WaterBill,
                    WifiBill     = x.WifiBill,
                    Payment      = x.Payment,
                    DateCreate   = x.DateCreate
                }).ToList(),
                TotalRecord = await request.CountAsync(),
            };
            return(list);
        }
Exemplo n.º 25
0
        public override async Task <PagedViewModel <OfficeViewModel> > GetPaged(string includeProperties = null,
                                                                                int page     = 1,
                                                                                int pageSize = WebApiConstants.DefaultPageSize,
                                                                                string sort  = null,
                                                                                string dir   = "",
                                                                                string s     = "")
        {
            if (sort == "City" || sort == "Country" || sort == "Street" || sort == "Building")
            {
                sort = "Address." + sort;
            }

            if (sort == "StreetBuilding")
            {
                sort = "Address.Street";
            }

            var sortString = string.IsNullOrEmpty(sort) ? null : $"{sort} {dir}";

            IQueryable <Office> offices;

            if (string.IsNullOrEmpty(s))
            {
                offices = _repository.Get(orderBy: sortString, includeProperties: includeProperties);
            }
            else
            {
                offices = _repository.Get(o => o.Address.City.Contains(s) || o.Address.Country.Contains(s) ||
                                          o.Address.Street.Contains(s) || o.Address.Building.Contains(s) ||
                                          o.Name.Contains(s),
                                          orderBy: sortString, includeProperties: includeProperties);
            }

            var officesViewModel = _mapper.Map <IEnumerable <Office>, IEnumerable <OfficeViewModel> >(await offices.ToListAsync());

            var officeViewModels = officesViewModel as IList <OfficeViewModel> ?? officesViewModel.ToList();

            officeViewModels.ForEach(o => o.Floors.ForEach(f =>
            {
                o.RoomsCount += f.RoomsCount;
                f.Rooms.ForEach(r =>
                {
                    o.ApplicationUsersCount += r.ApplicationUsersCount;
                });
            }));

            var pagedList = await officeViewModels.ToPagedListAsync(page, pageSize);

            var pagedModel = new PagedViewModel <OfficeViewModel>
            {
                PagedList = pagedList,
                PageCount = pagedList.PageCount,
                ItemCount = pagedList.TotalItemCount,
                PageSize  = pageSize
            };

            return(pagedModel);
        }
Exemplo n.º 26
0
        GetTestDataUsingAutomapper([FromQuery] TestDataQueryArgs args)
        {
            IQueryable <TestTable> testQuery = this.TestQuery(args);
            PagedViewModel <TestTableViewModel> testDataWithAutomappper =
                await _pagingManager
                .PageAsync <TestTableViewModel, TestDataQueryArgs>(testQuery, args);

            return(Ok(testDataWithAutomappper));
        }
Exemplo n.º 27
0
        public IHttpActionResult GetPaginated(int page)
        {
            var pagedData         = _mp3service.GetPaged(page);
            var pagedDataToReturn = new PagedViewModel <MP3>();

            Mapper.Map(pagedData, pagedDataToReturn);

            return(Ok(pagedDataToReturn));
        }
Exemplo n.º 28
0
 public static PagedViewModel <TripViewModel> ToViewModel(this PagedViewModel <Trip> pagedTrips)
 {
     return(new PagedViewModel <TripViewModel>()
     {
         Data = pagedTrips.Data.ToViewModel(),
         Total = pagedTrips.Total,
         Take = pagedTrips.Take,
         Skip = pagedTrips.Skip
     });
 }
Exemplo n.º 29
0
 public static PagedViewModel <CarViewModel> ToViewModel(this PagedViewModel <Car> pagedCars)
 {
     return(new PagedViewModel <CarViewModel>()
     {
         Data = pagedCars.Data.ToViewModel(),
         Skip = pagedCars.Skip,
         Take = pagedCars.Take,
         Total = pagedCars.Total
     });
 }
        protected override void OnViewModelChanged(PagedViewModel oldViewModel, PagedViewModel currentViewModel)
        {
            if (currentViewModel != null)
            {
                currentViewModel.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(CurrentViewModel_PropertyChanged).Handler;
                UpdateTitle();
            }

            base.OnViewModelChanged(oldViewModel, currentViewModel);
        }
Exemplo n.º 31
0
        public static PagedViewModel <T> Paged <T>(this IQueryable <T> query, int pageNumber, int pageSize)
        {
            var result = new PagedViewModel <T>
            {
                Count = query.Count(),
                Data  = query.Skip(pageSize * (pageNumber - 1)).Take(pageSize).ToList()
            };

            return(result);
        }
 public static PagedViewModel <CarMaintenanceViewModel> ToViewModel(this PagedViewModel <CarMaintenance> paged)
 {
     return(new PagedViewModel <CarMaintenanceViewModel>()
     {
         Data = paged.Data.ToViewModel(),
         Total = paged.Total,
         Take = paged.Take,
         Skip = paged.Skip
     });
 }
Exemplo n.º 33
0
        public ActionResult Market()
        {
            if (Session["id"] == null)
            {
                return(RedirectToAction("LogIn", "Account"));
            }
            if (Session["error"] != null)
            {
                ViewBag.Error    = Session["error"];
                Session["error"] = null;
            }
            else if (Session["success"] != null)
            {
                ViewBag.SuccessMessage = Session["success"];
                Session["success"]     = null;
            }

            List <PlayerViewModel> showPlayers = new List <PlayerViewModel>();

            double pageCount = pR.getLength() / numberInPage;
            int    lastPage  = (Convert.ToInt32(Math.Floor(pageCount) + 1));

            PagingModel page = new PagingModel();

            if (Session["currentPage"] == null)
            {
                showPlayers.AddRange(pR.getPartOfPlayers(0, numberInPage));
                page = new PagingModel(current: 1, last: lastPage);
            }
            else
            {
                if ((int)Session["currentPage"] <= 0 || (int)Session["currentPage"] > lastPage)
                {
                    Session["currentPage"] = lastPage;
                }

                int startIndex = ((int)Session["currentPage"] - 1) * numberInPage;
                if (pR.getLength() - startIndex < numberInPage)
                {
                    showPlayers.AddRange(pR.getPartOfPlayers(((int)Session["currentPage"] - 1) * numberInPage, pR.getLength() - startIndex));
                }
                else
                {
                    showPlayers.AddRange(pR.getPartOfPlayers(((int)Session["currentPage"] - 1) * numberInPage, numberInPage));
                }
                page = new PagingModel(current: (int)Session["currentPage"], last: lastPage);
            }
            var MarketViewModel = new PagedViewModel
            {
                Players = showPlayers,
                Page    = page
            };

            return(View(MarketViewModel));
        }
Exemplo n.º 34
0
 public static PagedViewModel <TripPossiblePlaceViewModel> ToViewModel(
     this PagedViewModel <TripPossiblePlace> pagedPlaces)
 {
     return(new PagedViewModel <TripPossiblePlaceViewModel>()
     {
         Data = pagedPlaces.Data.ToViewModel(),
         Total = pagedPlaces.Total,
         Take = pagedPlaces.Take,
         Skip = pagedPlaces.Skip
     });
 }
 public static PagedViewModel <UserRegistrationKeyViewModel> ToViewModel(this
                                                                         PagedViewModel <UserRegistrationKey> pagedKeys)
 {
     return(new PagedViewModel <UserRegistrationKeyViewModel>()
     {
         Take = pagedKeys.Take,
         Skip = pagedKeys.Skip,
         Data = pagedKeys.Data.ToViewModel(),
         Total = pagedKeys.Total
     });
 }
 public static PagedViewModel <UserAuthenticationTokenViewModel> ToViewModel(this
                                                                             PagedViewModel <UserAuthenticationToken> pagedTokens)
 {
     return(new PagedViewModel <UserAuthenticationTokenViewModel>()
     {
         Take = pagedTokens.Take,
         Skip = pagedTokens.Skip,
         Data = pagedTokens.Data.ToViewModel(),
         Total = pagedTokens.Total
     });
 }
Exemplo n.º 37
0
 public SettingsListViewModel(BaseViewModel parent) : base(parent)
 {
     Account    = FindAncestor <MainScreenViewModel>()?.CurrentAccount;
     HasAccount = Account != null;
     if (HasAccount)
     {
         Account.PropertyChanged += Account_PropertyChanged;
         UpdateFromAccount();
     }
     _pagedViewModel = FindAncestor <PagedViewModel>();
 }
 public SettingsListViewModel(BaseViewModel parent) : base(parent)
 {
     Account    = FindAncestor <MainWindowViewModel>()?.CurrentAccount;
     HasAccount = Account != null;
     if (HasAccount)
     {
         Account.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(Account_PropertyChanged).Handler;
         UpdateFromAccount();
     }
     _pagedViewModel = FindAncestor <PagedViewModel>();
 }
Exemplo n.º 39
0
 public ProgressPageModel(PagedViewModel model)
     : base(new ProgressPage(), model)
 {
     Model.BaseModel.Bootstrapper.ExecutePackageBegin += ExecutePackageBegin;
     Model.BaseModel.Bootstrapper.ApplyBegin += ApplyBegin;
     Model.BaseModel.Bootstrapper.ExecutePackageComplete += ExecutePackageComplete;
     Model.BaseModel.Bootstrapper.ExecuteProgress += ExecuteProgressHandler;
     Foreground = model.Foreground;
     Background = model.Background;
     _timer = new DispatcherTimer
         {
             Interval = new TimeSpan(0, 0, 0, 0, 500),
             IsEnabled = true
         };
     _timer.Tick += TimerTickHandler;
 }
Exemplo n.º 40
0
        public ActionResult SearchPhotos(String searchString, int page)
        {
            const int pageSize = 2;

            var photos = unitOfWork.PictureRepository.Read(filter: a => a.Title.Contains(searchString)).Select(photo => new PhotoViewModel { Picture = photo }).OrderByDescending(m => m.VotesValue).ToList();

            var photosViewModel = new PagedViewModel<PhotoViewModel>
            {
                Data = photos.Skip(page == 1 ? 0 : 6 + pageSize * (page - 2)).Take(page == 1 ? 6 : pageSize).ToList(),
                PageNumber = photos.Count % pageSize == 0 ? (photos.Count / pageSize - 2) : (photos.Count / pageSize - 1),
                CurrentPage = page
            };

            if (photosViewModel.PageNumber == photosViewModel.CurrentPage)
                photosViewModel.CurrentPage = -10;

            if (photos.Any())
                return PartialView("Shared/_PhotosPartial", photosViewModel);
            return Content(GlobalRes.NoPhotos);
        }
Exemplo n.º 41
0
 public MessagePageModel(PagedViewModel model)
     : base(new MessagePage(), model)
 {
 }
Exemplo n.º 42
0
 public ExternalProgressPageModel(PagedViewModel model, string pipeName)
     : base(model)
 {
     _pipe = new PipeServer(pipeName);
     _pipe.MessageReceived += PipedMessageReceivedHandler;
 }
Exemplo n.º 43
0
 public CancelBottomButtonModel(PagedViewModel model)
     : base(model)
 {
     Command = new RelayCommand(param => Model.Cancelled = true, param => Model.Cancelled != true & Model.InstallationState == InstallationState.Applying);
 }
Exemplo n.º 44
0
 public StateBottomButton(PagedViewModel model, InstallationState state)
     : base(model)
 {
     Command = new RelayCommand(param => Model.InstallationState = state);
 }
Exemplo n.º 45
0
 public ContentPanelModel(PagedViewModel model)
     : base(model)
 {
 }
Exemplo n.º 46
0
 public ButtonPageModel(PagedViewModel model)
     : base(new ButtonPage(), model)
 {
 }
        public virtual ActionResult List(int? page, GridSortOptions sortOptions, string number, int? regionId, int? correctionFacilityId, string terminalAddress)
        {
            // реализация поиска и фильтрации
            //http://www.codeproject.com/KB/aspnet/Grid_Paging_In_MVC3.aspx

            var dbFacilities = _selectionRepository.GetAllObjects().Where(terminal => terminal.IsDeleted == false);
            if (!UserHelper.Instance.IsAdministrator && !UserHelper.Instance.IsManager && !UserHelper.Instance.IsCallCenterUser) //простым смертным показывать только активные терминалы
                dbFacilities = dbFacilities.Where(terminal => terminal.IsActive == true);
            var facilities = dbFacilities.Select(dbTerminal => new TerminalListModel
                                                                   {
                                                                       Id = dbTerminal.Id,
                                                                       PhoneNumber = dbTerminal.PhoneNumber,
                                                                       IsPublic = dbTerminal.IsPublic,
                                                                       CorrectionFacilityId = dbTerminal.CorrectionFacilityId,
                                                                       CorrectionFacilityName = dbTerminal.CorrectionFacility.Name,
                                                                       InstallationAddress = dbTerminal.CorrectionFacility.Address,
                                                                       RegionId = dbTerminal.RegionId,
                                                                       IsActive = dbTerminal.IsActive
                                                                   });

            var pagedViewModel = new PagedViewModel<TerminalListModel>
            {
                ViewData = ViewData,
                Query = facilities,
                GridSortOptions = sortOptions,
                DefaultSortColumn = "PhoneNumber",
                Page = page,
                PageSize = 10
            }
            .AddFilter("number", number, t => t.PhoneNumber.Contains(number))
            .AddFilter("RegionId", regionId, t => t.RegionId == regionId, RegionController.GetDBRegionList(null), "Id", "Name")
            .AddFilter("CorrectionFacilityId", correctionFacilityId, t => t.CorrectionFacilityId == correctionFacilityId, CorrectionFacilityController.GetDbCorrectionFacilityList(-1, null), "Id", "Name")
            .AddFilter("terminalAddress", terminalAddress, t => t.InstallationAddress.ToLower().Contains(terminalAddress.ToLower()))
            .Setup();

            return View(pagedViewModel);
        }
Exemplo n.º 48
0
 public AskingPageModel(PagedViewModel model)
     : base(new AskingPage(), model)
 {
 }
        public void Fill_PagedViewModelWithNullList_PagedPropertySet()
        {
            var container = CreateContainer();
            var inspector = container.Resolve<QueryModelInspector>();
            var viewModel = new PagedViewModel();

            inspector.Fill(viewModel, null);

            Expect(viewModel.Customers, Is.Not.Null);
            Expect(viewModel.Customers.Count(), Is.EqualTo(5));
        }
Exemplo n.º 50
0
 public CloseBottomButtonModel(PagedViewModel model, int exitCode)
     : base(model)
 {
     Command = new RelayCommand(param=>model.Close(exitCode));
 }
Exemplo n.º 51
0
 public StartExternalBottomButton(PagedViewModel model, InstallActions postExecuteAction)
     : base(model)
 {
     Command = new RelayCommand(p => ExecuteExternal(postExecuteAction));
 }
Exemplo n.º 52
0
 public InvisibleButtonModel(PagedViewModel model)
     : base(model)
 {
 }
Exemplo n.º 53
0
        public ActionResult ShowUserPhotos(String userId, int page)
        {
            try
            {
                const int pageSize = 3;

                var photos = unitOfWork.PictureRepository.Read(filter: a => a.UserId == userId).Select(photo => new PhotoViewModel { Picture = photo }).OrderByDescending(m => m.VotesValue).ToList();

                var photosViewModel = new PagedViewModel<PhotoViewModel>
                {
                    Data = photos.Skip(page == 1 ? 0 : 9 + pageSize * (page - 2)).Take(page == 1 ? 9 : pageSize).ToList(),
                    PageNumber = photos.Count % pageSize == 0 ? (photos.Count / pageSize - 2) : (photos.Count / pageSize - 1),
                    CurrentPage = page
                };

                if (photosViewModel.PageNumber == photosViewModel.CurrentPage)
                    photosViewModel.CurrentPage = -10;

                if (photos.Count == 0)
                    return Content(GlobalRes.NoPhotos);

                return PartialView("_TopPhotosPartial", photosViewModel);

            }
            catch (Exception exception)
            {
                return RedirectToAction("Error", "Home", new {errorMessage = exception.Message});
            }
        }
Exemplo n.º 54
0
 public PlanBottomButton(PagedViewModel model, InstallActions action)
     : base(model)
 {
     Command = new RelayCommand(param => Model.BaseModel.Plan(action));
 }
Exemplo n.º 55
0
 public UrlBottomButtonModel(PagedViewModel model, string url)
     : base(model)
 {
     _url = url;
     Command = new RelayCommand(param =>LaunchUrl(), param => ! string.IsNullOrWhiteSpace(_url));
 }
Exemplo n.º 56
0
 public ButtonPanelModel(PagedViewModel model)
     : base(model)
 {
     _defaultHelpButton = new UrlBottomButtonModel(Model, model.BaseModel.HelpUrl) { Text = "Help" };
 }
Exemplo n.º 57
0
 protected AbstractBottomButtonModel(PagedViewModel model)
 {
     Model = model;
     Foreground = model.Foreground;
     Background = model.Background;
 }
Exemplo n.º 58
0
 public OptionPageModel(PagedViewModel model, XElement element)
     : base(new OptionPage(), model)
 {
     ImportFromNode(element);
 }
Exemplo n.º 59
0
        public ActionResult List(string searchWord, int? genreId, int? artistId, GridSortOptions gridSortOptions,
                                 int? page)
        {
            PagedViewModel<C_Mechanism> pagedViewModel = new PagedViewModel<C_Mechanism>
                                                             {
                                                                 ViewData = ViewData,
                                                                 Query = new BLL.C_Mechanism().GetList().AsQueryable(),
                                                                 GridSortOptions = gridSortOptions,
                                                                 DefaultSortColumn = "MECHANISMID",
                                                                 Page = page,
                                                                 PageSize = 10,
                                                             }
                .AddFilter("searchWord", searchWord, a => a.机构名称.Contains(searchWord))
                .Setup();

            return View(pagedViewModel);
        }