Ejemplo n.º 1
0
        public async Task <IActionResult> Order([Bind] Order order)
        {
            LiveAnimalDetailsViewModel viewModel = new LiveAnimalDetailsViewModel();
            var liveAnimalDetails = await _liveAnimalService.GetLiveAnimalById(order.LiveAnimalId);

            viewModel.LiveAnimalDetails = liveAnimalDetails;
            viewModel.Related           = await GetRelated(liveAnimalDetails.Category);

            viewModel.Order = order;
            // Debug.Print(order.DeliveryDate);

            if (ModelState.IsValid == false)
            {
                return(View(viewModel));
            }

            var id = Guid.NewGuid().ToString();

            order.Id = id;
            await _orderService.AddOrder(order);

            if (order != null)
            {
                return(RedirectToAction("OrderConfirmation", "LiveAnimal", new { orderId = order.Id }));
            }
            //Error
            return(RedirectToAction("Index", "LiveAnimal"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> OrderDetails(string Id)
        {
            if (string.IsNullOrEmpty(Id))
            {
                return(RedirectToAction("Index", "Payment"));
            }

            var orderData = await _orderService.FindOrderById(Id);

            if (orderData == null)
            {
                ModelState.AddModelError("", "OrderId Not found");
                return(RedirectToAction("Index", "Payment"));
            }
            var liveAnimal = await _liveAnimalService.GetLiveAnimalById(orderData.LiveAnimalId);

            if (liveAnimal == null)
            {
                ModelState.AddModelError("", "Ordered Animal is missing.");
                return(RedirectToAction("Index", "Payment"));
            }
            LiveAnimalDetailsViewModel viewModel = new LiveAnimalDetailsViewModel
            {
                Order             = orderData,
                Related           = null,
                LiveAnimalDetails = liveAnimal,
            };

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OrderDetails([Bind] LiveAnimalDetailsViewModel model)
        {
            NameValueCollection postData = new NameValueCollection();

            //Basic Infos.
            postData.Add("total_amount", model.LiveAnimalDetails.Price.ToString());
            postData.Add("currency", "BDT");
            string ID = Guid.NewGuid().ToString();

            postData.Add("tran_id", ID);

            postData.Add("success_url", "https://farmhut.com.bd/Payment/PaymentCheck");
            postData.Add("fail_url", "https://farmhut.com.bd/Payment/PaymentCheck");
            postData.Add("cancel_url", "https://farmhut.com.bd/Payment/PaymentCheck");

            //Customer Info.
            postData.Add("cus_name", model.Order.Name);
            postData.Add("cus_add1", model.Order.Address);
            postData.Add("cus_phone", model.Order.PhoneNumber);
            postData.Add("cus_email", "*****@*****.**");
            postData.Add("cus_city", "Dhaka");
            postData.Add("cus_postcode", "1000");
            postData.Add("cus_country", "Bangladesh");
            postData.Add("shipping_method", "NO");
            postData.Add("num_of_item", "1");

            postData.Add("emi_option", "0");

            //Product Infos.
            postData.Add("product_name", model.LiveAnimalDetails.Id);
            postData.Add("product_category", model.LiveAnimalDetails.Title);
            postData.Add("product_profile", "general");

            var live = await _liveAnimalService.GetLiveAnimalById(model.LiveAnimalDetails.Id);

            postData.Add("value_a", model.Order.Id);
            postData.Add("value_b", live.Title);
            postData.Add("value_c", live.Category);
            postData.Add("value_d", live.Color);

            _logger.LogInformation($"SSL COmerzzzzzzzzzzzzzzz NmaeValueCollection: {JsonConvert.SerializeObject(postData)}");

            if (live.Sold == false)
            {
                SSLCommerzInitResponse response = _sslCommerzService.InitiateTransaction(postData);
                _logger.LogInformation($"SSL COmerzzzzzzzzzzzzzzz Responseeeeeee: {JsonConvert.SerializeObject(response)}");
                if (response == null)
                {
                    // ERROR PAGE
                    return(RedirectToAction("Index", "Payment"));
                }
                return(Redirect(response.GatewayPageURL));
            }

            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Order(string Id)
        {
            if (string.IsNullOrEmpty(Id))
            {
                return(RedirectToAction("Index", "LiveAnimal"));
            }

            LiveAnimalDetailsViewModel viewModel = new LiveAnimalDetailsViewModel();

            var liveAnimalDetails = await _liveAnimalService.GetLiveAnimalById(Id);

            viewModel.LiveAnimalDetails = liveAnimalDetails;
            viewModel.Related           = await GetRelated(liveAnimalDetails.Category);

            return(View(viewModel));
        }