Esempio n. 1
0
        public async Task <ActionResult <ShoppingModel> > GetShopping(string userName)
        {
            var basket = await _basketService.GetBasket(userName);

            foreach (var item in basket.Items)
            {
                var product = await _catalogService.GetCatalog(item.ProductId);

                // set additional product fields onto basket item
                item.ProductName = product.Name;
                item.Category    = product.Category;
                item.Summary     = product.Summary;
                item.Description = product.Description;
                item.ImageFile   = product.ImageFile;
            }

            var orders = await _orderService.GetOrdersByUserName(userName);

            var shoppingModel = new ShoppingModel
            {
                UserName           = userName,
                BasketWithProducts = basket,
                Orders             = orders
            };

            return(Ok(shoppingModel));
        }
Esempio n. 2
0
        public ActionResult Add(string sku, int qty)
        {
            ProductMaster prod  = App.App.MyProducts.Where(i => i.SKU == sku).FirstOrDefault();
            OrderDetail   order = new OrderDetail()
            {
                QTY = qty, products = prod, orderNumber = int.Parse(DateTime.Now.ToString("yyHHmmss"))
            };

            if (App.App.Cart.orders.Exists(i => i.products.SKU == sku))
            {
                OrderDetail modify = App.App.Cart.orders.Where(i => i.products.SKU == sku).FirstOrDefault();
                App.App.Cart.orders.Remove(modify);
                modify.QTY += qty;
                App.App.Cart.orders.Add(modify);
            }
            else
            {
                App.App.Cart.orders.Add(order);
            }

            int           count          = App.App.Cart.orders.Count;
            ShoppingModel shoppingmodels = new ShoppingModel();

            shoppingmodels.products = App.App.MyProducts;
            shoppingmodels.cart     = App.App.Cart;
            return(View("../Home/Index", shoppingmodels));
        }
Esempio n. 3
0
 public UnitOfWork(ShoppingModel dataContext)
 {
     _dataContext = dataContext;
     Customer     = new CustomerRepository(_dataContext);
     Product      = new ProductRepository(_dataContext);
     Order        = new OrderRepository(_dataContext);
 }
Esempio n. 4
0
        public async Task <ActionResult <ShoppingModel> > GetShopping(string userName)
        {
            // Get the basket for the user
            var basket = await _basketService.GetBasket(userName);

            // foreach basket item, get the product and add its attribute to the basket item
            foreach (var item in basket.Items)
            {
                var product = await _catalogService.GetCatalog(item.ProductId);

                item.ProductName        = product.Name;
                item.ParentCategoryCode = product.ParentCategoryCode;

                item.Summary        = product.Summary;
                item.Description    = product.Description;
                item.SmallImageURL  = product.SmallImageURL;
                item.MediumImageURL = product.MediumImageURL;
                item.LargeImageURL  = product.LargeImageURL;
            }

            // Get the orders for the user
            var orders = await _orderService.GetOrdersByUserName(userName);

            // Return the shopping model
            var result = new ShoppingModel
            {
                UserName           = userName,
                BasketWithProducts = basket,
                Orders             = orders
            };

            return(Ok(result));
        }
Esempio n. 5
0
 public ShoppingBusiness(string itemName, int userId, int homeId)
 {
     shoppingModel                   = new ShoppingModel();
     shoppingModel.ItemName          = itemName;
     shoppingModel.ResponsibleUserId = userId;
     shoppingModel.HomeId            = homeId;
 }
Esempio n. 6
0
        public async Task <ActionResult <ShoppingModel> > GetShopping(string userName)
        {
            // get basket with username
            // iterate basket items and consume products with basket item productId member
            // map product related members into basketitem dto with extended columns
            // consume ordering microservices in order to retrieve order list
            // return root ShoppingModel dto class which including all responses

            var basket = await _basketService.GetBasket(userName);

            foreach (var item in basket.Items)
            {
                var product = await _catalogService.GetCatalog(item.ProductId);

                // set additional product fields onto basket item
                item.ProductName = product.Name;
                item.Category    = product.Category;
                item.Summary     = product.Summary;
                item.Description = product.Description;
                item.ImageFile   = product.ImageFile;
            }

            var orders = await _orderService.GetOrdersByUserName(userName);

            var shoppingModel = new ShoppingModel
            {
                UserName           = userName,
                BasketWithProducts = basket,
                Orders             = orders
            };

            return(Ok(shoppingModel));
        }
Esempio n. 7
0
        public ActionResult Index()
        {
            ShoppingModel shopingmodels = new ShoppingModel();

            shopingmodels.products = App.App.MyProducts;
            shopingmodels.cart     = App.App.Cart;
            return(View(shopingmodels));
        }
