// handle null
        public IActionResult ViewCart(Guid StoreId)
        {
            string sessionId = HttpContext.Session.GetString("customerId");

            if (sessionId == null)
            {
                ModelState.AddModelError("Failure", "User is not logged in");
                StoreListViewModel storeList = _logic.GetStoreList();
                return(View("Index", storeList));
            }

            Guid customerId = new Guid(sessionId);

            CartInfoViewModel cartView = _logic.GetCustomerCartAtStore(StoreId, customerId);

            if (cartView == null)
            {
                ModelState.AddModelError("Failure", "Customer or store does not exist");
                StoreListViewModel storeList = _logic.GetStoreList();
                return(View("Index", storeList));
            }


            return(View(cartView));
        }
        //
        // GET: /Super/Stores/

        public ActionResult Index(int pageNumber = 1, int pageSize = 100)
        {
            if (pageNumber < 1)
            {
                pageNumber = 1;
            }

            int allCount = MTApp.AccountServices.Stores.CountOfAll();

            MTApp.AccountServices.Stores.FindAllPaged(pageNumber, pageSize);

            StoreListViewModel model = new StoreListViewModel();

            foreach (Store s in MTApp.AccountServices.Stores.FindAllPaged(pageNumber, pageSize))
            {
                SuperStoreViewModel m = new SuperStoreViewModel(s);
                m.Users = MTApp.AccountServices.FindAdminUsersByStoreId(s.Id);
                model.Stores.Add(m);
            }

            model.PagerData.CurrentPage         = pageNumber;
            model.PagerData.PageSize            = pageSize;
            model.PagerData.TotalItems          = allCount;
            model.PagerData.PagerUrlFormat      = Url.Content("~/super/stores/?pageNumber={0}&pageSize=" + pageSize);
            model.PagerData.PagerUrlFormatFirst = Url.Content("~/super/stores/?pageNumber=1&pageSize=" + pageSize);

            return(View(model));
        }
