Exemplo n.º 1
0
        public IActionResult Index()
        {
            Product       product     = new Product();
            List <String> productList = new List <String>();

            foreach (Product item in product.GetAllProducts())
            {
                string name   = item?.Name ?? "NONE";
                int?   price  = item?.price ?? 0;
                string relate = item?.Related?.Name ?? "NONE";
                productList.Add(string.Format("Name ={0} Price ={1} Related={2}", name, price, relate));
            }

            ShoppingCart cart = new ShoppingCart()
            {
                Products = product.GetAllProducts().ToList()
            };

            int totalprice = cart.TotalPrice();

            ShoppingViewModel shoppingViewModel = new ShoppingViewModel()
            {
                Product = productList, price = totalprice
            };

            return(View(shoppingViewModel));
        }
Exemplo n.º 2
0
        public ActionResult Add(ShoppingViewModel model, HttpPostedFileBase image1, HttpPostedFileBase image2)
        {
            Cloth clothes = new Cloth();

            clothes.Gender      = model.Gender;
            clothes.Name        = model.Name;
            clothes.Details     = model.Details;
            clothes.Color       = model.Color;
            clothes.Brand       = model.Brand;
            clothes.BrandInfo   = model.BrandInfo;
            clothes.About       = model.About;
            clothes.LookAfter   = model.LookAfter;
            clothes.MoreDetails = model.MoreDetails;
            clothes.Image       = new byte[image1.ContentLength];
            image1.InputStream.Read(clothes.Image, 0, image1.ContentLength);
            clothes.ExtraImage = new byte[image2.ContentLength];
            image2.InputStream.Read(clothes.ExtraImage, 0, image2.ContentLength);
            //clothes.ExtraImage = model.ExtraImage;
            clothes.Price      = model.Price;
            clothes.CategoryId = int.Parse(model.Category);
            shoppingEntities.Clothes.Add(clothes);
            shoppingEntities.SaveChanges();

            return(RedirectToAction("AdminList"));
        }
Exemplo n.º 3
0
        public ShoppingPage()
        {
            InitializeComponent();

            shoppingViewModel = new ShoppingViewModel();
            BindingContext    = shoppingViewModel;
        }
Exemplo n.º 4
0
        public async Task <ActionResult> Index()
        {
            var currency = await _userContext.GetCurrentCurrency();

            var responseQuery = await _processor.ProcessQueryAsync <ProductShoppingQuery, ProductShoppingResponse>(new ProductShoppingQuery()
            {
                SkuOrSkuVariantOrName = string.Empty,
                CustomerGroup         = (await _userContext.GetCustomerGroup()),
                Currency = currency
            });

            var model = new ShoppingViewModel()
            {
                Title    = "Shopping",
                Products = responseQuery.ProductsShopping.Select(x => new ProductShoppingViewModel()
                {
                    Image = x.MainImageUrl,
                    Name  = x.Name,
                    Sku   = x.Sku,
                    Price = $"{ComponentsHelper.Currency[currency]}{x.Price.ToString("G29")} {currency}"
                }).ToArray()
            };

            return(View(model));
        }
Exemplo n.º 5
0
        public async Task <int> CreateNewShoppingStore(ShoppingViewModel shoppingViewModel)
        {
            //Example usage
            foreach (var store in shoppingViewModel.Stores)
            {
                //Logics to verify/validate entitities to Insert in Database
                var existingStore = await _unitOfWorkRepository.GetBySelectedIdAsync <Store>(store.Id);

                if (existingStore == null)
                {
                    store.Id = 0;
                    _unitOfWorkRepository.SetEntitiesToInsert(store);
                }
                else
                {
                    _unitOfWorkRepository.SetEntitiesToDelete(store);
                }
            }

            foreach (var product in shoppingViewModel.Products)
            {
                //Logics to verify/validate entities to Update in Database;
                var existingProduct = await _unitOfWorkRepository.GetBySelectedIdAsync <Product>(product.Id);

                if (existingProduct == null)
                {
                    product.Id = 0;
                    _unitOfWorkRepository.SetEntitiesToInsert(product);
                }
                else
                {
                    _unitOfWorkRepository.SetEntitiesToUpdate(product);
                }
            }

            foreach (var customer in shoppingViewModel.Customers)
            {
                //Logics to verify/validate entities to Delete in database;
                var existing = await _unitOfWorkRepository.GetBySelectedIdAsync <Customer>(customer.Id);

                if (existing != null)
                {
                    _unitOfWorkRepository.SetEntitiesToDelete(customer);
                }
                else
                {
                    customer.Id = 0;
                    _unitOfWorkRepository.SetEntitiesToInsert(customer);
                }
            }



            var committedEntities = await _unitOfWorkRepository.Commit();

            return(committedEntities);
        }
Exemplo n.º 6
0
        // GET: /<controller>/
        public ViewResult Index()
        {
            var shoppingViewModel = new ShoppingViewModel
            {
                IsFavShoe = _itemRepository.IsFavShoe
            };

            return(View(shoppingViewModel));
        }
