コード例 #1
0
        public async Task <IActionResult> Index(string searchString, string categoryName, bool ArchivedValue, bool soldOutValue)
        {
            ItemIndexViewModel viewModel = new ItemIndexViewModel();

            viewModel.Items = await _context.Item.Include(i => i.Category).ToListAsync();

            if (!String.IsNullOrEmpty(searchString))
            {
                viewModel.Items = viewModel.Items.Where(s => s.Name.Contains(searchString)).ToList();
            }

            if (!String.IsNullOrEmpty(categoryName))
            {
                viewModel.Items = viewModel.Items.Where(s => s.Category.Name == categoryName).ToList();
            }

            if (ArchivedValue)
            {
                viewModel.Items = viewModel.Items.Where(s => s.Archived == true).ToList();
            }

            if (soldOutValue)
            {
                viewModel.Items = viewModel.Items.Where(s => s.SoldOut == true).ToList();
            }

            viewModel.Categories = new SelectList(await _context.Category.Select(x => x.Name).Distinct().ToListAsync());
            return(View(viewModel));
        }
コード例 #2
0
        /// <summary>
        /// Get all the items for a set location
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public List <string> Get_Item_List_BasedOn_Location(string location)
        {
            ItemIndexViewModel ItemList = ItemIndexViewModel.Instance;
            List <string>      result   = new List <string>();

            if (location == "Hand")
            {
                foreach (var item in ItemList.GetLocationItems(ItemLocationEnum.PrimaryHand))
                {
                    result.Add(item.Name);
                }
            }
            else if (location == "Head")
            {
                foreach (var item in ItemList.GetLocationItems(ItemLocationEnum.Head))
                {
                    result.Add(item.Name);
                }
            }
            else if (location == "Finger")
            {
                foreach (var item in ItemList.GetLocationItems(ItemLocationEnum.Finger))
                {
                    result.Add(item.Name);
                }
            }

            return(result);
        }
コード例 #3
0
        public async Task CreateAsyncReturnsCorrectItem()
        {
            var secondItem = new ItemIndexViewModel
            {
                Id                       = 2,
                Name                     = SecondItemName,
                OrdinaryPrice            = SecondtemOrdinaryPrice,
                ExpressAddOnPrice        = SecondItemExpressAddOnPrice,
                FlavorAddOnPrice         = SecondItemFlavorAddOnPrice,
                VacuumCleaningAddOnPrice = SecondItemVacuumCleaningAddOnPrice,
            };

            var expected = new List <ItemIndexViewModel>();

            expected.Add(secondItem);

            var addItem = new ItemCreateInputModel
            {
                Name                     = SecondItemName,
                OrdinaryPrice            = SecondtemOrdinaryPrice,
                ExpressAddOnPrice        = SecondItemExpressAddOnPrice,
                FlavorAddOnPrice         = SecondItemFlavorAddOnPrice,
                VacuumCleaningAddOnPrice = SecondItemVacuumCleaningAddOnPrice,
            };

            var result = await this.ItemsServiceMock.CreateAsync(addItem);

            var actual = this.DbContext.Items;

            Assert.Equal(expected.Count, actual.Count());
            Assert.Equal(addItem.Name, result.Name);
        }
コード例 #4
0
        /// <summary>
        /// Constructor for Index Page
        ///
        /// Get the ItemIndexView Model
        /// </summary>
        public CharIndexPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new CharIndexViewModel();
            ItemViewModel  = new ItemIndexViewModel();
        }
