Exemplo n.º 1
0
        public ActionResult Checkout(Order order)
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext);

            order.OrderStatus = "Order Created";
            order.Email       = User.Identity.Name;
            //Process Payment

            order.OrderStatus = "Payment Processed";
            orderService.CreateOrder(order, basketItems);
            basketService.ClearBasket(this.HttpContext);

            return(RedirectToAction("Thankyou", new { OrderId = order.Id }));
        }
Exemplo n.º 2
0
        public ActionResult Checkout(Order order)
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext);

            order.OrderStatus = "Order Created";
            //Ensure that the user is logged in and they are linked to their actual order
            order.Email = User.Identity.Name;
            //process payment

            order.OrderStatus = "Payment Processed";
            orderService.CreateOrder(order, basketItems);
            basketService.ClearBasket(this.HttpContext);

            return(RedirectToAction("Thankyou", new { OrderId = order.Id }));
        }
Exemplo n.º 3
0
        public ActionResult Checkout(Order order) // this method doesn't need a view, is the logic to process the payment
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext);

            order.OrderStatus = "Order Created";    // this will set the OrderStatus field in db as "OrderCreated"
            order.Email       = User.Identity.Name; // this will set the OrderEmail field in the db as the user

            // process payment

            order.OrderStatus = "Payment Processed";
            orderService.CreateOrder(order, basketItems);
            basketService.ClearBasket(this.HttpContext);

            return(RedirectToAction("ThankYou", new { OrderId = order.Id }));
        }
Exemplo n.º 4
0
        public ActionResult Checkout(Order order)
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext); //get the basketitems because basket service is waiting for that

            order.OrderStatus = "Order Created";
            order.Email       = User.Identity.Name;

            //process payment

            order.OrderStatus = "Payment Processed";
            orderService.CreateOrder(order, basketItems);
            basketService.ClearBasket(this.HttpContext);

            return(RedirectToAction("ThankYou", new { OrderId = order.Id }));
        }
Exemplo n.º 5
0
        public ActionResult Checkout(Order order)
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext);

            order.OrderStatus = "Order Created";        //update the order status
            order.Email       = User.Identity.Name;     //here is to check that the user is logged in!!!!!!!!!!!!!!1

            //process payment

            order.OrderStatus = "Payment Processed";
            orderService.CreateOrder(order, basketItems);
            basketService.ClearBasket(this.HttpContext);

            return(RedirectToAction("Thankyou", new { OrderId = order.Id }));
        }
Exemplo n.º 6
0
        public ActionResult Checkout(Order order)
        {
            var basketItems = BasketService.GetBasketItems(this.HttpContext);

            order.OrderStatus = "Order Created";
            order.Email       = User.Identity.Name;

            // payment processing happens

            order.OrderStatus = "Processed Payment";
            OrderService.CreateOrder(order, basketItems);
            BasketService.ClearBasket(this.HttpContext);

            return(RedirectToAction("ThankYou", new { OrderID = order.Id }));
        }
Exemplo n.º 7
0
        public ActionResult Checkout(Order order)
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext); // get basket items from basketService

            order.OrderStatus = "Order Created";
            order.Email       = User.Identity.Name; // make sure user is logged in and that we r linking the login email with the actual order

            //process payment

            order.OrderStatus = "Payment Processed";
            orderService.CreateOrder(order, basketItems);                     // created our order with the basket items
            basketService.ClearBasket(this.HttpContext);                      // clear the basket

            return(RedirectToAction("ThankYou", new { OrderId = order.Id })); // sent them to our thank u page with an order id
        }
Exemplo n.º 8
0
        public async Task AddToBasket_WhenAddOneItem_ExpectOneItemInBasket()
        {
            // Arrange
            const int expected = 1;

            // Act
            _sut.ClearBasket();
            await _sut.AddToBasket(Id);

            var actual = _sut.NoOfProductsInBasket;

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 9
0
        public ActionResult Checkout(Order order)
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext);

            order.OrderStatus = "Order Created";
            order.Email       = User.Identity.Name;
            //TODO: process payment...

            order.OrderStatus = "Payment Processed";
            orderService.CreateOrder(order, basketItems);
            //clear the basket
            basketService.ClearBasket(this.HttpContext);

            //And finally redirect the user to the thank you page with order id.
            return(RedirectToAction("Thankyou", new { OrderId = order.Id }));
        }
Exemplo n.º 10
0
        public ActionResult Checkout(Order order)
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext);

            order.OrderStatus = "Order Created";
            order.Email       = User.Identity.Name;

            //process payment - this could either be a redirect to another view, or a two way process
            //using something like paypal.
            //for simplicity, and because payment processing itself can vary wildy depedant on what payment mechanism you
            //us we'll pretend payment was successful.
            order.OrderStatus = "Payment Processed";
            orderService.CreateOrder(order, basketItems);
            basketService.ClearBasket(this.HttpContext);

            return(RedirectToAction("ThankYou", new { OrderId = order.Id }));
        }