Esempio n. 8
0
        public ActionResult Clear()
        {
            App.App.Cart.orders = new List <OrderDetail>();
            ShoppingModel shoppingmodels = new ShoppingModel();

            shoppingmodels.products = App.App.MyProducts;
            shoppingmodels.cart     = App.App.Cart;
            return(View("../Home/Index", shoppingmodels));
        }
Esempio n. 9
0
 public async Task ToggleShopping(ShoppingModel shoppingModel)
 {
     using (var context = dbFactory.CreateDbContext())
     {
         var shoppingItem = context.ShoppingItems.SingleOrDefault(s => s.Id == shoppingModel.Id);
         if (shoppingItem != null)
         {
             shoppingItem.PickTime = shoppingModel.PickTime;
             context.Update(shoppingItem);
             await context.SaveChangesAsync();
         }
     }
 }
Esempio n. 10
0
        public async Task <IActionResult> Edit(int id, [Bind("ShoppingId,Nome,CNPJ,Email,EnderecoId")] ShoppingModel shoppingModel)
        {
            if (id != shoppingModel.EnderecoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                await _repositoryShopping.UpdateAsync(id, shoppingModel);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EnderecoId"] = new SelectList(_repositoryEndereco.GetAll(), "EnderecoId", "Rua");
            return(View(shoppingModel));
        }
Esempio n. 11
0
        public async Task InitializeLadderProcess()
        {
            if (HasBuiltLadderProcess)
            {
                return;
            }

            Debug.WriteLine("Building ladder process...");
            // Browsers are single-threaded so this will actually still block the UI.
            // See: https://github.com/aspnet/Blazor/issues/560
            LadderProcess ladder = await Task.Run(() => Build.CreateLadderProcess());

            Debug.WriteLine("Ladder process built.");
            Ladder                = new LadderModel(ladder);
            Shopping              = new ShoppingModel(ladder);
            ExportToAuno          = new ExportToAunoModel(ladder);
            HasBuiltLadderProcess = true;
        }
Esempio n. 12
0
        public void Post([FromBody] ShoppingModel model)
        {
            var data = JsonConvert.SerializeObject(model);
            var body = Encoding.UTF8.GetBytes(data);

            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare("shopping", false, false, false, null);

                    channel.BasicPublish("", "shopping", null, body);
                }
        }
Esempio n. 13
0
        public async Task <IActionResult> Create([Bind("ShoppingId,Nome,CNPJ,Email,EnderecoId")] ShoppingModel shoppingModel)
        {
            if (ModelState.IsValid)
            {
                var currentUser = await _userManager.GetUserAsync(User);

                if (currentUser == null)
                {
                    return(Unauthorized());
                }

                shoppingModel.OwnerId = currentUser.Id;

                await _repositoryShopping.InsertAsync(shoppingModel);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EnderecoId"] = new SelectList(await _repositoryShopping.GetAllAsync(), "EnderecoId", "Rua", shoppingModel.EnderecoId);
            return(View(shoppingModel));
        }
Esempio n. 14
0
        public void AddShoppingItem(ShoppingModel shoppingModel)
        {
            using (SweetHomeEntities she = new SweetHomeEntities())
            {
                try
                {
                    she.Shopping.Add(new Shopping
                    {
                        Name = shoppingModel.ItemName,
                        ResponsibleUserId = shoppingModel.ResponsibleUserId,
                        HomeId            = shoppingModel.HomeId
                    });

                    she.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Esempio n. 15
0
 public async Task PushProduct(ShoppingModel product)
 {
     await Clients.All.SendAsync("GetProduct", product);
 }
Esempio n. 16
0
 public async Task ToggleShopping(ShoppingModel shoppingModel)
 {
     await http.PostAsJsonAsync("Article/Shop", shoppingModel);
 }
 public UnitOfWork(ShoppingModel context)
 {
     _context = context;
 }
Esempio n. 18
0
 public ProductRepository(ShoppingModel dataContext)
     : base(dataContext)
 {
     _context = dataContext;
 }
        public IUnitOfWork CreateUoWInstance()
        {
            var dataContext = new ShoppingModel();

            return(new UnitOfWork(dataContext));
        }
Esempio n. 20
0
 protected Repository(ShoppingModel dataContext)
 {
     _dataContext = dataContext;
     dbset        = _dataContext.Set <T>();
 }
Esempio n. 21
0
 public OrderRepository(ShoppingModel dataContext)
     : base(dataContext)
 {
     _context = dataContext;
 }
Esempio n. 22
0
 public void UpdateShoppingItem(ShoppingModel shoppingModel)
 {
     throw new NotImplementedException();
 }
Esempio n. 23
0
 public async Task SetShoppingItem(ShoppingModel shoppingModel)
 {
     await articleService.ToggleShoppingItem(shoppingModel);
 }
Esempio n. 24
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="context">Object context</param>
 public GenericRepository(ShoppingModel context)
 {
     this._context = context;
 }