コード例 #5
0
        public void ItemIndexViewModelNameShouldbeNullIfMapItemFieldSNameIsNull()
        {
            // Arrange
            var itemToMap = new Item
            {
                Buyer               = null,
                BuyerId             = null,
                CreateDateTime      = new DateTime(2012, 12, 12, 1, 0, 0),
                Descrption          = "good one",
                HoldLongDay         = 3,
                HoldLongLessThanDay = new TimeSpan(0, 1, 0, 0),
                ImageUrl            = "http://www.123.com",
                HoldTime            = null,
                ItemId              = 3,
                Name = "coffee machine"
            };

            // Act
            var viewModel = new ItemIndexViewModel(itemToMap);

            // Assert
            Assert.Equal(null, viewModel.BuyerId);
            Assert.Equal(new TimeSpan(3, 1, 0, 0), viewModel.HoldLong);
            Assert.Equal(null, viewModel.BuyerName);
            Assert.Equal(3, viewModel.ItemId);
            Assert.Equal("coffee machine", viewModel.Name);
            Assert.Equal(false, viewModel.HasBuyer);
        }
コード例 #6
0
        public void ItemIndexViewModelShouldMapItemFieldNeeded()
        {
            // Arrange
            var itemToMap = new Item
            {
                Buyer = new Buyer
                {
                    BuyerId = 1,
                    Contact = "123",
                    Name    = "Anna",
                    Token   = "Would you kindly"
                },
                BuyerId             = 1,
                CreateDateTime      = new DateTime(2012, 12, 12, 1, 0, 0),
                Descrption          = "good one",
                HoldLongDay         = 3,
                HoldLongLessThanDay = new TimeSpan(0, 1, 0, 0),
                ImageUrl            = "http://www.123.com",
                HoldTime            = null,
                ItemId = 3,
                Name   = "coffee machine"
            };

            // Act
            var viewModel = new ItemIndexViewModel(itemToMap);

            // Assert
            Assert.Equal(1, viewModel.BuyerId);
            Assert.Equal(new TimeSpan(3, 1, 0, 0), viewModel.HoldLong);
            Assert.Equal("Anna", viewModel.BuyerName);
            Assert.Equal(3, viewModel.ItemId);
            Assert.Equal("coffee machine", viewModel.Name);
            Assert.Equal(true, viewModel.HasBuyer);
        }
 private ItemIndexViewModel GetIndexViewModel(ItemIndexViewModel currModel)
 {
     currModel.CategorySelectList = _categoryService.GetSelectCategoryList();
     currModel.AvaibleSelectList  = _itemService.GetAvaibleSelectList();
     currModel.FilterModel        = currModel.FilterModel ?? new ItemFilterModel();
     return(currModel);
 }
コード例 #8
0
        public IActionResult Index(string typeFilter, bool showCompleted = false)
        {
            var             userId    = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            List <ItemUser> joinList  = _db.ItemUser.Where(join => join.UserId == userId).Include(join => join.Item).ToList();
            List <Item>     userItems = new List <Item>();

            foreach (ItemUser join in joinList)
            {
                userItems.Add(join.Item);
            }
            ItemIndexViewModel model            = new ItemIndexViewModel();
            List <Item>        orderedUserItems = userItems.OrderBy(item => item.Priority).ToList();

            model.ItemList = orderedUserItems;
            if (showCompleted == false)
            {
                List <Item> uncompletedItems = model.ItemList.Where(item => item.Watched == false).ToList();
                model.ItemList = uncompletedItems;
            }
            else
            {
                List <Item> completedItems = model.ItemList.Where(item => item.Watched == true).ToList();
                model.ItemList         = completedItems;
                model.ShowingCompleted = true;
            }
            if (typeFilter != null)
            {
                List <Item> filteredItems = model.ItemList.Where(item => item.Type == typeFilter).ToList();
                model.ItemList   = filteredItems;
                model.TypeFilter = typeFilter;
            }
            return(View(model));
        }