Exemplo n.º 11
0
        public ActionResult CheckOut(Order order)
        {
            if (!ModelState.IsValid)
            {
                return(View(order));
            }

            List <BasketItemViewModel> basketItems = basketService.GetBasketItems(this.HttpContext);

            order.status = "Order Created";
            order.Email  = User.Identity.Name;
            //Payment success
            order.status = "Payment Processed";
            orderService.CreateOrder(order, basketItems);
            basketService.ClearBasket(this.HttpContext);
            return(RedirectToAction("ThankYou", new { OrderId = order.Id }));
        }
Exemplo n.º 12
0
        public IHttpActionResult Clear()
        {
            try {
                var basket     = _basket_service.ClearBasket(_userId);
                var basket_dto = ConvertToDto(basket);

                return(Ok(basket_dto));
            }
            catch (NotFoundException ex)
            {
                return(NotFound());
            }
            catch (Exception ex)
            {
                return(InternalServerError(new Exception(string.Format("Couldn't clear Cart"), ex)));
            }
        }
Exemplo n.º 13
0
        public ActionResult CheckOut(Order order)
        {
            if (ModelState.IsValid)
            {
                var basketItems = basketService.GetBasketItems(this.HttpContext);
                order.OrderStatus = "Order Created";
                order.Email       = User.Identity.Name;

                //payment processing

                order.OrderStatus = "Payment processed";
                orderService.CreateOrder(order, basketItems);
                basketService.ClearBasket(this.HttpContext);

                return(RedirectToAction("Thankyou", new { OrderId = order.Id }));
            }
            else
            {
                return(View(order));
            }
        }
Exemplo n.º 14
0
        public async Task <ActionResult> Index(CheckoutViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var customer = await customerService.GetCustomerByName(User.Identity.Name, context);

            // Save the address for this customer
            viewModel.Address.Customer = customer;
            await addressService.SaveAddress(viewModel.Address, context);

            // Create the order for this set of products
            var order = orderService.CreateOrder(customer, viewModel.Address);
            await orderService.SaveOrder(order, context);

            // Clear shopping basket
            basketService.ClearBasket();

            return(View("Complete", order));
        }
Exemplo n.º 15
0
 public IActionResult ClearBasket()
 {
     _basketService.ClearBasket();
     _logger.Log(_userManager.GetUserId(HttpContext.User), "ClearBasket");
     return(RedirectToAction("Basket"));
 }
Exemplo n.º 16
0
 public void ClearOrder()
 {
     _productService.ResetProducts();
     _basketService.ClearBasket();
 }
Exemplo n.º 17
0
        public ActionResult Clear()
        {
            basketService.ClearBasket();

            return(RedirectToAction("Details"));
        }