Exemplo n.º 7
0
        public ShoppingListPage()
        {
            Title = "Shopping List Sample";

            var shoppingItemService = IoC.Container.Resolve <IShoppingItemService>();
            var navigationService   = IoC.Container.Resolve <INavigationService>();

            Content = new ShoppingListView();

            BindingContext = new ShoppingViewModel(shoppingItemService, navigationService);
        }
Exemplo n.º 8
0
        public ShoppingGridView()
        {
            InitializeComponent();

            var shoppingItemService = IoC.Container.Resolve <IShoppingItemService>();
            var navigationService   = IoC.Container.Resolve <INavigationService>();

            var viewModel = new ShoppingViewModel(shoppingItemService, navigationService);

            BindingContext = viewModel;
        }
        public IActionResult Shopping(string code)
        {
            if (!string.IsNullOrEmpty(code))
            {
                requestRepository.AddItem(code);
            }

            Request            request           = requestRepository.GetRequest();
            List <RequestItem> items             = request.Items;
            ShoppingViewModel  shoppingViewModel = new ShoppingViewModel(items);

            //injetar na view os itens do repositório
            return(base.View(shoppingViewModel));
        }
Exemplo n.º 10
0
        private ShoppingViewModel BuildCartViewModelFromProductListAndTempData
            (object tempCount, object tempId, List <ProductLineItemViewModel> products)
        {
            var svm = new ShoppingViewModel();

            svm.Products = products;
            int cartCount = 0;
            int cartId    = 0;

            if (tempCount != null)
            {
                int.TryParse(tempCount.ToString(), out cartCount);
            }
            if (tempId != null)
            {
                int.TryParse(tempId.ToString(), out cartId);
            }
            svm.CartCount = cartCount;
            svm.CartId    = cartId;
            return(svm);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 取得User的歷史消費紀錄
        /// </summary>
        /// <param name="Account"></param>
        /// <returns></returns>
        public IList <ShoppingViewModel> GetUserShoppingHistory(string Account)
        {
            var user     = GetUser(Account);
            var userlist = this._ilistRepository.GetAll().ToList().FindAll(x => x.UserID == user.UserID);

            var prdlist = this._iProductRepository.GetAll().ToList();

            IList <ShoppingViewModel> Data = new List <ShoppingViewModel>();

            foreach (var item in userlist)
            {
                ShoppingViewModel model = new ShoppingViewModel();

                model.ListID = item.ListID;
                model.Status = item.Status;
                model.Total  = item.Total;
                model.UserID = item.UserID;

                var ProductDetail = this._ilistDetailRepository.GetAll().Where(x => x.ListID == item.ListID);

                IList <ProductDetail> Detail = new List <ProductDetail>();
                foreach (var prditem in ProductDetail)
                {
                    Detail.Add(new ProductDetail()
                    {
                        ProductID   = prditem.ProductID,
                        Price       = prditem.Price,
                        Quantity    = prditem.Quantity,
                        ProductName = prdlist.Find(x => x.ProductID == prditem.ProductID).ProductName
                    });
                }


                model.List = Detail;

                Data.Add(model);
            }

            return(Data);
        }
        public UpdateAmoutResponse UpdateAmout(RequestItem requestItem)
        {
            var requestItemDB = requestItemRepository.GetRequestItem(requestItem.ID);

            if (requestItemDB != null)
            {
                requestItemDB.UpdateAmount(requestItem.Amount);

                if (requestItem.Amount == 0)
                {
                    requestItemRepository.RemoveRequestItem(requestItem.ID);
                }

                context.SaveChanges();

                var shoppingViewModel = new ShoppingViewModel(GetRequest().Items);

                return(new UpdateAmoutResponse(requestItemDB, shoppingViewModel));
            }

            throw new ArgumentException("Item não encontrado");
        }
        public ShoppingPage()
        {
            this.InitializeComponent();

            this.ViewModel = new ShoppingViewModel();

            Window.Current.Activated += CurrentWindowActivationStateChanged;
            this.cameraControl.FilterOutSmallFaces = true;
            this.cameraControl.HideCameraControls();
            this.cameraControl.CameraAspectRatioChanged += CameraControl_CameraAspectRatioChanged;

            try
            {
                eyeTracker = new EyeTracker(SettingsHelper.Instance.EyeTracker);
                // this simply creates the http client, no actual listening
                eyeTracker.StartListening();
                eyeTracker.EyeDirectionEvent += OnEyeDirection;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
            }
        }
        public async Task <ActionResult <int> > CreateShop(ShoppingViewModel sohppingViewModel)
        {
            var result = await _shoppingService.CreateNewShoppingStore(sohppingViewModel);

            return(Ok(result));
        }
Exemplo n.º 15
0
 public UpdateAmoutResponse(RequestItem requestItem, ShoppingViewModel shoppingViewModel)
 {
     RequestItem       = requestItem;
     ShoppingViewModel = ShoppingViewModel;
 }