コード例 #9
0
        public async Task GetAllItemsAsyncReturnsAllItemss()
        {
            await this.AddTestingFirstItemToDb();

            this.DbContext.Items.Add(new Item
            {
                Id                       = 2,
                Name                     = SecondItemName,
                OrdinaryPrice            = SecondtemOrdinaryPrice,
                ExpressAddOnPrice        = SecondItemExpressAddOnPrice,
                FlavorAddOnPrice         = SecondItemFlavorAddOnPrice,
                VacuumCleaningAddOnPrice = SecondItemVacuumCleaningAddOnPrice,
            });
            await this.DbContext.SaveChangesAsync();

            var firstItem = new ItemIndexViewModel
            {
                Id                       = 1,
                Name                     = FirstItemName,
                OrdinaryPrice            = FistItemOrdinaryPrice,
                ExpressAddOnPrice        = FirstItemExpressAddOnPrice,
                FlavorAddOnPrice         = FirstItemFlavorAddOnPrice,
                VacuumCleaningAddOnPrice = FirstItemVacuumCleaningAddOnPrice,
            };
            var secondItem = new ItemIndexViewModel
            {
                Id                       = 2,
                Name                     = SecondItemName,
                OrdinaryPrice            = SecondtemOrdinaryPrice,
                ExpressAddOnPrice        = SecondItemExpressAddOnPrice,
                FlavorAddOnPrice         = SecondItemFlavorAddOnPrice,
                VacuumCleaningAddOnPrice = SecondItemVacuumCleaningAddOnPrice,
            };

            var expected = new List <ItemIndexViewModel>();

            expected.Add(firstItem);
            expected.Add(secondItem);

            var actual = await this.ItemsServiceMock.GetAllItemsAsync <ItemIndexViewModel>().ToListAsync();

            Assert.Collection(
                actual,
                elem1 =>
            {
                Assert.Equal(expected[0].Id, elem1.Id);
                Assert.Equal(expected[0].Name, elem1.Name);
                Assert.Equal(expected[0].OrdinaryPrice, elem1.OrdinaryPrice);
                Assert.Equal(expected[0].VacuumCleaningAddOnPrice, elem1.VacuumCleaningAddOnPrice);
            },
                elem2 =>
            {
                Assert.Equal(expected[1].Id, elem2.Id);
                Assert.Equal(expected[1].Name, elem2.Name);
                Assert.Equal(expected[1].OrdinaryPrice, elem2.OrdinaryPrice);
                Assert.Equal(expected[1].VacuumCleaningAddOnPrice, elem2.VacuumCleaningAddOnPrice);
            });
            Assert.Equal(expected.Count, actual.Count);
        }
コード例 #10
0
        public ActionResult Index(int?page)
        {
            ItemIndexViewModel model = new ItemIndexViewModel();

            model.ItemList = _itemService.GetAll().ToPagedList(page ?? 1, PAGE_SIZE);

            return(View(GetIndexViewModel(model)));
        }
コード例 #11
0
        public IActionResult Index()
        {
            var model = new ItemIndexViewModel();



            return(View(model));
        }
コード例 #12
0
        public void Setup()
        {
            // Initilize Xamarin Forms
            MockForms.Init();

            // Add each model here to warm up and load it.
            Game.Helpers.DataSetsHelper.WarmUp();

            ViewModel = ItemIndexViewModel.Instance;
        }
コード例 #13
0
ファイル: App.xaml.cs プロジェクト: nfj5/5250WQ-Jones
        /// <summary>
        /// Default App Constructor
        /// </summary>
        public App()
        {
            InitializeComponent();

            // To initialize the ItemIndexViewModel before use
            ItemIndexViewModel temp = ItemIndexViewModel.Instance;

            // Call the Main Page to open
            MainPage = new MainPage();
        }
コード例 #14
0
        public ActionResult Index(ItemIndexSearchCriteria criteria)
        {
            ItemIndexViewModel model = new ItemIndexViewModel
            {
                PageSize   = PageSize,
                TotalCount = 0,
            };

            return(View(model));
        }
コード例 #15
0
        public ActionResult Index(ItemFilterModel filterModel)
        {
            ItemIndexViewModel model = new ItemIndexViewModel()
            {
                ItemList    = filterModel.IsFiltered ? _itemService.Filter(filterModel).ToPagedList() : _itemService.GetAll().ToPagedList(1, PAGE_SIZE),
                FilterModel = filterModel,
            };

            return(View(GetIndexViewModel(model)));
        }