Exemplo n.º 18
0
        //[Authorize(Roles = RoleName.AskAdmin + "," + RoleName.AskUser)]
        public void PlaceOrder()
        {
            var basketItems = basketService.GetBasketItems(this.HttpContext);
            var order       = new Core.Models.Order
            {
                OrderNumber = Common.GetRandomInvoiceNumber()
            };

            OrderItem orderitems = new OrderItem();

            foreach (var item in basketItems)
            {
                orderitems.OrderId     = order.Id;
                orderitems.ProductId   = item.ProductId;
                orderitems.ProductName = item.ProductName;
                orderitems.Image       = item.Image;
                orderitems.Image2      = item.Image2;
                orderItemContext.Commit();
            }

            order.InvoiceNumber = "Shop.MyRockies.Network" + @DateTime.Now.Year + order.OrderNumber;
            order.OrderStatus   = "Order Created";
            orderService.CreateOrder(order, basketItems);
            order.OrderStatus = "Payment Processed";
            //order.CompletedAt = DateTime.Now;
            orderService.UpdateOrder(order);



            //Make the product sold remove
            foreach (var item in order.OrderItems)
            {
                List <Product> products = productContext.Collection().Where(p => p.Id == item.ProductId).ToList();
                foreach (var prod in products)
                {
                    Product product = productContext.Find(prod.Id);
                    product.Sold     = true;
                    product.DateSold = DateTime.Now;
                    productContext.Commit();
                }
            }

            //Email Customer
            string CustomerEmail = User.Identity.Name;;

            var subject     = "Shop.MyRockies.Network New Order: " + order.OrderNumber + " Recieved";
            var fromAddress = "*****@*****.**";
            var toAddress   = CustomerEmail;
            var emailBody   = "Email From: Shop.MyRockies.Network Message: Thank you for your order: " + order.OrderNumber;

            var smtp = new SmtpClient();

            {
                smtp.Host           = "smtp.myrockies.network";
                smtp.Port           = 587;
                smtp.EnableSsl      = false;
                smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp.Credentials    = new NetworkCredential("*****@*****.**", "bdFawHs7");
                smtp.Timeout        = 20000;
            }

            smtp.Send(fromAddress, toAddress, subject, emailBody);


            //Email Admin
            subject     = "Store.com New Question: " + order.OrderNumber;
            fromAddress = "*****@*****.**";
            toAddress   = "*****@*****.**";
            emailBody   = "Email From: Store.com Message: A New Order: " + order.OrderNumber;

            var smtp1 = new SmtpClient();

            {
                smtp1.Host           = "smtp.myrockies.network";
                smtp1.Port           = 587;
                smtp1.EnableSsl      = false;
                smtp1.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp1.Credentials    = new NetworkCredential("*****@*****.**", "bdFawHs7");
                smtp1.Timeout        = 20000;
            }

            smtp1.Send(fromAddress, toAddress, subject, emailBody);

            basketService.ClearBasket(this.HttpContext);
        }
 public IActionResult ClearBasket()
 {
     _log.LogInformation("Clearing basket.");
     _basketService.ClearBasket();
     return(Ok());
 }
        public IActionResult ClearBasket(string clientId, string basketId)
        {
            bool isCleared = _basketService.ClearBasket(clientId, basketId);

            return(new JsonResult(isCleared));
        }
        public IActionResult RemoveAllItems(string customerId)
        {
            var basket = _basketService.ClearBasket(customerId);

            return(new OkObjectResult(basket));
        }
Exemplo n.º 22
0
 private void ClearBasket(int basketId)
 {
     _basketService.ClearBasket(basketId);
 }
Exemplo n.º 23
0
 private void ClearBasket(string cartId)
 {
     _basketService.ClearBasket(cartId);
 }
Exemplo n.º 24
0
        public async Task <IActionResult> ClearUserBasket([FromRoute] int id)
        {
            await basketService.ClearBasket(id);

            return(Ok());
        }
Exemplo n.º 25
0
        public async Task BasketActions_WorkAsExpected()
        {
            const int Item1Id = 1;
            const int Item2Id = 2;
            const int Item3Id = 3;
            const int Item4Id = 4;

            // First log on as admin user
            var response = await _authenticationService.TryLogin("admin", "pass");

            response.IsSuccessful.Should().BeTrue();

            // Simulate the call to _basketHttpClientProvider.SetAuthentication(string token)
            _basketHttpClientProvider.AuthenticatedClient.AddAuthorizationHeader(response.Item.Token);

            // Start by adding a single item
            var addItemResponse = await _basketService.AddItemToBasket(new BasketItem(Item1Id, 1));

            addItemResponse.IsSuccessful.Should().BeTrue();
            addItemResponse.ErrorMessage.Should().BeEmpty();

            await AssertItemsInBasket(1, 1);

            // Update the quantity
            var updateItemResponse = await _basketService.UpdateBasketItem(new BasketItem(Item1Id, 2));

            updateItemResponse.IsSuccessful.Should().BeTrue();
            updateItemResponse.ErrorMessage.Should().BeEmpty();

            await AssertItemsInBasket(1, 2);

            // Add 3 more items. 1 by "updating it"
            addItemResponse = await _basketService.AddItemToBasket(new BasketItem(Item2Id, 1));

            addItemResponse = await _basketService.AddItemToBasket(new BasketItem(Item3Id, 1));

            await _basketService.UpdateBasketItem(new BasketItem(Item4Id, 1));

            await AssertItemsInBasket(4, 5);

            // Remove 1 item from basket directly
            var removeResponse = await _basketService.RemoveItemFromBasket(new BasketItem(Item4Id, 1));

            removeResponse.IsSuccessful.Should().BeTrue();
            removeResponse.ErrorMessage.Should().BeEmpty();

            await AssertItemsInBasket(3, 4);

            // Remove 1 item by updating quantity to zero
            await _basketService.UpdateBasketItem(new BasketItem(Item3Id, 0));

            await AssertItemsInBasket(2, 3);

            // Test clearing out basket
            var clearResponse = await _basketService.ClearBasket();

            clearResponse.IsSuccessful.Should().BeTrue();
            clearResponse.ErrorMessage.Should().BeEmpty();

            await AssertItemsInBasket(0, 0);
        }
Exemplo n.º 26
0
        public async Task <IActionResult> ClearBasket()
        {
            await basketService.ClearBasket();

            return(RedirectToAction("Index", "Home"));
        }