Example #3
0
        public void ReturnDefaultViewWithRespectiveModel()
        {
            // Arrange
            var storeServiceMock   = new Mock <IStoreService>();
            var mappingServiceMock = new Mock <IMappingService>();
            var utilsMock          = new Mock <IUtilitiesService>();

            var controller = new StoreItemsController(storeServiceMock.Object, mappingServiceMock.Object, utilsMock.Object);

            storeServiceMock.Setup(x => x.GetPagesCount(It.IsAny <string>())).Returns(1);
            utilsMock.Setup(x => x.GetPage(It.IsAny <int?>(), It.IsAny <int>())).Returns(1);

            var items = new List <StoreItem>();

            storeServiceMock.Setup(x => x.GetFilteredItemsByPage(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns(items);
            var mappedItems = new List <StoreItemViewModel>();

            mappingServiceMock.Setup(x => x.Map <IEnumerable <StoreItemViewModel> >(items)).Returns(mappedItems);
            var model = new StoreListViewModel();

            mappingServiceMock.Setup(x => x.Map <StoreListViewModel>(mappedItems)).Returns(model);
            utilsMock.Setup(x => x.AssignViewParams(model, It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>())).Returns(model);

            // Act & Assert
            controller.WithCallTo(x => x.Index(null, null))
            .ShouldRenderDefaultView()
            .WithModel <StoreListViewModel>(x => x == model);
        }
        public AddStore(int userId, UnitOfWork repo)
        {
            repository = repo;
            InitializeComponent();
            this.CurrentUser = repository.Users.FindBy(u => u.UserID == userId).SingleOrDefault();
            LoadStores();
            var viewmodel = new StoreListViewModel(this.CurrentUser.StoreUsers.ToList());

            userstorebindingSource.DataSource = viewmodel.storeslist;
        }
Example #5
0
        public MainPage()
        {
            InitializeComponent();
            BindingContext = new StoreListViewModel();

            //TODO -Now-
            //TOD - global Start backgroud tasks on separate thread
            //3 - Load check if we all the images
            //2- Any available updates
            //1 - Initialize user session
        }
        public IActionResult AddNewInventory(AddInventoryViewModel newInventory)
        {
            ShoppingListViewModel currentStoreInventory = _logic.AddNewInventory(newInventory.StoreId, newInventory.ProductName, newInventory.QuantityAdded);

            if (currentStoreInventory == null)
            {
                ModelState.AddModelError("Failure", "Product does not exist");
                StoreListViewModel storeList = _logic.GetStoreList();
                return(View("Index", storeList));
            }
            return(RedirectToAction("Store", "Shop", new { id = newInventory.StoreId }));
        }
Example #7
0
        public IActionResult Pager(Guid id, int page)
        {
            StoreListViewModel vm = new StoreListViewModel();
            var    category_cacheKey = $"Store_Pager_Category";
            var    app_cacheKey = $"Store_Pager_{id}_{page}";
            string category_cached, app_cached;
            IList <StoreCategories> categories = null;
            StoreAppResult          apps       = null;

            if (!_memoryCache.TryGetValue(category_cacheKey, out category_cached))
            {
                categories      = _storeRepository.GetCategories();
                category_cached = JsonConvert.SerializeObject(categories);
                _memoryCache.Set(category_cacheKey, category_cached, new MemoryCacheEntryOptions()
                {
                    SlidingExpiration = TimeSpan.FromHours(6)
                });
            }
            else
            {
                try
                {
                    categories = JsonConvert.DeserializeObject <IList <StoreCategories> >(category_cached);
                }
                catch
                {
                    categories = _storeRepository.GetCategories();
                }
            }
            if (!_memoryCache.TryGetValue(app_cacheKey, out app_cached))
            {
                apps       = _storeRepository.GetApps(id, _pageSize, page);
                app_cached = JsonConvert.SerializeObject(categories);
                _memoryCache.Set(category_cacheKey, app_cached, new MemoryCacheEntryOptions()
                {
                    SlidingExpiration = TimeSpan.FromHours(6)
                });
            }
            else
            {
                try
                {
                    apps = JsonConvert.DeserializeObject <StoreAppResult>(app_cached);
                }
                catch
                {
                    apps = _storeRepository.GetApps(id, _pageSize, page);
                }
            }
            vm.StoreCategories = categories;
            vm.AppResult       = apps;
            return(View("Index", vm));
        }
        // GET: /<controller>/
        public async Task <ActionResult> Index()
        {
            var _stores = (await _storeAppService.GetAll(new PagedResultRequestDto {
                MaxResultCount = MaxNum
            })).Items;
            //Paging not implemented yet 
            var model = new StoreListViewModel
            {
                Stores = _stores
            };

            return(View(model));
        }
Example #9
0
        public ActionResult Done(int page = 1)
        {
            int PageSize             = 10;
            var store                = _StoreService.GetAll(0);
            StoreListViewModel model = new StoreListViewModel
            {
                OrderInStore = store,
                PageCount    = (int)(Math.Ceiling(store.Count / (double)PageSize)),
                PageSize     = PageSize,
                CurrentPage  = page
            };

            return(View(model));
        }
Example #10
0
        public StoreList()
        {
            try
            {
                InitializeComponent();

                BindingContext = viewModel = new StoreListViewModel();
                collectionView.SelectionChanged += CollectionView_SelectionChanged;
            }
            catch (Exception ex)
            {
                ex = ex;
            }
        }
        public IActionResult Index()
        {
            FranchiseBuilder company      = new FranchiseBuilder();
            SupplierBuilder  allSuppliers = new SupplierBuilder();

            List <Franchise> allStores = company.SellFranchise();


            StoreListViewModel viewModel = new StoreListViewModel();

            viewModel.Stores    = allStores;
            viewModel.Suppliers = allSuppliers.GetSuppliers();

            return(View(viewModel));
        }
Example #12
0
        /// <summary>
        /// Gets a list of all stores in the database
        /// </summary>
        /// <returns>List of all stores</returns>
        public StoreListViewModel GetStoreList()
        {
            StoreListViewModel        storeList       = new StoreListViewModel();
            List <StoreInfoViewModel> storeViewModels = new List <StoreInfoViewModel>();
            List <StoreLocation>      stores          = _repo.GetStoreList();


            foreach (StoreLocation s in stores)
            {
                storeViewModels.Add(_mapper.ConvertStoreToStoreInfoViewModel(s));
            }

            storeList.StoreLocations = storeViewModels;

            return(storeList);
        }
        public void ConstructorShouldInitializeMember()
        {
            var stores = new List <Store>();

            stores.Add(new Store {
                Name = "store"
            });
            _storageSystem.Setup(s => s.Stores).Returns(stores);

            var viewModel = new StoreListViewModel(_storageSystem.Object, _eventAggregator);

            viewModel.Stores.Count.Should().Be(1);
            var storeViewModel = viewModel.Stores.First();

            storeViewModel.Name.Should().Be("store");
        }
        public void ReceiveAddStoreEventShouldAddStore()
        {
            var store = new Store {
                Name = "expected"
            };
            var storeEvent = _eventAggregator.GetEvent <PubSubEvent <AddStoreEvent> >();

            _storageSystem.Setup(s => s.Stores).Returns(new List <Store>());
            var viewModel = new StoreListViewModel(_storageSystem.Object, _eventAggregator);

            storeEvent.Publish(new AddStoreEvent {
                Store = store
            });

            Task.Delay(5).Wait();
            viewModel.Stores.Count.Should().Be(1);
            var storeViewModel = viewModel.Stores.First();

            storeViewModel.Name.Should().Be("expected");
        }
        public IActionResult AddInventory(Guid id)
        {
            AddInventoryViewModel addInventory = _logic.AddInventory(id);

            if (addInventory == null)
            {
                ModelState.AddModelError("Failure", "Store does not exist");
                StoreListViewModel storeList = _logic.GetStoreList();
                return(View("Index", storeList));
            }

            List <string> productNames = new List <string>();

            foreach (var item in addInventory.Products)
            {
                productNames.Add(item.ProductName);
            }

            ViewBag.Inventory = new SelectList(productNames);

            return(View(addInventory));
        }
Example #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_store_list);

            _viewModel = App.Container.GetInstance <StoreListViewModel>();

            _refreshLayout     = FindViewById <SwipeRefreshLayout>(Resource.Id.SwipeRefreshLayout);
            _storeRecyclerView = FindViewById <RecyclerView>(Resource.Id.StoreRecyclerView);
            _createButton      = FindViewById <Button>(Resource.Id.CreateButton);
            _progressBar       = FindViewById <ProgressBar>(Resource.Id.ProgressBar);

            _storeListAdapter = new StoreListAdapter(_viewModel);
            _storeRecyclerView.SetAdapter(_storeListAdapter);
            _storeRecyclerView.SetLayoutManager(new LinearLayoutManager(this));

            _viewModel.PropertyChanged += _viewModel_PropertyChanged;

            _refreshLayout.Refresh += _swipeRefreshLayout_Refresh;

            _viewModel.RefreshListCommand?.Execute(null);
        }
        public IActionResult Checkout(Guid cartId)
        {
            string sessionId = HttpContext.Session.GetString("customerId");

            if (sessionId == null)
            {
                ModelState.AddModelError("Failure", "User is not logged in");
                StoreListViewModel storeList = _logic.GetStoreList();
                return(View("Index", storeList));
            }

            Guid customerId = new Guid(sessionId);

            CartInfoViewModel checkedoutOrder = _logic.CheckoutCart(customerId, cartId);

            if (checkedoutOrder.error == 1)
            {
                TempData["ModelState"] = $"{checkedoutOrder.errorMessage}";
                ShoppingListViewModel storeInventory = _logic.GetStoreInventory(checkedoutOrder.Store.StoreLocationId);
                return(RedirectToAction("Store", "ViewCart", new { id = checkedoutOrder.Store.StoreLocationId }));
            }
            return(RedirectToAction("ViewPastOrder", new { orderId = checkedoutOrder.OrderId }));
        }
        // handle null
        // look at routing
        public IActionResult ViewPastOrders()
        {
            string sessionId = HttpContext.Session.GetString("customerId");

            if (sessionId == null)
            {
                ModelState.AddModelError("Failure", "User is not logged in");
                StoreListViewModel storeList = _logic.GetStoreList();
                return(View("Index", storeList));
            }

            Guid customerId = new Guid(sessionId);

            CartListViewModel orderList = _logic.GetUserPastOrders(customerId);

            if (orderList == null)
            {
                ModelState.AddModelError("Failure", "Customer does not exist");
                StoreListViewModel storeList = _logic.GetStoreList();
                return(View("Index", storeList));
            }

            return(View(orderList));
        }
Example #19
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            BindingContext = new StoreListViewModel(AppContainer.Resolve <IStoreService>());
        }
        public IActionResult Index()
        {
            StoreListViewModel storeList = _logic.GetStoreList();

            return(View(storeList));
        }
Example #21
0
 public StoreListAdapter(StoreListViewModel viewModel)
 {
     _viewModel = viewModel;
 }
Example #22
0
 public StoreList()
 {
     InitializeComponent();
     BindingContext = new StoreListViewModel();
 }
 public ItemsPage()
 {
     InitializeComponent();
     BindingContext = viewModel = new StoreListViewModel();
 }