コード例 #16
0
        // GET: Items
        public IActionResult Index()
        {
            //var applicationDbContext = _context.Items.Include(i => i.Owner);

            var indexVM = new ItemIndexViewModel
            {
                Items = _itemManager.GetItems()
            };

            return(View(indexVM));
        }
コード例 #17
0
        /// <summary>
        /// Default App Constructor
        /// </summary>
        public App()
        {
            InitializeComponent();
            ItemIndexViewModel temp = ItemIndexViewModel.Instance;

            //DependencyService.Register<MockDataStore>();
            //DependencyService.Register<DatabaseService>();

            // Call the Main Page to open
            MainPage = new MainPage();
        }
コード例 #18
0
        public async Task <IActionResult> Filter(string sortOrder, string searchTerm, int?pageSize, int?pageNumber)
        {
            sortOrder  = sortOrder ?? string.Empty;
            searchTerm = searchTerm ?? string.Empty;

            var items = await _itemService.FilterItemsAsync(sortOrder, searchTerm, pageNumber ?? 1, pageSize ?? 10);

            var model = new ItemIndexViewModel(items, sortOrder, searchTerm);

            return(PartialView("_ItemTablePartial", model.Table));
        }
コード例 #19
0
        public void Setup()
        {
            // Initilize Xamarin Forms
            MockForms.Init();

            // Activate the Datastore
            DependencyService.Register <MockDataStore>();

            ViewModel = new ItemIndexViewModel();

            // Load Data
            ViewModel.ForceDataRefresh();
        }
コード例 #20
0
        public ActionResult Index(IPrincipal user)
        {
            var currentUserId       = user.Identity.GetUserId();
            var items               = _repository.FindItemsByUserId(currentUserId);
            var itemIndexViewModels = ItemIndexViewModel.MapItemsForIndexView(items);

            var saleLink = Helper.GetSaleBaseLink();

            saleLink               = saleLink + "/buy/index/" + currentUserId;
            ViewBag.SaleLink       = saleLink;
            ViewBag.RichClientLink = Helper.GetSaleBaseLink() + "/richclient/items/" + currentUserId;
            return(View(itemIndexViewModels));
        }
コード例 #21
0
        public void ItemIndexPage_OnAppearing_Valid_Should_Pass()
        {
            // Arrange

            // Warm it up
            ItemIndexViewModel ViewModel = ItemIndexViewModel.Instance;

            // Act
            OnAppearing();

            // Reset

            // Assert
            Assert.IsTrue(true); // Got to here, so it happened...
        }
コード例 #22
0
        public void ItemIndexPage_ReadItem_Clicked_Default_Should_Pass()
        {
            // Arrange
            ItemIndexViewModel ViewModel = ItemIndexViewModel.Instance;
            ImageButton        item      = new ImageButton {
                CommandParameter = ViewModel.Dataset[0].Id
            };

            // Act
            page.ReadItem_Clicked(item, null);

            // Reset

            // Assert
            Assert.IsTrue(true); // Got to here, so it happened...
        }
コード例 #23
0
        public IActionResult Index(int partyId, bool showOnlyAvailable)
        {
            ViewData["options"] = "All";
            if (showOnlyAvailable)
            {
                ViewData["options"] = "OnlyAvailable";
            }

            var viewModel = new ItemIndexViewModel()
            {
                ItemIndexDtos = itemService.GetItemsIndex(partyId, showOnlyAvailable),
                PartyId       = partyId
            };

            return(View(viewModel));
        }
コード例 #24
0
        public ActionResult ViewAllOnLoanInv(SearchRequest searchRequest)
        {
            IList <InventoryItem> model = _itemServices.HandlesSearchRequest(searchRequest);

            var viewModel = new ItemIndexViewModel
            {
                InventoryItems = model,
                PagingInfo     = new PagingInfo
                {
                    CurrentPage  = 1,
                    ItemsPerPage = _pageSize,
                    TotalItems   = model.Count
                }
            };

            return(View(viewModel));
        }
