public void FillBooks()
 {
     using (CartClient client = new CartClient())
     {
         Books = client.getItemByTitle(string.Empty);
     }
 }
예제 #2
0
 //Lay danh sach mon hoc da luu trong cart
 public ActionResult Cart()
 {
     if (AuthorizeUser())
     {
         int        idUser = Convert.ToInt32(Session["UserId"]);
         CartClient CC     = new CartClient();
         ViewBag.cart = CC.getCartbyUser(idUser);
         return(View());
     }
     return(Redirect("/Account/Login"));
 }
예제 #3
0
        protected static void Main()
        {
            var logger = new ConsoleLogger();

            logger.LogInfo("🍩 Welcome to the Doughnut Shop.  Let's demo our cart client...");
            logger.LogInfo("----------------------------------------------------------------");

            // The underlying cart representation
            var shoppingCart = new Cart(logger);

            // The implementation of cart memory we'd like to use in our client
            var memory = new CartMemory();

            // This is the object we work with in our program
            var cartClient = new CartClient(shoppingCart, memory, logger);

            // Simulate Customer behavior:
            cartClient.Add(Doughnut.Chocolate);
            cartClient.Add(Doughnut.Vanilla);
            cartClient.Add(Doughnut.Blueberry);

            Thread.Sleep(1_500);
            cartClient.Add(Doughnut.Chocolate);
            Thread.Sleep(1_500);
            cartClient.Add(Doughnut.Chocolate);
            Thread.Sleep(1_000);
            cartClient.Add(Doughnut.Chocolate);
            Thread.Sleep(800);
            cartClient.Add(Doughnut.Chocolate);
            Thread.Sleep(500);
            cartClient.Add(Doughnut.Chocolate);
            Thread.Sleep(2_000);

            logger.LogInfo("----------------------------------------------------------------", ConsoleColor.Blue);
            logger.LogInfo("Initial Cart:", ConsoleColor.Blue);
            logger.LogInfo("----------------------------------------------------------------", ConsoleColor.Blue);
            cartClient.Print();

            cartClient.Undo();
            cartClient.Undo();
            cartClient.Undo();

            logger.LogInfo("----------------------------------------------------------------", ConsoleColor.Blue);
            logger.LogInfo("Final Cart after Undo Operations:", ConsoleColor.Blue);
            logger.LogInfo("----------------------------------------------------------------", ConsoleColor.Blue);

            cartClient.Print();

            logger.LogInfo("----------------------------------------------------------------", ConsoleColor.Blue);
            logger.LogInfo("Current Memory Dump:", ConsoleColor.Blue);
            logger.LogInfo("----------------------------------------------------------------", ConsoleColor.Blue);

            cartClient.GetMemoryDump();
        }
예제 #4
0
        private CommerceService()
        {
            this._listClient      = ClientContext.Clients.CreateListClient();
            this._browseClient    = ClientContext.Clients.CreateBrowseClient();
            this._storeClient     = ClientContext.Clients.CreateStoreClient();
            this._cartClient      = ClientContext.Clients.CreateCartClient();
            this._orderClient     = ClientContext.Clients.CreateOrderClient();
            this._priceClient     = ClientContext.Clients.CreatePriceClient();
            this._marketingClient = ClientContext.Clients.CreateMarketingClient();
            this._themeClient     = ClientContext.Clients.CreateThemeClient();
            this._reviewsClient   = ClientContext.Clients.CreateReviewsClient();

            _themesCacheStoragePath = ConfigurationManager.AppSettings["ThemeCacheFolder"];
            this._viewLocator       = new FileThemeViewLocator(_themesCacheStoragePath);
            this._cartHelper        = new CartHelper(this);
        }
예제 #5
0
        //Buy from cart
        public bool AddListHistory()
        {
            if (AuthorizeUser())
            {
                try
                {
                    int        idUser = Convert.ToInt32(Session["UserId"]);
                    CartClient CC     = new CartClient();
                    var        list   = CC.getCartbyUser(idUser);
                    DateTime   time   = DateTime.Now;
                    foreach (var item in list)
                    {
                        try
                        {
                            int     price   = Convert.ToInt32(item.price - (item.price * item.discount / 100));
                            History history = new History();
                            history.id_course = item.id_course;
                            history.id_user   = item.id_user;
                            history.price     = price;
                            history.date      = time;
                            db.Histories.Add(history);

                            DeleteCart(history.id_user, history.id_course);
                            db.SaveChanges();
                        }
                        catch
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
            return(false);
        }
예제 #6
0
        public CommerceService()
        {
            this._listClient      = ClientContext.Clients.CreateListClient();
            this._browseClient    = ClientContext.Clients.CreateBrowseClient();
            this._storeClient     = ClientContext.Clients.CreateStoreClient();
            this._cartClient      = ClientContext.Clients.CreateCartClient();
            this._orderClient     = ClientContext.Clients.CreateOrderClient();
            this._securityClient  = ClientContext.Clients.CreateSecurityClient();
            this._priceClient     = ClientContext.Clients.CreatePriceClient();
            this._marketingClient = ClientContext.Clients.CreateMarketingClient();
            this._inventoryClient = ClientContext.Clients.CreateInventoryClient();
            this._themeClient     = ClientContext.Clients.CreateThemeClient();
            this._pageClient      = ClientContext.Clients.CreatePageClient();
            this._reviewsClient   = ClientContext.Clients.CreateReviewsClient();

            _themesCacheStoragePath = ConfigurationManager.AppSettings["ThemeCacheFolder"];
            _pagesCacheStoragePath  = ConfigurationManager.AppSettings["PageCacheFolder"];

            this._viewLocator = new FileThemeViewLocator(HostingEnvironment.MapPath(_themesCacheStoragePath));

            this._cartHelper = new CartHelper(this);
        }
 public static CartClient CreateCartClient(this CommerceClients source, string serviceUrl)
 {
     var client = new CartClient(new Uri(serviceUrl), source.CreateMessageProcessingHandler());
     return client;
 }
예제 #8
0
        public void test_cart_client_connection()
        {
            CartClient proxy = new CartClient();

            proxy.Open();
        }
예제 #9
0
 public static CartClient CreateCartClient(this CommerceClients source, string serviceUrl, string appId, string secretKey)
 {
     var client = new CartClient(new Uri(serviceUrl), appId, secretKey);
     return client;
 }
예제 #10
0
        public static CartClient CreateCartClient(this CommerceClients source, string serviceUrl)
        {
            var client = new CartClient(new Uri(serviceUrl), source.CreateMessageProcessingHandler());

            return(client);
        }
예제 #11
0
        public static CartClient CreateCartClient(this CommerceClients source, string serviceUrl, string appId, string secretKey)
        {
            var client = new CartClient(new Uri(serviceUrl), appId, secretKey);

            return(client);
        }