public async Task <IActionResult> SearchByNameAsync(ItemsListViewModel model, string searchString) { model.Items = dbManager.SearchByName(model.CollectionId, searchString); model.ViewedByCreator = await CheckAcess(model); return(View("Index", model)); }
public async Task <IActionResult> OrderByTagsAsync(ItemsListViewModel model) { model.Items = dbManager.GetSortedByTags(model.CollectionId); model.ViewedByCreator = await CheckAcess(model); return(View("Index", model)); }
public ViewResult List() { ItemsListViewModel itemsListViewModel = new ItemsListViewModel(); itemsListViewModel.Items = _itemRepository.AllItems; return(View(itemsListViewModel)); }
public async Task AllItems_GetLoaded_AfterInitializeAsync() { var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockItemsService = new Mock <IItemsService>(); var fakeItemsList = Task.Run(() => new List <Item>() { new Item() { Id = 1, Name = "Test 1", Description = "Description 123", Quantity = 1 }, new Item() { Id = 3, Name = "Test 3", Description = "Description 3", Quantity = 3 } } .AsEnumerable() ); mockItemsService.Setup(m => m.GetAllItemsAsync()).Returns(fakeItemsList); var listItemsViewModel = new ItemsListViewModel(mockNavigationService.Object, mockDialogService.Object, mockItemsService.Object); await listItemsViewModel.InitializeAsync(null); Approvals.Verify(listItemsViewModel.Items.ToList().ToApprovalString()); }
public ItemsListViewModel GetItemsListModel(Collection c) { List <CollectionItem> items = DbManager.GetItemsInCollection(c.Id); ItemsListViewModel model = MakeModel(c.Id, c, items); return(model); }
public ActionResult Catalog(string category, int page = 1) { var model = new ItemsListViewModel { Items = _repository.Items .Where(item => category == null || item.Category == category) .OrderBy(item => item.ItemId) .Skip((page - 1) * PageSize) .Take(PageSize) .ToList(), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = category == null ? _repository.Items.Count() : _repository.Items.Count(item => item.Category == category) }, CurrentCategory = category }; if (page > model.PagingInfo.TotalPages) { model.PagingInfo.CurrentPage = model.PagingInfo.TotalPages; } // пустая модель //var model = new ItemsListViewModel() //{ // Items = new List<Item>(), // PagingInfo = new PagingInfo() {ItemsPerPage = 12} //}; return(View(model)); }
public IHttpActionResult PagingItemsList([FromUri] PaginationParams parametrs) { if (ModelState.IsValid) { int page = parametrs.CurrentPage; int pageSize = parametrs.PageSize; var items = outputService.GetItemsWithPagination(page, pageSize); if (items.Count() == 0) { return(NotFound()); } ItemsListViewModel model = new ItemsListViewModel() { Items = mapper.Map <IEnumerable <ItemView> >(items), PagingInfo = new PagingInfo() { CurrentPage = page, ItemsPerPage = pageSize, TotalItems = outputService.GetAllItems().Count() } }; return(Ok(model)); } return(BadRequest(ModelState)); }
private async Task <bool> CheckAcess(ItemsListViewModel ia) { Collection c = dbManager.GetCollectionById(ia.CollectionId); IdentityUser currentUser = await userManager.GetUserAsync(HttpContext.User); return(currentUser != null && (currentUser.Id == c.UserId || User.IsInRole(UserRoles.admin.ToString()))); }
public async Task <IActionResult> OrderByFieldIndexAsync(ItemsListViewModel model, int index) { model.Items = dbManager. GetSortBy(model.CollectionId, model.AdditionalFieldsIndexes[index]); model.ViewedByCreator = await CheckAcess(model); return(View("Index", model)); }
public IViewComponentResult Invoke() { var viewModel = new ItemsListViewModel <ItemsAllViewModel> { Items = this.itemsService.GetAllApprovedItems <ItemsAllViewModel>() }; return(this.View(viewModel)); }
public ItemModel GetItemModel(ItemsListViewModel il) { return(new ItemModel { AdditionalFieldsNames = il.AdditionalFieldsNames ?? new List <string>(), AdditionalFieldsIndexes = il.AdditionalFieldsIndexes ?? new List <int>(), CollectionId = il.CollectionId }); }
public IViewComponentResult Invoke() { var titles = this.articlesService.GetTitles <ArticlesTitlesViewModel>(); var viewModel = new ItemsListViewModel <ArticlesTitlesViewModel>() { Items = titles }; return(this.View(viewModel)); }
public void ItemTappedCommand_NotNull() { var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockItemsService = new Mock <IItemsService>(); var listItemsViewModel = new ItemsListViewModel(mockNavigationService.Object, mockDialogService.Object, mockItemsService.Object); Assert.NotNull(listItemsViewModel.ItemTappedCommand); }
public async Task <IActionResult> AddAsync(ItemsListViewModel il) { if (!await CheckAcess(il)) { return(Forbid()); } ItemModel model = modelHelper.GetItemModel(il); ViewBag.Tags = dbManager.GetTagsFromServer(); return(View(model)); }
public ItemsListViewModel MakeModel(int id, Collection c, List <CollectionItem> items) { ItemsListViewModel model = new ItemsListViewModel { Items = items, CollectionId = id }; model.AdditionalFieldsIndexes = IndexesFromMask(c.SelectedFieldsMask); model.AdditionalFieldsNames = GetFieldsNames(c, model.AdditionalFieldsIndexes); model.Selected = new List <bool>(new bool[items.Count]); return(model); }
public void NavigationToItemDetailViewIsCalled_WithSelectedItem_WhenItemIsTapped() { var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockItemsService = new Mock <IItemsService>(); var listItemsViewModel = new ItemsListViewModel(mockNavigationService.Object, mockDialogService.Object, mockItemsService.Object); listItemsViewModel.ItemTappedCommand.Execute(ItemBuilder.Simple().Build()); mockNavigationService.Verify(mock => mock.NavigateToAsync <ItemDetailViewModel>(It.IsAny <Item>()), Times.Once()); }
/// <summary> /// 展示未完成事项 /// </summary> /// <param name="inventoryId"></param> /// <returns></returns> public IActionResult ShowNoFinishItems(int inventoryId) { List <ItemViewModels> noFinished = SaveInViewModels(_itemService.GetItemsInInventory(inventoryId)); var noFinishItems = new ItemsListViewModel() { noFinished = noFinished, InventoryId = inventoryId }; return(View("ShowNoFinishItems", noFinishItems)); }
public async Task Items_NotNull_AfterInitializeAsync() { var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockItemsService = new Mock <IItemsService>(); var listItemsViewModel = new ItemsListViewModel(mockNavigationService.Object, mockDialogService.Object, mockItemsService.Object); await listItemsViewModel.InitializeAsync(null); Assert.NotNull(listItemsViewModel.Items); }
public async Task <IActionResult> IncreaseItemSort(ItemsListViewModel model) { await _avatarService.IncreaseItemSortAsync(model.ItemId); return(RedirectToAction(nameof(Layer), new { model.Id, model.Search, model.Unlockable, page = model.PaginateModel.CurrentPage })); }
public async Task AllItems_GetLoaded_AfterInitializeAsync() { var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockItemsRepository = new FakeItemsRepository(); var mockItemsService = new ItemsService(mockItemsRepository, new InMemoryBlobCache()); var listItemsViewModel = new ItemsListViewModel(mockNavigationService.Object, mockDialogService.Object, mockItemsService); await listItemsViewModel.InitializeAsync(null); Assert.Equal(mockItemsRepository.Items.Count, listItemsViewModel.Items.Count); }
public IActionResult All(int id = 1) { const int itemsPerPage = 12; var viewModel = new ItemsListViewModel { ItemsPerPage = itemsPerPage, PageNumber = id, Items = this.itemsService.GetAll(id, 12), ItemsCount = this.itemsService.GetCount(), }; return(this.View(viewModel)); }
public IActionResult Category(int categoryId, string categoryName) { const int itemsPerPage = 12; var viewModel = new ItemsListViewModel { ItemsPerPage = itemsPerPage, PageNumber = 1, Items = this.itemsService.GetByCategory(1, 12, categoryId), ItemsCount = this.itemsService.GetCount(), CategoryName = categoryName, }; return(this.View(viewModel)); }
public async Task <IActionResult> Layer(int id, string search, bool?unlockable = null, int page = 1) { var filter = new AvatarFilter(page, 12) { LayerId = id, Search = search, Unlockable = unlockable }; var itemList = await _avatarService.PageItemsAsync(filter); PaginateViewModel paginateModel = new PaginateViewModel() { ItemCount = itemList.Count, CurrentPage = page, ItemsPerPage = filter.Take.Value }; if (paginateModel.MaxPage > 0 && paginateModel.CurrentPage > paginateModel.MaxPage) { return(RedirectToRoute( new { page = paginateModel.LastPage ?? 1 })); } foreach (var item in itemList.Data) { item.Thumbnail = _pathResolver.ResolveContentPath(item.Thumbnail); } if (itemList.Data.Any()) { PageTitle = $"Avatar Items: {itemList.Data.First().AvatarLayerName}"; } var viewModel = new ItemsListViewModel() { Items = itemList.Data, PaginateModel = paginateModel, Id = id, Search = search, Unlockable = unlockable }; return(View(viewModel)); }
public async Task <IActionResult> GetItemsList(string itemIds, int?layerId, string search, bool unlockable, int page = 1) { var filter = new AvatarFilter(page, 10) { Search = search, LayerId = layerId, Unlockable = unlockable }; if (!string.IsNullOrWhiteSpace(itemIds)) { filter.ItemIds = itemIds.Split(',') .Where(_ => !string.IsNullOrWhiteSpace(_)) .Select(int.Parse) .ToList(); } var items = await _avatarService.PageItemsAsync(filter); var paginateModel = new PaginateViewModel { ItemCount = items.Count, CurrentPage = page, ItemsPerPage = filter.Take.Value }; foreach (var item in items.Data) { if (!string.IsNullOrWhiteSpace(item.Thumbnail)) { item.Thumbnail = _pathResolver.ResolveContentPath(item.Thumbnail); } } var viewModel = new ItemsListViewModel { Items = items.Data, PaginateModel = paginateModel }; return(PartialView("_ItemsPartial", viewModel)); }
public IActionResult ShowHomePage(int inventoryID) { List <ItemViewModels> noFinished = SaveInViewModels(_itemService.GetItemsInInventory(inventoryID)); List <ItemViewModels> hasFinished = SaveInViewModels(_itemService.GetFinishedItemsInInventory(inventoryID)); List <ItemViewModels> hasOverDue = SaveInViewModels(_itemService.GetOverdueItemsInInventory(inventoryID)); List <InventoryViewModel> allInventory = SaveInViewModels(_inventoryService.ViewAllInventory(_userView.Id)); ItemsListViewModel itemList = new ItemsListViewModel() { noFinished = noFinished, hasFinished = hasFinished, hasOverdue = hasOverDue, allInventorys = allInventory, InventoryId = inventoryID }; return(View("ShowItems", itemList)); }
public ItemsListEditWindowViewModel( IPaginationSearchableRepository <TEntity> searchableRepository, IModelMapper <TEntity, TModel> subscriptionMapper, IEntityValidator <TModel> entityValidator, IDisplayService displayService) { _searchableRepository = searchableRepository ?? throw new ArgumentNullException(nameof(searchableRepository)); _entityValidator = entityValidator ?? throw new ArgumentNullException(nameof(entityValidator)); _displayService = displayService ?? throw new ArgumentNullException(nameof(displayService)); _entityMapper = subscriptionMapper ?? throw new ArgumentNullException(nameof(subscriptionMapper)); ItemsListViewModel = new ItemsListViewModel <TModel>(); ActionCommand = new RelayCommand(HandleAction, ActionWasExecute); CancelCommand = new RelayCommand(HandleCancel); CurrentState = ItemsListEditState.NoSelected; }
public async Task <IActionResult> DeleteItem(ItemsListViewModel model) { try { await _avatarService.DeleteItemAsync(model.ItemId); ShowAlertSuccess("Item has been deleted."); } catch (GraException gex) { ShowAlertDanger("Unable to delete item: ", gex); } return(RedirectToAction(nameof(Layer), new { model.Id, model.Search, model.Unlockable, page = model.PaginateModel.CurrentPage })); }
public ActionResult GetItemList(int year = 0, int month = 0) { year = year == 0 || month == 0 ? DateTime.Now.Year : year; month = month == 0 || month == 0 ? DateTime.Now.Month : month; var from = new DateTime(year, month, 1); var to = from.AddMonths(1); var list = moneyRepository.GetItems(CurrentUserId, from, to) .Select(i => new ListItem(i)) .ToList(); var vm = new ItemsListViewModel { List = list, SelectedMonth = String.Format(@"{0}/{1:00}", year, month) }; return(Ok(vm)); }
public async Task ItemsAboutToExpire_GetLoaded_WhenFilterIsAboutToExpire() { var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockItemsRepository = new FakeItemsRepository(); //Specify items ExpirationDate mockItemsRepository.Items.ForEach(i => i.ExpirationDate = DateTime.Today.AddDays(15)); mockItemsRepository.Items[0].ExpirationDate = DateTime.Today.AddDays(-1); mockItemsRepository.Items[1].ExpirationDate = DateTime.Today; mockItemsRepository.Items[2].ExpirationDate = DateTime.Today.AddDays(1); mockItemsRepository.Items[3].ExpirationDate = DateTime.Today.AddDays(4); var mockItemsService = new ItemsService(mockItemsRepository, new InMemoryBlobCache()); var listItemsViewModel = new ItemsListViewModel(mockNavigationService.Object, mockDialogService.Object, mockItemsService); await listItemsViewModel.InitializeAsync(ItemListFilters.AboutToExpire); Assert.Equal(4, listItemsViewModel.Items.Count); }
public ViewResult ShowList(string category) { string _category = category; IEnumerable <Item> items = null; string curr_category = ""; if (string.IsNullOrEmpty(category)) { items = _items.GetAllItems.OrderBy(i => i.id); } else { if (string.Equals("Historical", category, StringComparison.OrdinalIgnoreCase)) { items = _items.GetAllItems.Where(i => i.item_category.CategoryName.Equals("Historical")).OrderBy(i => i.id); } else if (string.Equals("Food", category, StringComparison.OrdinalIgnoreCase)) { items = _items.GetAllItems.Where(i => i.item_category.CategoryName.Equals("Food")).OrderBy(i => i.id); } else if (string.Equals("Misc", category, StringComparison.OrdinalIgnoreCase)) { items = _items.GetAllItems.Where(i => i.item_category.CategoryName.Equals("Misc")).OrderBy(i => i.id); } curr_category = _category; } var item_obj = new ItemsListViewModel { allItems = items, currentCategory = curr_category }; ViewBag.Title = "Items List"; //оголошуєммо змінну і присвоюємо їй результат фунції по отримання всіх ітемів //ItemsListViewModel allitems = new ItemsListViewModel(); //allitems.getallItems = _items.GetAllItems; //allitems.currentCategory = Convert.ToString(_categories.GetAllCategories.First()); return(View(item_obj)); }