コード例 #25
0
        public void ItemIndexPage_OnAppearing_Valid_Empty_Should_Pass()
        {
            // Arrange

            // Add each model here to warm up and load it.
            ItemIndexViewModel ViewModel = ItemIndexViewModel.Instance;

            ViewModel.Dataset.Clear();

            // Act
            OnAppearing();

            // Reset

            // Assert
            Assert.IsTrue(true); // Got to here, so it happened...
        }
コード例 #26
0
        public ActionResult Create(ItemViewModel viewModel, ItemIndexSearchCriteria criteria)
        {
            User user = GetCurrentUser();

            if (!ModelState.IsValid)
            {
                throw new BusinessRuleException(ModelState.GetFirstError());
            }

            Item entity = Item.Create(viewModel.Title, user);

            entity = ItemService.Obj.Create(entity);

            ItemIndexViewModel result = getItemIndexModel(criteria, "Success");

            result.SelectedRowId = entity.ItemId;
            return(Json(result));
        }
コード例 #27
0
        public async Task <IActionResult> Index()
        {
            var Item = await _itemRepo.GetAllAsync().ConfigureAwait(true);

            var indexViewModel = new List <ItemIndexViewModel>();

            foreach (var data in Item)
            {
                var model = new ItemIndexViewModel
                {
                    ItemId = data.Id, Status = data.Status, Name = data.Name, UnitName = data.Unit.Name,
                    Rate   = data.Rate, AvailableQty = data.AvailableQty
                };
                indexViewModel.Add(model);
            }

            return(View(indexViewModel));
        }
コード例 #28
0
        /// <summary>
        /// Constructor that takes and existing data item
        /// </summary>
        public CharacterUpdatePage(GenericViewModel <CharacterModel> data)
        {
            InitializeComponent();

            BindingContext = this.ViewModel = data;

            // Get instance of ItemIndexViewModel
            ItemListModel = ItemIndexViewModel.Instance;

            // Make a copy of the character for cancel to restore
            DataCopy = new CharacterModel(data.Data);

            this.ViewModel.Title = "Character Update";

            LoadCharacterLevelPickerValues();

            UpdatePageBindingContext();
        }
コード例 #29
0
        public IActionResult Index(string searchOption = null, string searchString = null, int page = 1)
        {
            if (String.IsNullOrEmpty(searchString))
            {
                return(RedirectToAction("Index", "Home"));
            }
            var             userId     = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            List <ItemUser> joinList   = _db.ItemUser.Where(join => join.UserId == userId).Include(join => join.Item).ToList();
            List <long>     userApiIds = new List <long>();

            foreach (ItemUser join in joinList)
            {
                userApiIds.Add(join.Item.ApiId);
            }
            ItemIndexViewModel model = new ItemIndexViewModel();

            model.ApiIds       = userApiIds;
            model.CurrentPage  = page;
            model.SearchOption = searchOption;
            model.SearchString = searchString;
            if (searchOption == "games")
            {
                RawgSearchRoot results = Rawg.GetGamesSearch(searchString, page);
                model.GamesSearch = results;
                model.Results     = results.Count;
                model.Pages       = (results.Count + 19) / 20;
            }
            else if (searchOption == "movies")
            {
                TmdbMovieSearchRoot results = Tmdb.GetMoviesSearch(searchString, page);
                model.MovieSearch = results;
                model.Results     = results.TotalResults;
                model.Pages       = results.TotalPages;
            }
            else if (searchOption == "tv")
            {
                TmdbTvSearchRoot results = Tmdb.GetTvSearch(searchString, page);
                model.TvSearch = results;
                model.Results  = results.TotalResults;
                model.Pages    = results.TotalPages;
            }
            return(View(model));
        }
コード例 #30
0
        public async Task <IActionResult> Index()
        {
            if (!_memoryCache.TryGetValue("ListOfItems", out IPagedList <Item> items))
            {
                items = await _itemService.FilterItemsAsync();

                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(25),
                    SlidingExpiration = TimeSpan.FromSeconds(5)
                };

                _memoryCache.Set("ListOfItems", items, options);
            }

            var model = new ItemIndexViewModel(items);

            return(View(model));
        }